rouge 3.4.1 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rouge.rb +3 -0
- data/lib/rouge/cli.rb +19 -2
- data/lib/rouge/demos/bpf +7 -0
- data/lib/rouge/demos/brainfuck +5 -0
- data/lib/rouge/demos/magik +6 -0
- data/lib/rouge/formatter.rb +2 -2
- data/lib/rouge/formatters/tex.rb +90 -0
- data/lib/rouge/guessers/glob_mapping.rb +1 -1
- data/lib/rouge/lexer.rb +22 -10
- data/lib/rouge/lexers/abap.rb +11 -11
- data/lib/rouge/lexers/actionscript.rb +34 -34
- data/lib/rouge/lexers/apache.rb +8 -8
- data/lib/rouge/lexers/apple_script.rb +15 -14
- data/lib/rouge/lexers/awk.rb +25 -25
- data/lib/rouge/lexers/biml.rb +4 -4
- data/lib/rouge/lexers/bpf.rb +104 -0
- data/lib/rouge/lexers/brainfuck.rb +53 -0
- data/lib/rouge/lexers/bsl.rb +12 -12
- data/lib/rouge/lexers/c.rb +30 -30
- data/lib/rouge/lexers/ceylon.rb +1 -29
- data/lib/rouge/lexers/cfscript.rb +26 -26
- data/lib/rouge/lexers/clojure.rb +14 -14
- data/lib/rouge/lexers/cmake.rb +14 -14
- data/lib/rouge/lexers/coffeescript.rb +30 -30
- data/lib/rouge/lexers/common_lisp.rb +36 -36
- data/lib/rouge/lexers/conf.rb +6 -6
- data/lib/rouge/lexers/coq.rb +18 -18
- data/lib/rouge/lexers/cpp.rb +8 -8
- data/lib/rouge/lexers/crystal.rb +70 -70
- data/lib/rouge/lexers/csharp.rb +28 -28
- data/lib/rouge/lexers/css.rb +23 -23
- data/lib/rouge/lexers/d.rb +59 -59
- data/lib/rouge/lexers/dart.rb +33 -33
- data/lib/rouge/lexers/digdag.rb +1 -1
- data/lib/rouge/lexers/docker.rb +10 -10
- data/lib/rouge/lexers/dot.rb +16 -16
- data/lib/rouge/lexers/eiffel.rb +20 -20
- data/lib/rouge/lexers/elixir.rb +29 -28
- data/lib/rouge/lexers/elm.rb +29 -29
- data/lib/rouge/lexers/erb.rb +4 -4
- data/lib/rouge/lexers/factor.rb +40 -40
- data/lib/rouge/lexers/fortran.rb +32 -32
- data/lib/rouge/lexers/fsharp.rb +26 -26
- data/lib/rouge/lexers/gherkin.rb +13 -13
- data/lib/rouge/lexers/glsl.rb +0 -4
- data/lib/rouge/lexers/go.rb +1 -1
- data/lib/rouge/lexers/graphql.rb +62 -62
- data/lib/rouge/lexers/groovy.rb +23 -25
- data/lib/rouge/lexers/hack.rb +1 -1
- data/lib/rouge/lexers/haml.rb +25 -29
- data/lib/rouge/lexers/handlebars.rb +18 -18
- data/lib/rouge/lexers/haskell.rb +66 -65
- data/lib/rouge/lexers/hcl.rb +25 -25
- data/lib/rouge/lexers/html.rb +31 -31
- data/lib/rouge/lexers/http.rb +4 -4
- data/lib/rouge/lexers/hylang.rb +14 -14
- data/lib/rouge/lexers/idlang.rb +32 -32
- data/lib/rouge/lexers/igorpro.rb +30 -30
- data/lib/rouge/lexers/ini.rb +12 -12
- data/lib/rouge/lexers/io.rb +7 -7
- data/lib/rouge/lexers/irb.rb +5 -5
- data/lib/rouge/lexers/java.rb +24 -24
- data/lib/rouge/lexers/javascript.rb +51 -51
- data/lib/rouge/lexers/jinja.rb +22 -22
- data/lib/rouge/lexers/json.rb +11 -10
- data/lib/rouge/lexers/json_doc.rb +2 -2
- data/lib/rouge/lexers/jsonnet.rb +18 -18
- data/lib/rouge/lexers/jsp.rb +28 -28
- data/lib/rouge/lexers/jsx.rb +16 -16
- data/lib/rouge/lexers/julia.rb +44 -44
- data/lib/rouge/lexers/kotlin.rb +3 -3
- data/lib/rouge/lexers/lasso.rb +50 -50
- data/lib/rouge/lexers/liquid.rb +53 -53
- data/lib/rouge/lexers/literate_coffeescript.rb +2 -2
- data/lib/rouge/lexers/literate_haskell.rb +5 -5
- data/lib/rouge/lexers/llvm.rb +23 -16
- data/lib/rouge/lexers/lua.rb +3 -3
- data/lib/rouge/lexers/m68k.rb +18 -19
- data/lib/rouge/lexers/magik.rb +126 -0
- data/lib/rouge/lexers/make.rb +22 -28
- data/lib/rouge/lexers/markdown.rb +37 -37
- data/lib/rouge/lexers/mathematica.rb +11 -11
- data/lib/rouge/lexers/matlab.rb +20 -20
- data/lib/rouge/lexers/moonscript.rb +3 -3
- data/lib/rouge/lexers/mosel.rb +17 -17
- data/lib/rouge/lexers/mxml.rb +18 -18
- data/lib/rouge/lexers/nasm.rb +24 -25
- data/lib/rouge/lexers/nginx.rb +14 -14
- data/lib/rouge/lexers/nim.rb +1 -1
- data/lib/rouge/lexers/nix.rb +42 -42
- data/lib/rouge/lexers/objective_c.rb +38 -38
- data/lib/rouge/lexers/ocaml.rb +29 -29
- data/lib/rouge/lexers/pascal.rb +4 -4
- data/lib/rouge/lexers/perl.rb +68 -68
- data/lib/rouge/lexers/php.rb +38 -38
- data/lib/rouge/lexers/plist.rb +14 -14
- data/lib/rouge/lexers/pony.rb +19 -19
- data/lib/rouge/lexers/powershell.rb +25 -25
- data/lib/rouge/lexers/praat.rb +75 -75
- data/lib/rouge/lexers/prolog.rb +26 -20
- data/lib/rouge/lexers/prometheus.rb +30 -30
- data/lib/rouge/lexers/properties.rb +12 -12
- data/lib/rouge/lexers/protobuf.rb +22 -22
- data/lib/rouge/lexers/puppet.rb +31 -31
- data/lib/rouge/lexers/python.rb +52 -52
- data/lib/rouge/lexers/q.rb +12 -12
- data/lib/rouge/lexers/qml.rb +12 -12
- data/lib/rouge/lexers/r.rb +12 -12
- data/lib/rouge/lexers/racket.rb +22 -22
- data/lib/rouge/lexers/ruby.rb +71 -69
- data/lib/rouge/lexers/rust.rb +30 -30
- data/lib/rouge/lexers/sass.rb +8 -8
- data/lib/rouge/lexers/sass/common.rb +40 -40
- data/lib/rouge/lexers/scala.rb +43 -43
- data/lib/rouge/lexers/scheme.rb +18 -18
- data/lib/rouge/lexers/scss.rb +3 -3
- data/lib/rouge/lexers/sed.rb +29 -29
- data/lib/rouge/lexers/shell.rb +61 -52
- data/lib/rouge/lexers/sieve.rb +8 -8
- data/lib/rouge/lexers/slim.rb +24 -24
- data/lib/rouge/lexers/smalltalk.rb +33 -33
- data/lib/rouge/lexers/smarty.rb +12 -12
- data/lib/rouge/lexers/sml.rb +67 -67
- data/lib/rouge/lexers/sqf.rb +1 -1
- data/lib/rouge/lexers/sql.rb +21 -21
- data/lib/rouge/lexers/supercollider.rb +19 -19
- data/lib/rouge/lexers/swift.rb +42 -39
- data/lib/rouge/lexers/tap.rb +20 -20
- data/lib/rouge/lexers/tcl.rb +27 -27
- data/lib/rouge/lexers/terraform.rb +13 -13
- data/lib/rouge/lexers/tex.rb +19 -19
- data/lib/rouge/lexers/toml.rb +18 -18
- data/lib/rouge/lexers/tulip.rb +36 -36
- data/lib/rouge/lexers/turtle.rb +35 -38
- data/lib/rouge/lexers/vala.rb +17 -17
- data/lib/rouge/lexers/vb.rb +27 -27
- data/lib/rouge/lexers/verilog.rb +25 -27
- data/lib/rouge/lexers/vhdl.rb +10 -10
- data/lib/rouge/lexers/viml.rb +14 -14
- data/lib/rouge/lexers/vue.rb +9 -9
- data/lib/rouge/lexers/wollok.rb +25 -25
- data/lib/rouge/lexers/xml.rb +17 -21
- data/lib/rouge/lexers/xojo.rb +15 -15
- data/lib/rouge/lexers/yaml.rb +61 -61
- data/lib/rouge/plugins/redcarpet.rb +1 -1
- data/lib/rouge/tex_theme_renderer.rb +128 -0
- data/lib/rouge/theme.rb +4 -0
- data/lib/rouge/themes/magritte.rb +78 -0
- data/lib/rouge/version.rb +1 -1
- metadata +11 -2
@@ -630,49 +630,49 @@ module Rouge
|
|
630
630
|
|
631
631
|
# Override from Shell
|
632
632
|
state :interp do
|
633
|
-
rule /`$/, Str::Escape # line continuation
|
634
|
-
rule /`./, Str::Escape
|
635
|
-
rule /\$\(\(/, Keyword, :math
|
636
|
-
rule /\$\(/, Keyword, :paren
|
637
|
-
rule /\${#?/, Keyword, :curly
|
638
|
-
rule /\$#?(\w+|.)/, Name::Variable
|
633
|
+
rule %r/`$/, Str::Escape # line continuation
|
634
|
+
rule %r/`./, Str::Escape
|
635
|
+
rule %r/\$\(\(/, Keyword, :math
|
636
|
+
rule %r/\$\(/, Keyword, :paren
|
637
|
+
rule %r/\${#?/, Keyword, :curly
|
638
|
+
rule %r/\$#?(\w+|.)/, Name::Variable
|
639
639
|
end
|
640
640
|
|
641
641
|
# Override from Shell
|
642
642
|
state :double_quotes do
|
643
643
|
# NB: "abc$" is literally the string abc$.
|
644
644
|
# Here we prevent :interp from interpreting $" as a variable.
|
645
|
-
rule /(?:\$#?)?"/, Str::Double, :pop!
|
645
|
+
rule %r/(?:\$#?)?"/, Str::Double, :pop!
|
646
646
|
mixin :interp
|
647
|
-
rule /[^"`$]+/, Str::Double
|
647
|
+
rule %r/[^"`$]+/, Str::Double
|
648
648
|
end
|
649
649
|
|
650
650
|
# Override from Shell
|
651
651
|
state :data do
|
652
|
-
rule /\s+/, Text
|
653
|
-
rule /\$?"/, Str::Double, :double_quotes
|
654
|
-
rule /\$'/, Str::Single, :ansi_string
|
652
|
+
rule %r/\s+/, Text
|
653
|
+
rule %r/\$?"/, Str::Double, :double_quotes
|
654
|
+
rule %r/\$'/, Str::Single, :ansi_string
|
655
655
|
|
656
|
-
rule /'/, Str::Single, :single_quotes
|
656
|
+
rule %r/'/, Str::Single, :single_quotes
|
657
657
|
|
658
|
-
rule /\*/, Keyword
|
658
|
+
rule %r/\*/, Keyword
|
659
659
|
|
660
|
-
rule /;/, Text
|
661
|
-
rule /[^=\*\s{}()$"'`<]+/, Text
|
662
|
-
rule /\d+(?= |\Z)/, Num
|
663
|
-
rule /</, Text
|
660
|
+
rule %r/;/, Text
|
661
|
+
rule %r/[^=\*\s{}()$"'`<]+/, Text
|
662
|
+
rule %r/\d+(?= |\Z)/, Num
|
663
|
+
rule %r/</, Text
|
664
664
|
mixin :interp
|
665
665
|
end
|
666
666
|
|
667
667
|
prepend :basic do
|
668
|
-
rule %r(<#[\s
|
669
|
-
rule /#.*$/, Comment::Single
|
670
|
-
rule /\b(#{OPERATORS})\s*\b/i, Operator
|
671
|
-
rule /\b(#{ATTRIBUTES})\s*\b/i, Name::Attribute
|
672
|
-
rule /\b(#{KEYWORDS})\s*\b/i, Keyword
|
673
|
-
rule /\b(#{KEYWORDS_TYPE})\s*\b/i, Keyword::Type
|
674
|
-
rule /\bcase\b/, Keyword, :case
|
675
|
-
rule /\b(#{BUILTINS})\s*\b(?!\.)/i, Name::Builtin
|
668
|
+
rule %r(<#[\s\S]*?#>)m, Comment::Multiline
|
669
|
+
rule %r/#.*$/, Comment::Single
|
670
|
+
rule %r/\b(#{OPERATORS})\s*\b/i, Operator
|
671
|
+
rule %r/\b(#{ATTRIBUTES})\s*\b/i, Name::Attribute
|
672
|
+
rule %r/\b(#{KEYWORDS})\s*\b/i, Keyword
|
673
|
+
rule %r/\b(#{KEYWORDS_TYPE})\s*\b/i, Keyword::Type
|
674
|
+
rule %r/\bcase\b/, Keyword, :case
|
675
|
+
rule %r/\b(#{BUILTINS})\s*\b(?!\.)/i, Name::Builtin
|
676
676
|
end
|
677
677
|
end
|
678
678
|
end
|
data/lib/rouge/lexers/praat.rb
CHANGED
@@ -101,84 +101,84 @@ module Rouge
|
|
101
101
|
)
|
102
102
|
|
103
103
|
state :root do
|
104
|
-
rule /(\s+)(#.*?$)/ do
|
104
|
+
rule %r/(\s+)(#.*?$)/ do
|
105
105
|
groups Text, Comment::Single
|
106
106
|
end
|
107
107
|
|
108
|
-
rule /^#.*?$/, Comment::Single
|
109
|
-
rule /;[^\n]*/, Comment::Single
|
110
|
-
rule /\s+/, Text
|
108
|
+
rule %r/^#.*?$/, Comment::Single
|
109
|
+
rule %r/;[^\n]*/, Comment::Single
|
110
|
+
rule %r/\s+/, Text
|
111
111
|
|
112
|
-
rule /(\bprocedure)(\s+)/ do
|
112
|
+
rule %r/(\bprocedure)(\s+)/ do
|
113
113
|
groups Keyword, Text
|
114
114
|
push :procedure_definition
|
115
115
|
end
|
116
116
|
|
117
|
-
rule /(\bcall)(\s+)/ do
|
117
|
+
rule %r/(\bcall)(\s+)/ do
|
118
118
|
groups Keyword, Text
|
119
119
|
push :procedure_call
|
120
120
|
end
|
121
121
|
|
122
|
-
rule /@/, Name::Function, :procedure_call
|
122
|
+
rule %r/@/, Name::Function, :procedure_call
|
123
123
|
|
124
124
|
mixin :function_call
|
125
125
|
|
126
|
-
rule /\b(?:select all)\b/, Keyword
|
127
|
-
rule /\b(?:#{keywords.join('|')})\b/, Keyword
|
126
|
+
rule %r/\b(?:select all)\b/, Keyword
|
127
|
+
rule %r/\b(?:#{keywords.join('|')})\b/, Keyword
|
128
128
|
|
129
|
-
rule /(\bform\b)(\s+)([^\n]+)/ do
|
129
|
+
rule %r/(\bform\b)(\s+)([^\n]+)/ do
|
130
130
|
groups Keyword, Text, Literal::String
|
131
131
|
push :old_form
|
132
132
|
end
|
133
133
|
|
134
|
-
rule /(print(?:line|tab)?|echo|exit|asserterror|pause|send(?:praat|socket)|include|execute|system(?:_nocheck)?)(\s+)/ do
|
134
|
+
rule %r/(print(?:line|tab)?|echo|exit|asserterror|pause|send(?:praat|socket)|include|execute|system(?:_nocheck)?)(\s+)/ do
|
135
135
|
groups Keyword, Text
|
136
136
|
push :string_unquoted
|
137
137
|
end
|
138
138
|
|
139
|
-
rule /(goto|label)(\s+)(\w+)/ do
|
139
|
+
rule %r/(goto|label)(\s+)(\w+)/ do
|
140
140
|
groups Keyword, Text, Name::Label
|
141
141
|
end
|
142
142
|
|
143
143
|
mixin :variable_name
|
144
144
|
mixin :number
|
145
145
|
|
146
|
-
rule /"/, Literal::String, :string
|
146
|
+
rule %r/"/, Literal::String, :string
|
147
147
|
|
148
|
-
rule /\b(?:#{objects.join('|')})(?=\s+\S+\n)/, Name::Class, :string_unquoted
|
148
|
+
rule %r/\b(?:#{objects.join('|')})(?=\s+\S+\n)/, Name::Class, :string_unquoted
|
149
149
|
|
150
|
-
rule /\b(?=[A-Z])/, Text, :command
|
151
|
-
rule /(\.{3}|[)(,\$])/, Punctuation
|
150
|
+
rule %r/\b(?=[A-Z])/, Text, :command
|
151
|
+
rule %r/(\.{3}|[)(,\$])/, Punctuation
|
152
152
|
end
|
153
153
|
|
154
154
|
state :command do
|
155
|
-
rule /( ?([^\s:\.'])+ ?)/, Keyword
|
155
|
+
rule %r/( ?([^\s:\.'])+ ?)/, Keyword
|
156
156
|
mixin :string_interpolated
|
157
157
|
|
158
|
-
rule /\.{3}/ do
|
158
|
+
rule %r/\.{3}/ do
|
159
159
|
token Keyword
|
160
160
|
pop!
|
161
161
|
push :old_arguments
|
162
162
|
end
|
163
163
|
|
164
|
-
rule /:/ do
|
164
|
+
rule %r/:/ do
|
165
165
|
token Keyword
|
166
166
|
pop!
|
167
167
|
push :comma_list
|
168
168
|
end
|
169
169
|
|
170
|
-
rule /[\s]/, Text, :pop!
|
170
|
+
rule %r/[\s]/, Text, :pop!
|
171
171
|
end
|
172
172
|
|
173
173
|
state :procedure_call do
|
174
174
|
mixin :string_interpolated
|
175
175
|
|
176
|
-
rule /(:|\s*\()/, Punctuation, :pop!
|
176
|
+
rule %r/(:|\s*\()/, Punctuation, :pop!
|
177
177
|
|
178
|
-
rule /'/, Name::Function
|
179
|
-
rule /[^:\('\s]+/, Name::Function
|
178
|
+
rule %r/'/, Name::Function
|
179
|
+
rule %r/[^:\('\s]+/, Name::Function
|
180
180
|
|
181
|
-
rule /(?=\s+)/ do
|
181
|
+
rule %r/(?=\s+)/ do
|
182
182
|
token Text
|
183
183
|
pop!
|
184
184
|
push :old_arguments
|
@@ -186,23 +186,23 @@ module Rouge
|
|
186
186
|
end
|
187
187
|
|
188
188
|
state :procedure_definition do
|
189
|
-
rule /(:|\s*\()/, Punctuation, :pop!
|
189
|
+
rule %r/(:|\s*\()/, Punctuation, :pop!
|
190
190
|
|
191
|
-
rule /[^:\(\s]+/, Name::Function
|
191
|
+
rule %r/[^:\(\s]+/, Name::Function
|
192
192
|
|
193
|
-
rule /(\s+)/, Text, :pop!
|
193
|
+
rule %r/(\s+)/, Text, :pop!
|
194
194
|
end
|
195
195
|
|
196
196
|
state :function_call do
|
197
|
-
rule /\b(#{functions_string.join('|')})\$(?=\s*[:(])/, Name::Function, :function
|
198
|
-
rule /\b(#{functions_array.join('|')})#(?=\s*[:(])/, Name::Function, :function
|
199
|
-
rule /\b(#{functions_numeric.join('|')})(?=\s*[:(])/, Name::Function, :function
|
197
|
+
rule %r/\b(#{functions_string.join('|')})\$(?=\s*[:(])/, Name::Function, :function
|
198
|
+
rule %r/\b(#{functions_array.join('|')})#(?=\s*[:(])/, Name::Function, :function
|
199
|
+
rule %r/\b(#{functions_numeric.join('|')})(?=\s*[:(])/, Name::Function, :function
|
200
200
|
end
|
201
201
|
|
202
202
|
state :function do
|
203
|
-
rule /\s+/, Text
|
203
|
+
rule %r/\s+/, Text
|
204
204
|
|
205
|
-
rule /(?::|\s*\()/ do
|
205
|
+
rule %r/(?::|\s*\()/ do
|
206
206
|
token Text
|
207
207
|
pop!
|
208
208
|
push :comma_list
|
@@ -210,140 +210,140 @@ module Rouge
|
|
210
210
|
end
|
211
211
|
|
212
212
|
state :comma_list do
|
213
|
-
rule /(\s*\n\s*)(\.{3})/ do
|
213
|
+
rule %r/(\s*\n\s*)(\.{3})/ do
|
214
214
|
groups Text, Punctuation
|
215
215
|
end
|
216
216
|
|
217
|
-
rule /\s*[\])\n]/, Text, :pop!
|
217
|
+
rule %r/\s*[\])\n]/, Text, :pop!
|
218
218
|
|
219
|
-
rule /\s+/, Text
|
220
|
-
rule /"/, Literal::String, :string
|
221
|
-
rule /\b(if|then|else|fi|endif)\b/, Keyword
|
219
|
+
rule %r/\s+/, Text
|
220
|
+
rule %r/"/, Literal::String, :string
|
221
|
+
rule %r/\b(if|then|else|fi|endif)\b/, Keyword
|
222
222
|
|
223
223
|
mixin :function_call
|
224
224
|
mixin :variable_name
|
225
225
|
mixin :operator
|
226
226
|
mixin :number
|
227
227
|
|
228
|
-
rule /[()]/, Text
|
229
|
-
rule /,/, Punctuation
|
228
|
+
rule %r/[()]/, Text
|
229
|
+
rule %r/,/, Punctuation
|
230
230
|
end
|
231
231
|
|
232
232
|
state :old_arguments do
|
233
|
-
rule /\n/, Text, :pop!
|
233
|
+
rule %r/\n/, Text, :pop!
|
234
234
|
|
235
235
|
mixin :variable_name
|
236
236
|
mixin :operator
|
237
237
|
mixin :number
|
238
238
|
|
239
|
-
rule /"/, Literal::String, :string
|
240
|
-
rule /[^\n]/, Text
|
239
|
+
rule %r/"/, Literal::String, :string
|
240
|
+
rule %r/[^\n]/, Text
|
241
241
|
end
|
242
242
|
|
243
243
|
state :number do
|
244
|
-
rule /\n/, Text, :pop!
|
245
|
-
rule /\b\d+(\.\d*)?([eE][-+]?\d+)?%?/, Literal::Number
|
244
|
+
rule %r/\n/, Text, :pop!
|
245
|
+
rule %r/\b\d+(\.\d*)?([eE][-+]?\d+)?%?/, Literal::Number
|
246
246
|
end
|
247
247
|
|
248
248
|
state :variable_name do
|
249
249
|
mixin :operator
|
250
250
|
mixin :number
|
251
251
|
|
252
|
-
rule /\b(?:#{variables_string.join('|')})\$/, Name::Builtin
|
253
|
-
rule /\b(?:#{variables_numeric.join('|')})(?!\$)\b/, Name::Builtin
|
252
|
+
rule %r/\b(?:#{variables_string.join('|')})\$/, Name::Builtin
|
253
|
+
rule %r/\b(?:#{variables_numeric.join('|')})(?!\$)\b/, Name::Builtin
|
254
254
|
|
255
|
-
rule /\b(Object|#{objects.join('|')})_/ do
|
255
|
+
rule %r/\b(Object|#{objects.join('|')})_/ do
|
256
256
|
token Name::Builtin
|
257
257
|
push :object_reference
|
258
258
|
end
|
259
259
|
|
260
|
-
rule /\.?[a-z][a-zA-Z0-9_.]*(\$|#)?/, Text
|
261
|
-
rule /[\[\]]/, Text, :comma_list
|
260
|
+
rule %r/\.?[a-z][a-zA-Z0-9_.]*(\$|#)?/, Text
|
261
|
+
rule %r/[\[\]]/, Text, :comma_list
|
262
262
|
mixin :string_interpolated
|
263
263
|
end
|
264
264
|
|
265
265
|
state :object_reference do
|
266
266
|
mixin :string_interpolated
|
267
|
-
rule /([a-z][a-zA-Z0-9_]*|\d+)/, Name::Builtin
|
267
|
+
rule %r/([a-z][a-zA-Z0-9_]*|\d+)/, Name::Builtin
|
268
268
|
|
269
|
-
rule /\.(#{object_attributes.join('|')})\b/, Name::Builtin, :pop!
|
269
|
+
rule %r/\.(#{object_attributes.join('|')})\b/, Name::Builtin, :pop!
|
270
270
|
|
271
|
-
rule /\$/, Name::Builtin
|
272
|
-
rule /\[/, Text, :pop!
|
271
|
+
rule %r/\$/, Name::Builtin
|
272
|
+
rule %r/\[/, Text, :pop!
|
273
273
|
end
|
274
274
|
|
275
275
|
state :operator do
|
276
276
|
# This rule incorrectly matches === or +++++, which are not operators
|
277
|
-
rule /([+\/*<>=!-]=?|[&*|][&*|]?|\^|<>)/, Operator
|
278
|
-
rule /(?<![\w.])(and|or|not|div|mod)(?![\w.])/, Operator::Word
|
277
|
+
rule %r/([+\/*<>=!-]=?|[&*|][&*|]?|\^|<>)/, Operator
|
278
|
+
rule %r/(?<![\w.])(and|or|not|div|mod)(?![\w.])/, Operator::Word
|
279
279
|
end
|
280
280
|
|
281
281
|
state :string_interpolated do
|
282
|
-
rule /'[\._a-z][^\[\]'":]*(\[([\d,]+|"[\w
|
282
|
+
rule %r/'[\._a-z][^\[\]'":]*(\[([\d,]+|"[\w,]+")\])?(:[0-9]+)?'/, Literal::String::Interpol
|
283
283
|
end
|
284
284
|
|
285
285
|
state :string_unquoted do
|
286
|
-
rule /\n\s*\.{3}/, Punctuation
|
287
|
-
rule /\n/, Text, :pop!
|
288
|
-
rule /\s/, Text
|
286
|
+
rule %r/\n\s*\.{3}/, Punctuation
|
287
|
+
rule %r/\n/, Text, :pop!
|
288
|
+
rule %r/\s/, Text
|
289
289
|
|
290
290
|
mixin :string_interpolated
|
291
291
|
|
292
|
-
rule /'/, Literal::String
|
293
|
-
rule /[^'\n]+/, Literal::String
|
292
|
+
rule %r/'/, Literal::String
|
293
|
+
rule %r/[^'\n]+/, Literal::String
|
294
294
|
end
|
295
295
|
|
296
296
|
state :string do
|
297
|
-
rule /\n\s*\.{3}/, Punctuation
|
298
|
-
rule /"/, Literal::String, :pop!
|
297
|
+
rule %r/\n\s*\.{3}/, Punctuation
|
298
|
+
rule %r/"/, Literal::String, :pop!
|
299
299
|
|
300
300
|
mixin :string_interpolated
|
301
301
|
|
302
|
-
rule /'/, Literal::String
|
303
|
-
rule /[^'"\n]+/, Literal::String
|
302
|
+
rule %r/'/, Literal::String
|
303
|
+
rule %r/[^'"\n]+/, Literal::String
|
304
304
|
end
|
305
305
|
|
306
306
|
state :old_form do
|
307
|
-
rule /(\s+)(#.*?$)/ do
|
307
|
+
rule %r/(\s+)(#.*?$)/ do
|
308
308
|
groups Text, Comment::Single
|
309
309
|
end
|
310
310
|
|
311
|
-
rule /\s+/, Text
|
311
|
+
rule %r/\s+/, Text
|
312
312
|
|
313
|
-
rule /(optionmenu|choice)([ \t]+\S+:[ \t]+)/ do
|
313
|
+
rule %r/(optionmenu|choice)([ \t]+\S+:[ \t]+)/ do
|
314
314
|
groups Keyword, Text
|
315
315
|
push :number
|
316
316
|
end
|
317
317
|
|
318
|
-
rule /(option|button)([ \t]+)/ do
|
318
|
+
rule %r/(option|button)([ \t]+)/ do
|
319
319
|
groups Keyword, Text
|
320
320
|
push :string_unquoted
|
321
321
|
end
|
322
322
|
|
323
|
-
rule /(sentence|text)([ \t]+\S+)/ do
|
323
|
+
rule %r/(sentence|text)([ \t]+\S+)/ do
|
324
324
|
groups Keyword, Text
|
325
325
|
push :string_unquoted
|
326
326
|
end
|
327
327
|
|
328
|
-
rule /(word)([ \t]+\S+[ \t]*)(\S+)?([ \t]+.*)?/ do
|
328
|
+
rule %r/(word)([ \t]+\S+[ \t]*)(\S+)?([ \t]+.*)?/ do
|
329
329
|
groups Keyword, Text, Literal::String, Text
|
330
330
|
end
|
331
331
|
|
332
|
-
rule /(boolean)(\s+\S+\s*)(0|1|"?(?:yes|no)"?)/ do
|
332
|
+
rule %r/(boolean)(\s+\S+\s*)(0|1|"?(?:yes|no)"?)/ do
|
333
333
|
groups Keyword, Text, Name::Variable
|
334
334
|
end
|
335
335
|
|
336
|
-
rule /(real|natural|positive|integer)([ \t]+\S+[ \t]*)([+-]?)/ do
|
336
|
+
rule %r/(real|natural|positive|integer)([ \t]+\S+[ \t]*)([+-]?)/ do
|
337
337
|
groups Keyword, Text, Operator
|
338
338
|
push :number
|
339
339
|
end
|
340
340
|
|
341
|
-
rule /(comment)(\s+)/ do
|
341
|
+
rule %r/(comment)(\s+)/ do
|
342
342
|
groups Keyword, Text
|
343
343
|
push :string_unquoted
|
344
344
|
end
|
345
345
|
|
346
|
-
rule /\bendform\b/, Keyword, :pop!
|
346
|
+
rule %r/\bendform\b/, Keyword, :pop!
|
347
347
|
end
|
348
348
|
|
349
349
|
end
|
data/lib/rouge/lexers/prolog.rb
CHANGED
@@ -11,37 +11,43 @@ module Rouge
|
|
11
11
|
filenames '*.pro', '*.P', '*.prolog', '*.pl'
|
12
12
|
mimetypes 'text/x-prolog'
|
13
13
|
|
14
|
+
start { push :bol }
|
15
|
+
|
16
|
+
state :bol do
|
17
|
+
rule %r/#.*/, Comment::Single
|
18
|
+
rule(//) { pop! }
|
19
|
+
end
|
20
|
+
|
14
21
|
state :basic do
|
15
|
-
rule /\s+/, Text
|
16
|
-
rule
|
17
|
-
rule
|
18
|
-
rule /\/\*/, Comment::Multiline, :nested_comment
|
22
|
+
rule %r/\s+/, Text
|
23
|
+
rule %r/%.*/, Comment::Single
|
24
|
+
rule %r/\/\*/, Comment::Multiline, :nested_comment
|
19
25
|
|
20
|
-
rule /[\[\](){}|.,;!]/, Punctuation
|
21
|
-
rule /:-|-->/, Punctuation
|
26
|
+
rule %r/[\[\](){}|.,;!]/, Punctuation
|
27
|
+
rule %r/:-|-->/, Punctuation
|
22
28
|
|
23
|
-
rule /"[^"]*"/, Str::Double
|
29
|
+
rule %r/"[^"]*"/, Str::Double
|
24
30
|
|
25
|
-
rule /\d+\.\d+/, Num::Float
|
26
|
-
rule /\d+/, Num
|
31
|
+
rule %r/\d+\.\d+/, Num::Float
|
32
|
+
rule %r/\d+/, Num
|
27
33
|
end
|
28
34
|
|
29
35
|
state :atoms do
|
30
|
-
rule /[[:lower:]]([
|
31
|
-
rule /'[^']*'/, Str::Symbol
|
36
|
+
rule %r/[[:lower:]]([[:word:]])*/, Str::Symbol
|
37
|
+
rule %r/'[^']*'/, Str::Symbol
|
32
38
|
end
|
33
39
|
|
34
40
|
state :operators do
|
35
|
-
rule /(<|>|=<|>=|==|=:=|=|\/|\/\/|\*|\+|-)(?=\s|[a-zA-Z0-9\[])/,
|
41
|
+
rule %r/(<|>|=<|>=|==|=:=|=|\/|\/\/|\*|\+|-)(?=\s|[a-zA-Z0-9\[])/,
|
36
42
|
Operator
|
37
|
-
rule /is/, Operator
|
38
|
-
rule /(mod|div|not)/, Operator
|
39
|
-
rule /[#&*+-.\/:<=>?@^~]+/, Operator
|
43
|
+
rule %r/is/, Operator
|
44
|
+
rule %r/(mod|div|not)/, Operator
|
45
|
+
rule %r/[#&*+-.\/:<=>?@^~]+/, Operator
|
40
46
|
end
|
41
47
|
|
42
48
|
state :variables do
|
43
|
-
rule /[A-Z]+\w*/, Name::Variable
|
44
|
-
rule /_[[:word:]]*/, Name::Variable
|
49
|
+
rule %r/[A-Z]+\w*/, Name::Variable
|
50
|
+
rule %r/_[[:word:]]*/, Name::Variable
|
45
51
|
end
|
46
52
|
|
47
53
|
state :root do
|
@@ -52,9 +58,9 @@ module Rouge
|
|
52
58
|
end
|
53
59
|
|
54
60
|
state :nested_comment do
|
55
|
-
rule
|
56
|
-
rule /\s*\*[^*\/]+/, Comment::Multiline
|
57
|
-
rule
|
61
|
+
rule %r(/\*), Comment::Multiline, :push
|
62
|
+
rule %r/\s*\*[^*\/]+/, Comment::Multiline
|
63
|
+
rule %r(\*/), Comment::Multiline, :pop!
|
58
64
|
end
|
59
65
|
end
|
60
66
|
end
|