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
data/lib/rouge/lexers/slim.rb
CHANGED
@@ -45,22 +45,22 @@ module Rouge
|
|
45
45
|
start { ruby.reset!; html.reset! }
|
46
46
|
|
47
47
|
state :root do
|
48
|
-
rule /\s*\n/, Text
|
48
|
+
rule %r/\s*\n/, Text
|
49
49
|
rule(/\s*/) { |m| token Text; indentation(m[0]) }
|
50
50
|
end
|
51
51
|
|
52
52
|
state :content do
|
53
53
|
mixin :css
|
54
54
|
|
55
|
-
rule /\/#{dot}*/, Comment, :indented_block
|
55
|
+
rule %r/\/#{dot}*/, Comment, :indented_block
|
56
56
|
|
57
|
-
rule /(doctype)(\s+)(.*)/ do
|
57
|
+
rule %r/(doctype)(\s+)(.*)/ do
|
58
58
|
groups Name::Namespace, Text::Whitespace, Text
|
59
59
|
pop!
|
60
60
|
end
|
61
61
|
|
62
62
|
# filters, shamelessly ripped from HAML
|
63
|
-
rule /(\w*):\s*\n/ do |m|
|
63
|
+
rule %r/(\w*):\s*\n/ do |m|
|
64
64
|
token Name::Decorator
|
65
65
|
pop!
|
66
66
|
starts_block :filter_block
|
@@ -81,29 +81,29 @@ module Rouge
|
|
81
81
|
goto :plain_block
|
82
82
|
end
|
83
83
|
|
84
|
-
rule /-|==|=/, Punctuation, :ruby_line
|
84
|
+
rule %r/-|==|=/, Punctuation, :ruby_line
|
85
85
|
|
86
86
|
# Dynamic tags
|
87
|
-
rule /(\*)(#{ruby_chars}+\(.*?\))/ do |m|
|
87
|
+
rule %r/(\*)(#{ruby_chars}+\(.*?\))/ do |m|
|
88
88
|
token Punctuation, m[1]
|
89
89
|
delegate ruby, m[2]
|
90
90
|
push :tag
|
91
91
|
end
|
92
92
|
|
93
|
-
rule /(\*)(#{ruby_chars}+)/ do |m|
|
93
|
+
rule %r/(\*)(#{ruby_chars}+)/ do |m|
|
94
94
|
token Punctuation, m[1]
|
95
95
|
delegate ruby, m[2]
|
96
96
|
push :tag
|
97
97
|
end
|
98
98
|
|
99
|
-
#rule /<\w+(?=.*>)/, Keyword::Constant, :tag # Maybe do this, look ahead and stuff
|
99
|
+
#rule %r/<\w+(?=.*>)/, Keyword::Constant, :tag # Maybe do this, look ahead and stuff
|
100
100
|
rule %r((</?[\w\s\=\'\"]+?/?>)) do |m| # Dirty html
|
101
101
|
delegate html, m[1]
|
102
102
|
pop!
|
103
103
|
end
|
104
104
|
|
105
105
|
# Ordinary slim tags
|
106
|
-
rule /\w+/, Name::Tag, :tag
|
106
|
+
rule %r/\w+/, Name::Tag, :tag
|
107
107
|
|
108
108
|
end
|
109
109
|
|
@@ -113,24 +113,24 @@ module Rouge
|
|
113
113
|
mixin :interpolation
|
114
114
|
|
115
115
|
# Whitespace control
|
116
|
-
rule /[<>]/, Punctuation
|
116
|
+
rule %r/[<>]/, Punctuation
|
117
117
|
|
118
118
|
# Trim whitespace
|
119
|
-
rule /\s+?/, Text::Whitespace
|
119
|
+
rule %r/\s+?/, Text::Whitespace
|
120
120
|
|
121
121
|
# Splats, these two might be mergable?
|
122
|
-
rule /(\*)(#{ruby_chars}+)/ do |m|
|
122
|
+
rule %r/(\*)(#{ruby_chars}+)/ do |m|
|
123
123
|
token Punctuation, m[1]
|
124
124
|
delegate ruby, m[2]
|
125
125
|
end
|
126
126
|
|
127
|
-
rule /(\*)(\{#{dot}+?\})/ do |m|
|
127
|
+
rule %r/(\*)(\{#{dot}+?\})/ do |m|
|
128
128
|
token Punctuation, m[1]
|
129
129
|
delegate ruby, m[2]
|
130
130
|
end
|
131
131
|
|
132
132
|
# Attributes
|
133
|
-
rule /([\w\-]+)(\s*)(\=)/ do |m|
|
133
|
+
rule %r/([\w\-]+)(\s*)(\=)/ do |m|
|
134
134
|
token Name::Attribute, m[1]
|
135
135
|
token Text::Whitespace, m[2]
|
136
136
|
token Punctuation, m[3]
|
@@ -138,7 +138,7 @@ module Rouge
|
|
138
138
|
end
|
139
139
|
|
140
140
|
# Ruby value
|
141
|
-
rule /(\=)(#{dot}+)/ do |m|
|
141
|
+
rule %r/(\=)(#{dot}+)/ do |m|
|
142
142
|
token Punctuation, m[1]
|
143
143
|
#token Keyword::Constant, m[2]
|
144
144
|
delegate ruby, m[2]
|
@@ -147,9 +147,9 @@ module Rouge
|
|
147
147
|
# HTML Entities
|
148
148
|
rule(/&\S*?;/, Name::Entity)
|
149
149
|
|
150
|
-
rule /#{dot}+?/, Text
|
150
|
+
rule %r/#{dot}+?/, Text
|
151
151
|
|
152
|
-
rule /\s*\n/, Text::Whitespace, :pop!
|
152
|
+
rule %r/\s*\n/, Text::Whitespace, :pop!
|
153
153
|
end
|
154
154
|
|
155
155
|
state :css do
|
@@ -165,7 +165,7 @@ module Rouge
|
|
165
165
|
rule(/(#{ruby_chars}+\(.*?\))/) { |m| delegate ruby, m[1]; pop! }
|
166
166
|
rule(/(#{ruby_chars}+)/) { |m| delegate ruby, m[1]; pop! }
|
167
167
|
|
168
|
-
rule /\s+/, Text::Whitespace
|
168
|
+
rule %r/\s+/, Text::Whitespace
|
169
169
|
end
|
170
170
|
|
171
171
|
state :ruby_line do
|
@@ -173,12 +173,12 @@ module Rouge
|
|
173
173
|
mixin :indented_block
|
174
174
|
|
175
175
|
rule(/[,\\]\s*\n/) { delegate ruby }
|
176
|
-
rule /[ ]\|[ \t]*\n/, Str::Escape
|
176
|
+
rule %r/[ ]\|[ \t]*\n/, Str::Escape
|
177
177
|
rule(/.*?(?=([,\\]$| \|)?[ \t]*$)/) { delegate ruby }
|
178
178
|
end
|
179
179
|
|
180
180
|
state :filter_block do
|
181
|
-
rule /([^#\n]|#[^{\n]|(\\\\)*\\#\{)+/ do
|
181
|
+
rule %r/([^#\n]|#[^{\n]|(\\\\)*\\#\{)+/ do
|
182
182
|
if @filter_lexer
|
183
183
|
delegate @filter_lexer
|
184
184
|
else
|
@@ -200,18 +200,18 @@ module Rouge
|
|
200
200
|
# HTML Entities
|
201
201
|
rule(/&\S*?;/, Name::Entity)
|
202
202
|
|
203
|
-
#rule /([^#\n]|#[^{\n]|(\\\\)*\\#\{)+/ do
|
204
|
-
rule /#{dot}+?/, Text
|
203
|
+
#rule %r/([^#\n]|#[^{\n]|(\\\\)*\\#\{)+/ do
|
204
|
+
rule %r/#{dot}+?/, Text
|
205
205
|
|
206
206
|
mixin :indented_block
|
207
207
|
end
|
208
208
|
|
209
209
|
state :interpolation do
|
210
|
-
rule /#[{]/, Str::Interpol, :ruby_interp
|
210
|
+
rule %r/#[{]/, Str::Interpol, :ruby_interp
|
211
211
|
end
|
212
212
|
|
213
213
|
state :ruby_interp do
|
214
|
-
rule /[}]/, Str::Interpol, :pop!
|
214
|
+
rule %r/[}]/, Str::Interpol, :pop!
|
215
215
|
mixin :ruby_interp_inner
|
216
216
|
end
|
217
217
|
|
@@ -15,29 +15,29 @@ module Rouge
|
|
15
15
|
ops = %r([-+*/\\~<>=|&!?,@%])
|
16
16
|
|
17
17
|
state :root do
|
18
|
-
rule /(<)(\w+:)(.*?)(>)/ do
|
18
|
+
rule %r/(<)(\w+:)(.*?)(>)/ do
|
19
19
|
groups Punctuation, Keyword, Text, Punctuation
|
20
20
|
end
|
21
21
|
|
22
22
|
# mixin :squeak_fileout
|
23
23
|
mixin :whitespaces
|
24
24
|
mixin :method_definition
|
25
|
-
rule /([|])([\w\s]*)([|])/ do
|
25
|
+
rule %r/([|])([\w\s]*)([|])/ do
|
26
26
|
groups Punctuation, Name::Variable, Punctuation
|
27
27
|
end
|
28
28
|
mixin :objects
|
29
|
-
rule /\^|:=|_/, Operator
|
29
|
+
rule %r/\^|:=|_/, Operator
|
30
30
|
|
31
|
-
rule /[)}\]]/, Punctuation, :after_object
|
32
|
-
rule /[({\[!]/, Punctuation
|
31
|
+
rule %r/[)}\]]/, Punctuation, :after_object
|
32
|
+
rule %r/[({\[!]/, Punctuation
|
33
33
|
end
|
34
34
|
|
35
35
|
state :method_definition do
|
36
|
-
rule /([a-z]\w*:)(\s*)(\w+)/i do
|
36
|
+
rule %r/([a-z]\w*:)(\s*)(\w+)/i do
|
37
37
|
groups Name::Function, Text, Name::Variable
|
38
38
|
end
|
39
39
|
|
40
|
-
rule /^(\s*)(\b[a-z]\w*\b)(\s*)$/i do
|
40
|
+
rule %r/^(\s*)(\b[a-z]\w*\b)(\s*)$/i do
|
41
41
|
groups Text, Name::Function, Text
|
42
42
|
end
|
43
43
|
|
@@ -48,27 +48,27 @@ module Rouge
|
|
48
48
|
|
49
49
|
state :block_variables do
|
50
50
|
mixin :whitespaces
|
51
|
-
rule /(:)(\s*)(\w+)/ do
|
51
|
+
rule %r/(:)(\s*)(\w+)/ do
|
52
52
|
groups Operator, Text, Name::Variable
|
53
53
|
end
|
54
54
|
|
55
|
-
rule /[|]/, Punctuation, :pop!
|
55
|
+
rule %r/[|]/, Punctuation, :pop!
|
56
56
|
|
57
57
|
rule(//) { pop! }
|
58
58
|
end
|
59
59
|
|
60
60
|
state :literals do
|
61
|
-
rule /'(''|.)*?'/m, Str, :after_object
|
62
|
-
rule /[$]./, Str::Char, :after_object
|
63
|
-
rule /#[(]/, Str::Symbol, :parenth
|
64
|
-
rule /(\d+r)?-?\d+(\.\d+)?(e-?\d+)?/,
|
61
|
+
rule %r/'(''|.)*?'/m, Str, :after_object
|
62
|
+
rule %r/[$]./, Str::Char, :after_object
|
63
|
+
rule %r/#[(]/, Str::Symbol, :parenth
|
64
|
+
rule %r/(\d+r)?-?\d+(\.\d+)?(e-?\d+)?/,
|
65
65
|
Num, :after_object
|
66
|
-
rule /#("[^"]*"|#{ops}+|[\w:]+)/,
|
66
|
+
rule %r/#("[^"]*"|#{ops}+|[\w:]+)/,
|
67
67
|
Str::Symbol, :after_object
|
68
68
|
end
|
69
69
|
|
70
70
|
state :parenth do
|
71
|
-
rule /[)]/ do
|
71
|
+
rule %r/[)]/ do
|
72
72
|
token Str::Symbol
|
73
73
|
goto :after_object
|
74
74
|
end
|
@@ -77,39 +77,39 @@ module Rouge
|
|
77
77
|
end
|
78
78
|
|
79
79
|
state :inner_parenth do
|
80
|
-
rule /#[(]/, Str::Symbol, :inner_parenth
|
81
|
-
rule /[)]/, Str::Symbol, :pop!
|
80
|
+
rule %r/#[(]/, Str::Symbol, :inner_parenth
|
81
|
+
rule %r/[)]/, Str::Symbol, :pop!
|
82
82
|
mixin :whitespaces
|
83
83
|
mixin :literals
|
84
|
-
rule /(#{ops}|[\w:])+/, Str::Symbol
|
84
|
+
rule %r/(#{ops}|[\w:])+/, Str::Symbol
|
85
85
|
end
|
86
86
|
|
87
87
|
state :whitespaces do
|
88
|
-
rule /! !$/, Keyword # squeak chunk delimiter
|
89
|
-
rule /\s+/m, Text
|
90
|
-
rule /".*?"/m, Comment
|
88
|
+
rule %r/! !$/, Keyword # squeak chunk delimiter
|
89
|
+
rule %r/\s+/m, Text
|
90
|
+
rule %r/".*?"/m, Comment
|
91
91
|
end
|
92
92
|
|
93
93
|
state :objects do
|
94
|
-
rule /\[/, Punctuation, :block_variables
|
95
|
-
rule /(self|super|true|false|nil|thisContext)\b/,
|
94
|
+
rule %r/\[/, Punctuation, :block_variables
|
95
|
+
rule %r/(self|super|true|false|nil|thisContext)\b/,
|
96
96
|
Name::Builtin::Pseudo, :after_object
|
97
|
-
rule /[A-Z]\w*(?!:)\b/, Name::Class, :after_object
|
98
|
-
rule /[a-z]\w*(?!:)\b/, Name::Variable, :after_object
|
97
|
+
rule %r/[A-Z]\w*(?!:)\b/, Name::Class, :after_object
|
98
|
+
rule %r/[a-z]\w*(?!:)\b/, Name::Variable, :after_object
|
99
99
|
mixin :literals
|
100
100
|
end
|
101
101
|
|
102
102
|
state :after_object do
|
103
103
|
mixin :whitespaces
|
104
|
-
rule /(ifTrue|ifFalse|whileTrue|whileFalse|timesRepeat):/,
|
104
|
+
rule %r/(ifTrue|ifFalse|whileTrue|whileFalse|timesRepeat):/,
|
105
105
|
Name::Builtin, :pop!
|
106
|
-
rule /new(?!:)\b/, Name::Builtin
|
107
|
-
rule /:=|_/, Operator, :pop!
|
108
|
-
rule /[a-z]+\w*:/i, Name::Function, :pop!
|
109
|
-
rule /[a-z]+\w*/i, Name::Function
|
110
|
-
rule /#{ops}+/, Name::Function, :pop!
|
111
|
-
rule /[.]/, Punctuation, :pop!
|
112
|
-
rule /;/, Punctuation
|
106
|
+
rule %r/new(?!:)\b/, Name::Builtin
|
107
|
+
rule %r/:=|_/, Operator, :pop!
|
108
|
+
rule %r/[a-z]+\w*:/i, Name::Function, :pop!
|
109
|
+
rule %r/[a-z]+\w*/i, Name::Function
|
110
|
+
rule %r/#{ops}+/, Name::Function, :pop!
|
111
|
+
rule %r/[.]/, Punctuation, :pop!
|
112
|
+
rule %r/;/, Punctuation
|
113
113
|
rule(//) { pop! }
|
114
114
|
end
|
115
115
|
end
|
data/lib/rouge/lexers/smarty.rb
CHANGED
@@ -33,9 +33,9 @@ module Rouge
|
|
33
33
|
rule(/\{\s+/) { delegate parent }
|
34
34
|
|
35
35
|
# block comments
|
36
|
-
rule /\{\*.*?\*\}/m, Comment
|
36
|
+
rule %r/\{\*.*?\*\}/m, Comment
|
37
37
|
|
38
|
-
rule /\{\/?(?![\s*])/ do
|
38
|
+
rule %r/\{\/?(?![\s*])/ do
|
39
39
|
token Keyword
|
40
40
|
push :smarty
|
41
41
|
end
|
@@ -53,21 +53,21 @@ module Rouge
|
|
53
53
|
|
54
54
|
state :smarty do
|
55
55
|
# allow nested tags
|
56
|
-
rule /\{\/?(?![\s*])/ do
|
56
|
+
rule %r/\{\/?(?![\s*])/ do
|
57
57
|
token Keyword
|
58
58
|
push :smarty
|
59
59
|
end
|
60
60
|
|
61
|
-
rule /}/, Keyword, :pop!
|
62
|
-
rule /\s+/m, Text
|
61
|
+
rule %r/}/, Keyword, :pop!
|
62
|
+
rule %r/\s+/m, Text
|
63
63
|
rule %r([~!%^&*()+=|\[\]:;,.<>/@?-]), Operator
|
64
|
-
rule /#[a-zA-Z_]\w*#/, Name::Variable
|
65
|
-
rule /\$[a-zA-Z_]\w*(\.\w+)*/, Name::Variable
|
66
|
-
rule /(true|false|null)\b/, Keyword::Constant
|
67
|
-
rule /[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?/, Num
|
68
|
-
rule /"(\\.|.)*?"/, Str::Double
|
69
|
-
rule /'(\\.|.)*?'/, Str::Single
|
70
|
-
rule /([a-zA-Z_]\w*)/ do |m|
|
64
|
+
rule %r/#[a-zA-Z_]\w*#/, Name::Variable
|
65
|
+
rule %r/\$[a-zA-Z_]\w*(\.\w+)*/, Name::Variable
|
66
|
+
rule %r/(true|false|null)\b/, Keyword::Constant
|
67
|
+
rule %r/[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?/, Num
|
68
|
+
rule %r/"(\\.|.)*?"/, Str::Double
|
69
|
+
rule %r/'(\\.|.)*?'/, Str::Single
|
70
|
+
rule %r/([a-zA-Z_]\w*)/ do |m|
|
71
71
|
if self.class.builtins.include? m[0]
|
72
72
|
token Name::Builtin
|
73
73
|
else
|
data/lib/rouge/lexers/sml.rb
CHANGED
@@ -30,25 +30,25 @@ module Rouge
|
|
30
30
|
symbol = %r([!%&$#/:<=>?@\\~`^|*+-]+)
|
31
31
|
|
32
32
|
state :whitespace do
|
33
|
-
rule /\s+/m, Text
|
34
|
-
rule /[(][*]/, Comment, :comment
|
33
|
+
rule %r/\s+/m, Text
|
34
|
+
rule %r/[(][*]/, Comment, :comment
|
35
35
|
end
|
36
36
|
|
37
37
|
state :delimiters do
|
38
|
-
rule /[(\[{]/, Punctuation, :main
|
39
|
-
rule /[)\]}]/, Punctuation, :pop!
|
38
|
+
rule %r/[(\[{]/, Punctuation, :main
|
39
|
+
rule %r/[)\]}]/, Punctuation, :pop!
|
40
40
|
|
41
|
-
rule /\b(let|if|local)\b(?!')/ do
|
41
|
+
rule %r/\b(let|if|local)\b(?!')/ do
|
42
42
|
token Keyword::Reserved
|
43
43
|
push; push
|
44
44
|
end
|
45
45
|
|
46
|
-
rule /\b(struct|sig|while)\b(?!')/ do
|
46
|
+
rule %r/\b(struct|sig|while)\b(?!')/ do
|
47
47
|
token Keyword::Reserved
|
48
48
|
push
|
49
49
|
end
|
50
50
|
|
51
|
-
rule /\b(do|else|end|in|then)\b(?!')/, Keyword::Reserved, :pop!
|
51
|
+
rule %r/\b(do|else|end|in|then)\b(?!')/, Keyword::Reserved, :pop!
|
52
52
|
end
|
53
53
|
|
54
54
|
def token_for_id_with_dot(id)
|
@@ -78,28 +78,28 @@ module Rouge
|
|
78
78
|
end
|
79
79
|
|
80
80
|
state :core do
|
81
|
-
rule /[()\[\]{},;_]|[.][.][.]/, Punctuation
|
82
|
-
rule /#"/, Str::Char, :char
|
83
|
-
rule /"/, Str::Double, :string
|
84
|
-
rule /~?0x[0-9a-fA-F]+/, Num::Hex
|
85
|
-
rule /0wx[0-9a-fA-F]+/, Num::Hex
|
86
|
-
rule /0w\d+/, Num::Integer
|
87
|
-
rule /~?\d+([.]\d+)?[eE]~?\d+/, Num::Float
|
88
|
-
rule /~?\d+[.]\d+/, Num::Float
|
89
|
-
rule /~?\d+/, Num::Integer
|
90
|
-
|
91
|
-
rule /#\s*[1-9][0-9]*/, Name::Label
|
92
|
-
rule /#\s*#{id}/, Name::Label
|
93
|
-
rule /#\s+#{symbol}/, Name::Label
|
94
|
-
|
95
|
-
rule /\b(datatype|abstype)\b(?!')/, Keyword::Reserved, :dname
|
81
|
+
rule %r/[()\[\]{},;_]|[.][.][.]/, Punctuation
|
82
|
+
rule %r/#"/, Str::Char, :char
|
83
|
+
rule %r/"/, Str::Double, :string
|
84
|
+
rule %r/~?0x[0-9a-fA-F]+/, Num::Hex
|
85
|
+
rule %r/0wx[0-9a-fA-F]+/, Num::Hex
|
86
|
+
rule %r/0w\d+/, Num::Integer
|
87
|
+
rule %r/~?\d+([.]\d+)?[eE]~?\d+/, Num::Float
|
88
|
+
rule %r/~?\d+[.]\d+/, Num::Float
|
89
|
+
rule %r/~?\d+/, Num::Integer
|
90
|
+
|
91
|
+
rule %r/#\s*[1-9][0-9]*/, Name::Label
|
92
|
+
rule %r/#\s*#{id}/, Name::Label
|
93
|
+
rule %r/#\s+#{symbol}/, Name::Label
|
94
|
+
|
95
|
+
rule %r/\b(datatype|abstype)\b(?!')/, Keyword::Reserved, :dname
|
96
96
|
rule(/(?=\bexception\b(?!'))/) { push :ename }
|
97
|
-
rule /\b(functor|include|open|signature|structure)\b(?!')/,
|
97
|
+
rule %r/\b(functor|include|open|signature|structure)\b(?!')/,
|
98
98
|
Keyword::Reserved, :sname
|
99
|
-
rule /\b(type|eqtype)\b(?!')/, Keyword::Reserved, :tname
|
99
|
+
rule %r/\b(type|eqtype)\b(?!')/, Keyword::Reserved, :tname
|
100
100
|
|
101
|
-
rule /'#{id}/, Name::Decorator
|
102
|
-
rule /(#{id})([.])/ do |m|
|
101
|
+
rule %r/'#{id}/, Name::Decorator
|
102
|
+
rule %r/(#{id})([.])/ do |m|
|
103
103
|
groups(token_for_id_with_dot(m[1]), Punctuation)
|
104
104
|
push :dotted
|
105
105
|
end
|
@@ -114,7 +114,7 @@ module Rouge
|
|
114
114
|
end
|
115
115
|
|
116
116
|
state :dotted do
|
117
|
-
rule /(#{id})([.])/ do |m|
|
117
|
+
rule %r/(#{id})([.])/ do |m|
|
118
118
|
groups(token_for_id_with_dot(m[1]), Punctuation)
|
119
119
|
end
|
120
120
|
|
@@ -130,15 +130,15 @@ module Rouge
|
|
130
130
|
end
|
131
131
|
|
132
132
|
state :root do
|
133
|
-
rule /#!.*?\n/, Comment::Preproc
|
133
|
+
rule %r/#!.*?\n/, Comment::Preproc
|
134
134
|
rule(//) { push :main }
|
135
135
|
end
|
136
136
|
|
137
137
|
state :main do
|
138
138
|
mixin :whitespace
|
139
139
|
|
140
|
-
rule /\b(val|and)\b(?!')/, Keyword::Reserved, :vname
|
141
|
-
rule /\b(fun)\b(?!')/ do
|
140
|
+
rule %r/\b(val|and)\b(?!')/, Keyword::Reserved, :vname
|
141
|
+
rule %r/\b(fun)\b(?!')/ do
|
142
142
|
token Keyword::Reserved
|
143
143
|
goto :main_fun
|
144
144
|
push :fname
|
@@ -150,15 +150,15 @@ module Rouge
|
|
150
150
|
|
151
151
|
state :main_fun do
|
152
152
|
mixin :whitespace
|
153
|
-
rule /\b(fun|and)\b(?!')/, Keyword::Reserved, :fname
|
154
|
-
rule /\bval\b(?!')/ do
|
153
|
+
rule %r/\b(fun|and)\b(?!')/, Keyword::Reserved, :fname
|
154
|
+
rule %r/\bval\b(?!')/ do
|
155
155
|
token Keyword::Reserved
|
156
156
|
goto :main
|
157
157
|
push :vname
|
158
158
|
end
|
159
159
|
|
160
|
-
rule /[|]/, Punctuation, :fname
|
161
|
-
rule /\b(case|handle)\b(?!')/ do
|
160
|
+
rule %r/[|]/, Punctuation, :fname
|
161
|
+
rule %r/\b(case|handle)\b(?!')/ do
|
162
162
|
token Keyword::Reserved
|
163
163
|
goto :main
|
164
164
|
end
|
@@ -168,27 +168,27 @@ module Rouge
|
|
168
168
|
end
|
169
169
|
|
170
170
|
state :has_escapes do
|
171
|
-
rule /\\[\\"abtnvfr]/, Str::Escape
|
172
|
-
rule /\\\^[\x40-\x5e]/, Str::Escape
|
173
|
-
rule /\\[0-9]{3}/, Str::Escape
|
174
|
-
rule /\\u\h{4}/, Str::Escape
|
175
|
-
rule /\\\s+\\/, Str::Interpol
|
171
|
+
rule %r/\\[\\"abtnvfr]/, Str::Escape
|
172
|
+
rule %r/\\\^[\x40-\x5e]/, Str::Escape
|
173
|
+
rule %r/\\[0-9]{3}/, Str::Escape
|
174
|
+
rule %r/\\u\h{4}/, Str::Escape
|
175
|
+
rule %r/\\\s+\\/, Str::Interpol
|
176
176
|
end
|
177
177
|
|
178
178
|
state :string do
|
179
|
-
rule /[^"\\]+/, Str::Double
|
180
|
-
rule /"/, Str::Double, :pop!
|
179
|
+
rule %r/[^"\\]+/, Str::Double
|
180
|
+
rule %r/"/, Str::Double, :pop!
|
181
181
|
mixin :has_escapes
|
182
182
|
end
|
183
183
|
|
184
184
|
state :char do
|
185
|
-
rule /[^"\\]+/, Str::Char
|
186
|
-
rule /"/, Str::Char, :pop!
|
185
|
+
rule %r/[^"\\]+/, Str::Char
|
186
|
+
rule %r/"/, Str::Char, :pop!
|
187
187
|
mixin :has_escapes
|
188
188
|
end
|
189
189
|
|
190
190
|
state :breakout do
|
191
|
-
rule /(?=\b(#{SML.keywords.to_a.join('|')})\b(?!'))/ do
|
191
|
+
rule %r/(?=\b(#{SML.keywords.to_a.join('|')})\b(?!'))/ do
|
192
192
|
pop!
|
193
193
|
end
|
194
194
|
end
|
@@ -201,8 +201,8 @@ module Rouge
|
|
201
201
|
end
|
202
202
|
|
203
203
|
state :has_annotations do
|
204
|
-
rule /'[\w']*/, Name::Decorator
|
205
|
-
rule /[(]/, Punctuation, :tyvarseq
|
204
|
+
rule %r/'[\w']*/, Name::Decorator
|
205
|
+
rule %r/[(]/, Punctuation, :tyvarseq
|
206
206
|
end
|
207
207
|
|
208
208
|
state :fname do
|
@@ -217,12 +217,12 @@ module Rouge
|
|
217
217
|
mixin :whitespace
|
218
218
|
mixin :has_annotations
|
219
219
|
|
220
|
-
rule /(#{id})(\s*)(=(?!#{symbol}))/m do
|
220
|
+
rule %r/(#{id})(\s*)(=(?!#{symbol}))/m do
|
221
221
|
groups Name::Variable, Text, Punctuation
|
222
222
|
pop!
|
223
223
|
end
|
224
224
|
|
225
|
-
rule /(#{symbol})(\s*)(=(?!#{symbol}))/m do
|
225
|
+
rule %r/(#{symbol})(\s*)(=(?!#{symbol}))/m do
|
226
226
|
groups Name::Variable, Text, Punctuation
|
227
227
|
end
|
228
228
|
|
@@ -237,8 +237,8 @@ module Rouge
|
|
237
237
|
mixin :breakout
|
238
238
|
mixin :has_annotations
|
239
239
|
|
240
|
-
rule /'[\w']*/, Name::Decorator
|
241
|
-
rule /[(]/, Punctuation, :tyvarseq
|
240
|
+
rule %r/'[\w']*/, Name::Decorator
|
241
|
+
rule %r/[(]/, Punctuation, :tyvarseq
|
242
242
|
|
243
243
|
rule %r(=(?!#{symbol})) do
|
244
244
|
token Punctuation
|
@@ -252,7 +252,7 @@ module Rouge
|
|
252
252
|
state :typbind do
|
253
253
|
mixin :whitespace
|
254
254
|
|
255
|
-
rule /\b(and)\b(?!')/ do
|
255
|
+
rule %r/\b(and)\b(?!')/ do
|
256
256
|
token Keyword::Reserved
|
257
257
|
goto :tname
|
258
258
|
end
|
@@ -266,7 +266,7 @@ module Rouge
|
|
266
266
|
mixin :breakout
|
267
267
|
mixin :has_annotations
|
268
268
|
|
269
|
-
rule /(=)(\s*)(datatype)\b/ do
|
269
|
+
rule %r/(=)(\s*)(datatype)\b/ do
|
270
270
|
groups Punctuation, Text, Keyword::Reserved
|
271
271
|
pop!
|
272
272
|
end
|
@@ -283,18 +283,18 @@ module Rouge
|
|
283
283
|
|
284
284
|
state :datbind do
|
285
285
|
mixin :whitespace
|
286
|
-
rule /\b(and)\b(?!')/ do
|
286
|
+
rule %r/\b(and)\b(?!')/ do
|
287
287
|
token Keyword::Reserved; goto :dname
|
288
288
|
end
|
289
|
-
rule /\b(withtype)\b(?!')/ do
|
289
|
+
rule %r/\b(withtype)\b(?!')/ do
|
290
290
|
token Keyword::Reserved; goto :tname
|
291
291
|
end
|
292
|
-
rule /\bof\b(?!')/, Keyword::Reserved
|
293
|
-
rule /([|])(\s*)(#{id})/ do
|
292
|
+
rule %r/\bof\b(?!')/, Keyword::Reserved
|
293
|
+
rule %r/([|])(\s*)(#{id})/ do
|
294
294
|
groups(Punctuation, Text, Name::Class)
|
295
295
|
end
|
296
296
|
|
297
|
-
rule /([|])(\s+)(#{symbol})/ do
|
297
|
+
rule %r/([|])(\s+)(#{symbol})/ do
|
298
298
|
groups(Punctuation, Text, Name::Class)
|
299
299
|
end
|
300
300
|
|
@@ -304,15 +304,15 @@ module Rouge
|
|
304
304
|
|
305
305
|
state :ename do
|
306
306
|
mixin :whitespace
|
307
|
-
rule /(exception|and)(\s+)(#{id})/ do
|
307
|
+
rule %r/(exception|and)(\s+)(#{id})/ do
|
308
308
|
groups Keyword::Reserved, Text, Name::Class
|
309
309
|
end
|
310
310
|
|
311
|
-
rule /(exception|and)(\s*)(#{symbol})/ do
|
311
|
+
rule %r/(exception|and)(\s*)(#{symbol})/ do
|
312
312
|
groups Keyword::Reserved, Text, Name::Class
|
313
313
|
end
|
314
314
|
|
315
|
-
rule /\b(of)\b(?!')/, Keyword::Reserved
|
315
|
+
rule %r/\b(of)\b(?!')/, Keyword::Reserved
|
316
316
|
mixin :breakout
|
317
317
|
mixin :core
|
318
318
|
end
|
@@ -325,20 +325,20 @@ module Rouge
|
|
325
325
|
|
326
326
|
state :tyvarseq do
|
327
327
|
mixin :whitespace
|
328
|
-
rule /'[\w']*/, Name::Decorator
|
328
|
+
rule %r/'[\w']*/, Name::Decorator
|
329
329
|
rule id, Name
|
330
|
-
rule /,/, Punctuation
|
331
|
-
rule /[)]/, Punctuation, :pop!
|
330
|
+
rule %r/,/, Punctuation
|
331
|
+
rule %r/[)]/, Punctuation, :pop!
|
332
332
|
rule symbol, Name
|
333
333
|
end
|
334
334
|
|
335
335
|
state :comment do
|
336
|
-
rule /[^(*)]+/, Comment::Multiline
|
337
|
-
rule /[(][*]/ do
|
336
|
+
rule %r/[^(*)]+/, Comment::Multiline
|
337
|
+
rule %r/[(][*]/ do
|
338
338
|
token Comment::Multiline; push
|
339
339
|
end
|
340
|
-
rule /[*][)]/, Comment::Multiline, :pop!
|
341
|
-
rule /[(*)]/, Comment::Multiline
|
340
|
+
rule %r/[*][)]/, Comment::Multiline, :pop!
|
341
|
+
rule %r/[(*)]/, Comment::Multiline
|
342
342
|
end
|
343
343
|
end
|
344
344
|
end
|