rouge 3.19.0 → 3.24.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 +1 -0
- data/lib/rouge/cli.rb +32 -2
- data/lib/rouge/demos/augeas +16 -0
- data/lib/rouge/demos/bibtex +12 -0
- data/lib/rouge/demos/brightscript +6 -0
- data/lib/rouge/demos/email +11 -0
- data/lib/rouge/demos/hlsl +20 -0
- data/lib/rouge/demos/j +12 -0
- data/lib/rouge/demos/janet +3 -0
- data/lib/rouge/demos/livescript +15 -0
- data/lib/rouge/demos/postscript +9 -0
- data/lib/rouge/demos/ssh +4 -0
- data/lib/rouge/demos/systemd +4 -0
- data/lib/rouge/demos/velocity +9 -0
- data/lib/rouge/demos/zig +6 -0
- data/lib/rouge/formatters/html_line_highlighter.rb +26 -0
- data/lib/rouge/lexer.rb +38 -20
- data/lib/rouge/lexers/apex.rb +9 -7
- data/lib/rouge/lexers/augeas.rb +93 -0
- data/lib/rouge/lexers/batchfile.rb +1 -1
- data/lib/rouge/lexers/bibtex.rb +115 -0
- data/lib/rouge/lexers/brightscript.rb +147 -0
- data/lib/rouge/lexers/cpp.rb +11 -4
- data/lib/rouge/lexers/css.rb +3 -1
- data/lib/rouge/lexers/diff.rb +1 -1
- data/lib/rouge/lexers/docker.rb +1 -1
- data/lib/rouge/lexers/elm.rb +5 -5
- data/lib/rouge/lexers/email.rb +39 -0
- data/lib/rouge/lexers/ghc_core.rb +2 -1
- data/lib/rouge/lexers/graphql.rb +1 -1
- data/lib/rouge/lexers/hack.rb +1 -1
- data/lib/rouge/lexers/haskell.rb +27 -19
- data/lib/rouge/lexers/hlsl.rb +166 -0
- data/lib/rouge/lexers/html.rb +7 -7
- data/lib/rouge/lexers/http.rb +8 -2
- data/lib/rouge/lexers/isbl.rb +2 -2
- data/lib/rouge/lexers/j.rb +244 -0
- data/lib/rouge/lexers/janet.rb +218 -0
- data/lib/rouge/lexers/javascript.rb +10 -5
- data/lib/rouge/lexers/jinja.rb +22 -7
- data/lib/rouge/lexers/jsl.rb +1 -1
- data/lib/rouge/lexers/jsonnet.rb +4 -3
- data/lib/rouge/lexers/jsp.rb +2 -3
- data/lib/rouge/lexers/jsx.rb +47 -59
- data/lib/rouge/lexers/julia.rb +4 -2
- data/lib/rouge/lexers/kotlin.rb +7 -3
- data/lib/rouge/lexers/livescript.rb +310 -0
- data/lib/rouge/lexers/opentype_feature_file.rb +26 -42
- data/lib/rouge/lexers/perl.rb +21 -3
- data/lib/rouge/lexers/php.rb +274 -128
- data/lib/rouge/lexers/postscript.rb +93 -0
- data/lib/rouge/lexers/powershell.rb +5 -3
- data/lib/rouge/lexers/q.rb +1 -1
- data/lib/rouge/lexers/rego.rb +27 -12
- data/lib/rouge/lexers/ruby.rb +3 -3
- data/lib/rouge/lexers/rust.rb +3 -1
- data/lib/rouge/lexers/sass/common.rb +1 -0
- data/lib/rouge/lexers/smarty.rb +1 -1
- data/lib/rouge/lexers/ssh.rb +33 -0
- data/lib/rouge/lexers/systemd.rb +34 -0
- data/lib/rouge/lexers/tsx.rb +10 -3
- data/lib/rouge/lexers/twig.rb +4 -4
- data/lib/rouge/lexers/typescript.rb +1 -12
- data/lib/rouge/lexers/typescript/common.rb +18 -4
- data/lib/rouge/lexers/velocity.rb +71 -0
- data/lib/rouge/lexers/wollok.rb +0 -1
- data/lib/rouge/lexers/xml.rb +5 -3
- data/lib/rouge/lexers/yaml.rb +5 -3
- data/lib/rouge/lexers/zig.rb +139 -0
- data/lib/rouge/regex_lexer.rb +56 -1
- data/lib/rouge/version.rb +1 -1
- metadata +29 -2
data/lib/rouge/lexers/perl.rb
CHANGED
@@ -65,7 +65,7 @@ module Rouge
|
|
65
65
|
end
|
66
66
|
|
67
67
|
state :root do
|
68
|
-
rule %r
|
68
|
+
rule %r/#.*/, Comment::Single
|
69
69
|
rule %r/^=[a-zA-Z0-9]+\s+.*?\n=cut/m, Comment::Multiline
|
70
70
|
rule %r/(?:#{keywords.join('|')})\b/, Keyword
|
71
71
|
|
@@ -99,6 +99,9 @@ module Rouge
|
|
99
99
|
re_tok, :balanced_regex
|
100
100
|
|
101
101
|
rule %r/\s+/, Text
|
102
|
+
|
103
|
+
rule(/(?=[a-z_]\w*(\s*#.*\n)*\s*=>)/i) { push :fat_comma }
|
104
|
+
|
102
105
|
rule %r/(?:#{builtins.join('|')})\b/, Name::Builtin
|
103
106
|
rule %r/((__(DIE|WARN)__)|(DATA|STD(IN|OUT|ERR)))\b/,
|
104
107
|
Name::Builtin::Pseudo
|
@@ -142,6 +145,13 @@ module Rouge
|
|
142
145
|
rule %r/.*?\n/, Str::Interpol
|
143
146
|
end
|
144
147
|
|
148
|
+
state :fat_comma do
|
149
|
+
rule %r/#.*/, Comment::Single
|
150
|
+
rule %r/\w+/, Str
|
151
|
+
rule %r/\s+/, Text
|
152
|
+
rule %r/=>/, Operator, :pop!
|
153
|
+
end
|
154
|
+
|
145
155
|
state :name_common do
|
146
156
|
rule %r/\w+::/, Name::Namespace
|
147
157
|
rule %r/[\w:]+/, Name::Variable, :pop!
|
@@ -178,16 +188,24 @@ module Rouge
|
|
178
188
|
end
|
179
189
|
|
180
190
|
state :sq do
|
181
|
-
rule %r/\\[']/, Str::Escape
|
191
|
+
rule %r/\\[\\']/, Str::Escape
|
182
192
|
rule %r/[^\\']+/, Str::Single
|
183
193
|
rule %r/'/, Punctuation, :pop!
|
194
|
+
rule %r/\\/, Str::Single
|
184
195
|
end
|
185
196
|
|
186
197
|
state :dq do
|
187
198
|
mixin :string_intp
|
188
|
-
rule %r/\\[\\
|
199
|
+
rule %r/\\[\\tnrabefluLUE"$@]/, Str::Escape
|
200
|
+
rule %r/\\0\d{2}/, Str::Escape
|
201
|
+
rule %r/\\o\{\d+\}/, Str::Escape
|
202
|
+
rule %r/\\x\h{2}/, Str::Escape
|
203
|
+
rule %r/\\x\{\h+\}/, Str::Escape
|
204
|
+
rule %r/\\c./, Str::Escape
|
205
|
+
rule %r/\\N\{[^\}]+\}/, Str::Escape
|
189
206
|
rule %r/[^\\"]+?/, Str::Double
|
190
207
|
rule %r/"/, Punctuation, :pop!
|
208
|
+
rule %r/\\/, Str::Escape
|
191
209
|
end
|
192
210
|
|
193
211
|
state :bq do
|
data/lib/rouge/lexers/php.rb
CHANGED
@@ -28,6 +28,26 @@ module Rouge
|
|
28
28
|
@disabledmodules = list_option(:disabledmodules)
|
29
29
|
end
|
30
30
|
|
31
|
+
def self.detect?(text)
|
32
|
+
return true if text.shebang?('php')
|
33
|
+
return false if /^<\?hh/ =~ text
|
34
|
+
return true if /^<\?php/ =~ text
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.keywords
|
38
|
+
@keywords ||= Set.new %w(
|
39
|
+
old_function cfunction
|
40
|
+
__class__ __dir__ __file__ __function__ __halt_compiler __line__
|
41
|
+
__method__ __namespace__ __trait__ abstract and array as break case
|
42
|
+
catch clone continue declare default die do echo else elseif
|
43
|
+
enddeclare endfor endforeach endif endswitch endwhile eval exit
|
44
|
+
extends final finally fn for foreach global goto if implements
|
45
|
+
include include_once instanceof insteadof isset list new or parent
|
46
|
+
print private protected public require require_once return self
|
47
|
+
static switch throw try var while xor yield
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
31
51
|
def self.builtins
|
32
52
|
Kernel::load File.join(Lexers::BASE_DIR, 'php/keywords.rb')
|
33
53
|
builtins
|
@@ -44,188 +64,314 @@ module Rouge
|
|
44
64
|
end
|
45
65
|
end
|
46
66
|
|
47
|
-
# source: http://php.net/manual/en/language.variables.basics.php
|
48
|
-
# the given regex is invalid utf8, so... we're using the unicode
|
49
|
-
# "Letter" property instead.
|
50
67
|
id = /[\p{L}_][\p{L}\p{N}_]*/
|
51
|
-
|
68
|
+
ns = /(?:#{id}\\)+/
|
69
|
+
id_with_ns = /(?:#{ns})?#{id}/
|
52
70
|
|
53
71
|
start do
|
54
72
|
case @start_inline
|
55
73
|
when true
|
56
|
-
push :template
|
57
74
|
push :php
|
58
|
-
when false
|
59
|
-
push :template
|
60
75
|
when :guess
|
61
|
-
|
76
|
+
push :start
|
62
77
|
end
|
63
78
|
end
|
64
79
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
# - class is also listed here, in addition to the rule below, to handle anonymous classes
|
71
|
-
@keywords ||= Set.new %w(
|
72
|
-
old_function cfunction
|
73
|
-
__class__ __dir__ __file__ __function__ __halt_compiler
|
74
|
-
__line__ __method__ __namespace__ __trait__ abstract and
|
75
|
-
array as break callable case catch class clone continue
|
76
|
-
declare default die do echo else elseif enddeclare
|
77
|
-
endfor endforeach endif endswitch endwhile eval exit
|
78
|
-
extends final finally fn for foreach global goto if
|
79
|
-
implements include include_once instanceof insteadof
|
80
|
-
interface list new or parent print private protected
|
81
|
-
public require require_once return self static switch
|
82
|
-
throw trait try var while xor yield
|
83
|
-
)
|
80
|
+
state :escape do
|
81
|
+
rule %r/\?>/ do
|
82
|
+
token Comment::Preproc
|
83
|
+
reset_stack
|
84
|
+
end
|
84
85
|
end
|
85
86
|
|
86
|
-
|
87
|
-
|
88
|
-
return false if /^<\?hh/ =~ text
|
89
|
-
return true if /^<\?php/ =~ text
|
87
|
+
state :return do
|
88
|
+
rule(//) { pop! }
|
90
89
|
end
|
91
90
|
|
92
|
-
state :
|
93
|
-
#
|
94
|
-
|
95
|
-
|
91
|
+
state :start do
|
92
|
+
# We enter this state if we aren't sure whether the PHP in the text is
|
93
|
+
# delimited by <?php (or <?=) tags or not. These two rules check
|
94
|
+
# whether there is an opening angle bracket and, if there is, delegates
|
95
|
+
# the tokens before it to the HTML lexer.
|
96
|
+
rule(/\s*(?=<)/m) { delegate parent; pop! }
|
97
|
+
rule(/[^$]+(?=<\?(php|=))/i) { delegate parent; pop! }
|
96
98
|
|
97
|
-
rule(//) {
|
99
|
+
rule(//) { goto :php }
|
98
100
|
end
|
99
101
|
|
100
|
-
state :
|
101
|
-
rule %r
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
rule %r/#.*?$/, Comment::Single
|
111
|
-
rule %r(//.*?$), Comment::Single
|
112
|
-
rule %r(/\*\*(?!/).*?\*/)m, Comment::Doc
|
113
|
-
rule %r(/\*.*?\*/)m, Comment::Multiline
|
114
|
-
|
115
|
-
rule %r/(->|::)(\s*)(#{id})/ do
|
116
|
-
groups Operator, Text, Name::Attribute
|
102
|
+
state :names do
|
103
|
+
rule %r/#{id_with_ns}(?=\s*\()/ do |m|
|
104
|
+
name = m[0].downcase
|
105
|
+
if self.class.keywords.include? name
|
106
|
+
token Keyword
|
107
|
+
elsif self.builtins.include? name
|
108
|
+
token Name::Builtin
|
109
|
+
else
|
110
|
+
token Name::Function
|
111
|
+
end
|
117
112
|
end
|
118
113
|
|
119
|
-
rule
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
114
|
+
rule id_with_ns do |m|
|
115
|
+
name = m[0].downcase
|
116
|
+
if name == "use"
|
117
|
+
push :in_use
|
118
|
+
token Keyword::Namespace
|
119
|
+
elsif name == "const"
|
120
|
+
push :in_const
|
121
|
+
token Keyword
|
122
|
+
elsif name == "catch"
|
123
|
+
push :in_catch
|
124
|
+
token Keyword
|
125
|
+
elsif %w(public protected private).include? name
|
126
|
+
push :in_visibility
|
127
|
+
token Keyword
|
128
|
+
elsif name == "stdClass"
|
129
|
+
token Name::Class
|
130
|
+
elsif self.class.keywords.include? name
|
131
|
+
token Keyword
|
132
|
+
elsif m[0] =~ /^__.*?__$/
|
133
|
+
token Name::Builtin
|
134
|
+
elsif m[0] =~ /^(E|PHP)(_[[:upper:]]+)+$/
|
135
|
+
token Keyword::Constant
|
136
|
+
elsif m[0] =~ /(\\|^)[[:upper:]][[[:upper:]][[:digit:]]_]+$/
|
137
|
+
token Name::Constant
|
138
|
+
elsif m[0] =~ /(\\|^)[[:upper:]][[:alnum:]]*?$/
|
139
|
+
token Name::Class
|
140
|
+
else
|
141
|
+
token Name
|
142
|
+
end
|
136
143
|
end
|
144
|
+
end
|
137
145
|
|
138
|
-
|
139
|
-
rule %r/
|
140
|
-
|
141
|
-
push :funcname
|
142
|
-
end
|
146
|
+
state :operators do
|
147
|
+
rule %r/[~!%^&*+\|:.<>\/@-]+/, Operator
|
148
|
+
end
|
143
149
|
|
144
|
-
|
145
|
-
|
146
|
-
|
150
|
+
state :string do
|
151
|
+
rule %r/"/, Str::Double, :pop!
|
152
|
+
rule %r/[^\\{$"]+/, Str::Double
|
153
|
+
rule %r/\\u\{[0-9a-fA-F]+\}/, Str::Escape
|
154
|
+
rule %r/\\([efrntv\"$\\]|[0-7]{1,3}|[xX][0-9a-fA-F]{1,2})/, Str::Escape
|
155
|
+
rule %r/\$#{id}(\[\S+\]|->#{id})?/, Name::Variable
|
147
156
|
|
148
|
-
rule %r
|
149
|
-
rule %r
|
150
|
-
rule %r/(
|
151
|
-
|
152
|
-
rule %r/\$+#{id}/i, Name::Variable
|
153
|
-
rule %r/(yield)([ \n\r\t]+)(from)/i do
|
154
|
-
groups Keyword, Text, Keyword
|
157
|
+
rule %r/\{\$\{/, Str::Interpol, :string_interp_double
|
158
|
+
rule %r/\{(?=\$)/, Str::Interpol, :string_interp_single
|
159
|
+
rule %r/(\{)(\S+)(\})/ do
|
160
|
+
groups Str::Interpol, Name::Variable, Str::Interpol
|
155
161
|
end
|
156
162
|
|
157
|
-
|
158
|
-
|
159
|
-
name = m[0].downcase
|
163
|
+
rule %r/[${\\]+/, Str::Double
|
164
|
+
end
|
160
165
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
166
|
+
state :string_interp_double do
|
167
|
+
rule %r/\}\}/, Str::Interpol, :pop!
|
168
|
+
mixin :php
|
169
|
+
end
|
170
|
+
|
171
|
+
state :string_interp_single do
|
172
|
+
rule %r/\}/, Str::Interpol, :pop!
|
173
|
+
mixin :php
|
174
|
+
end
|
175
|
+
|
176
|
+
state :values do
|
177
|
+
# heredocs
|
178
|
+
rule %r/<<<(["']?)(#{id})\1\n.*?\n\s*\2;?/im, Str::Heredoc
|
169
179
|
|
180
|
+
# numbers
|
170
181
|
rule %r/(\d[_\d]*)?\.(\d[_\d]*)?(e[+-]?\d[_\d]*)?/i, Num::Float
|
171
182
|
rule %r/0[0-7][0-7_]*/, Num::Oct
|
172
183
|
rule %r/0b[01][01_]*/i, Num::Bin
|
173
184
|
rule %r/0x[a-f0-9][a-f0-9_]*/i, Num::Hex
|
174
185
|
rule %r/\d[_\d]*/, Num::Integer
|
186
|
+
|
187
|
+
# strings
|
175
188
|
rule %r/'([^'\\]*(?:\\.[^'\\]*)*)'/, Str::Single
|
176
189
|
rule %r/`([^`\\]*(?:\\.[^`\\]*)*)`/, Str::Backtick
|
177
190
|
rule %r/"/, Str::Double, :string
|
178
|
-
end
|
179
191
|
|
180
|
-
|
181
|
-
rule %r/(
|
182
|
-
|
183
|
-
:
|
192
|
+
# functions
|
193
|
+
rule %r/(function|fn)\b/i do
|
194
|
+
push :in_function_return
|
195
|
+
push :in_function_params
|
196
|
+
push :in_function_name
|
197
|
+
token Keyword
|
184
198
|
end
|
185
|
-
|
186
|
-
|
199
|
+
|
200
|
+
# constants
|
201
|
+
rule %r/(true|false|null)\b/i, Keyword::Constant
|
202
|
+
|
203
|
+
# objects
|
204
|
+
rule %r/new\b/i, Keyword, :in_new
|
205
|
+
end
|
206
|
+
|
207
|
+
state :variables do
|
208
|
+
rule %r/\$\{\$+#{id}\}/, Name::Variable
|
209
|
+
rule %r/\$+#{id}/, Name::Variable
|
187
210
|
end
|
188
211
|
|
189
|
-
state :
|
212
|
+
state :whitespace do
|
190
213
|
rule %r/\s+/, Text
|
191
|
-
rule %r
|
192
|
-
rule %r
|
193
|
-
rule %r
|
194
|
-
|
195
|
-
end
|
196
|
-
rule %r/#{id}/, Name::Namespace
|
214
|
+
rule %r/#.*?$/, Comment::Single
|
215
|
+
rule %r(//.*?$), Comment::Single
|
216
|
+
rule %r(/\*\*(?!/).*?\*/)m, Comment::Doc
|
217
|
+
rule %r(/\*.*?\*/)m, Comment::Multiline
|
197
218
|
end
|
198
219
|
|
199
|
-
state :
|
200
|
-
rule %r
|
220
|
+
state :root do
|
221
|
+
rule %r/<\?(php|=)?/i, Comment::Preproc, :php
|
222
|
+
rule(/.*?(?=<\?)|.*/m) { delegate parent }
|
201
223
|
end
|
202
224
|
|
203
|
-
state :
|
204
|
-
|
205
|
-
rule %r/[^\\{$"]+/, Str::Double
|
206
|
-
rule %r/\\u\{[0-9a-fA-F]+\}/, Str::Escape
|
207
|
-
rule %r/\\([efrntv\"$\\]|[0-7]{1,3}|[xX][0-9a-fA-F]{1,2})/,
|
208
|
-
Str::Escape
|
209
|
-
rule %r/\$#{id}(\[\S+\]|->#{id})?/, Name::Variable
|
225
|
+
state :php do
|
226
|
+
mixin :escape
|
210
227
|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
228
|
+
mixin :whitespace
|
229
|
+
mixin :variables
|
230
|
+
mixin :values
|
231
|
+
|
232
|
+
rule %r/(namespace)
|
233
|
+
(\s+)
|
234
|
+
(#{id_with_ns})/ix do |m|
|
235
|
+
groups Keyword::Namespace, Text, Name::Namespace
|
215
236
|
end
|
216
237
|
|
217
|
-
rule %r/
|
238
|
+
rule %r/(class|interface|trait|extends|implements)
|
239
|
+
(\s+)
|
240
|
+
(#{id_with_ns})/ix do |m|
|
241
|
+
groups Keyword::Declaration, Text, Name::Class
|
242
|
+
end
|
243
|
+
|
244
|
+
mixin :names
|
245
|
+
|
246
|
+
rule %r/[;,\(\)\{\}\[\]]/, Punctuation
|
247
|
+
|
248
|
+
mixin :operators
|
249
|
+
rule %r/[=?]/, Operator
|
218
250
|
end
|
219
251
|
|
220
|
-
state :
|
221
|
-
rule %r
|
252
|
+
state :in_assign do
|
253
|
+
rule %r/,/, Punctuation, :pop!
|
254
|
+
rule %r/[\[\]]/, Punctuation
|
255
|
+
rule %r/\(/, Punctuation, :in_assign_function
|
256
|
+
mixin :escape
|
257
|
+
mixin :whitespace
|
258
|
+
mixin :values
|
259
|
+
mixin :variables
|
260
|
+
mixin :names
|
261
|
+
mixin :operators
|
262
|
+
mixin :return
|
263
|
+
end
|
264
|
+
|
265
|
+
state :in_assign_function do
|
266
|
+
rule %r/\)/, Punctuation, :pop!
|
267
|
+
rule %r/,/, Punctuation
|
268
|
+
mixin :in_assign
|
269
|
+
end
|
270
|
+
|
271
|
+
state :in_catch do
|
272
|
+
rule %r/\(/, Punctuation
|
273
|
+
rule %r/\|/, Operator
|
274
|
+
rule id, Name::Class
|
275
|
+
mixin :escape
|
276
|
+
mixin :whitespace
|
277
|
+
mixin :return
|
278
|
+
end
|
279
|
+
|
280
|
+
state :in_const do
|
281
|
+
rule id, Name::Constant
|
282
|
+
rule %r/=/, Operator, :in_assign
|
283
|
+
mixin :escape
|
284
|
+
mixin :whitespace
|
285
|
+
mixin :return
|
286
|
+
end
|
287
|
+
|
288
|
+
state :in_function_body do
|
289
|
+
rule %r/{/, Punctuation, :push
|
290
|
+
rule %r/}/, Punctuation, :pop!
|
222
291
|
mixin :php
|
223
292
|
end
|
224
293
|
|
225
|
-
state :
|
226
|
-
rule %r
|
294
|
+
state :in_function_name do
|
295
|
+
rule %r/&/, Operator
|
296
|
+
rule id, Name
|
297
|
+
rule %r/\(/, Punctuation, :pop!
|
298
|
+
mixin :escape
|
299
|
+
mixin :whitespace
|
300
|
+
mixin :return
|
301
|
+
end
|
302
|
+
|
303
|
+
state :in_function_params do
|
304
|
+
rule %r/\)/, Punctuation, :pop!
|
305
|
+
rule %r/,/, Punctuation
|
306
|
+
rule %r/[.]{3}/, Punctuation
|
307
|
+
rule %r/=/, Operator, :in_assign
|
308
|
+
rule %r/\??#{id}/, Keyword::Type, :in_assign
|
309
|
+
mixin :escape
|
310
|
+
mixin :whitespace
|
311
|
+
mixin :variables
|
312
|
+
mixin :return
|
313
|
+
end
|
314
|
+
|
315
|
+
state :in_function_return do
|
316
|
+
rule %r/:/, Punctuation
|
317
|
+
rule %r/use\b/i, Keyword, :in_function_use
|
318
|
+
rule %r/\??#{id}/, Keyword::Type, :in_assign
|
319
|
+
rule %r/\{/ do
|
320
|
+
token Punctuation
|
321
|
+
goto :in_function_body
|
322
|
+
end
|
323
|
+
mixin :escape
|
324
|
+
mixin :whitespace
|
325
|
+
mixin :return
|
326
|
+
end
|
327
|
+
|
328
|
+
state :in_function_use do
|
329
|
+
rule %r/[,\(]/, Punctuation
|
330
|
+
rule %r/&/, Operator
|
331
|
+
rule %r/\)/, Punctuation, :pop!
|
332
|
+
mixin :escape
|
333
|
+
mixin :whitespace
|
334
|
+
mixin :variables
|
335
|
+
mixin :return
|
336
|
+
end
|
337
|
+
|
338
|
+
state :in_new do
|
339
|
+
rule %r/class\b/i do
|
340
|
+
token Keyword::Declaration
|
341
|
+
goto :in_new_class
|
342
|
+
end
|
343
|
+
rule id_with_ns, Name::Class, :pop!
|
344
|
+
mixin :escape
|
345
|
+
mixin :whitespace
|
346
|
+
mixin :return
|
347
|
+
end
|
348
|
+
|
349
|
+
state :in_new_class do
|
350
|
+
rule %r/\}/, Punctuation, :pop!
|
351
|
+
rule %r/\{/, Punctuation
|
227
352
|
mixin :php
|
228
353
|
end
|
354
|
+
|
355
|
+
state :in_use do
|
356
|
+
rule %r/[,\}]/, Punctuation
|
357
|
+
rule %r/(function|const)\b/i, Keyword
|
358
|
+
rule %r/(#{ns})(\{)/ do
|
359
|
+
groups Name::Namespace, Punctuation
|
360
|
+
end
|
361
|
+
rule %r/#{id_with_ns}(_#{id})+/, Name::Function
|
362
|
+
mixin :escape
|
363
|
+
mixin :whitespace
|
364
|
+
mixin :names
|
365
|
+
mixin :return
|
366
|
+
end
|
367
|
+
|
368
|
+
state :in_visibility do
|
369
|
+
rule %r/(?=(abstract|const|function|static)\b)/i, Keyword, :pop!
|
370
|
+
rule %r/\??#{id}/, Keyword::Type, :pop!
|
371
|
+
mixin :escape
|
372
|
+
mixin :whitespace
|
373
|
+
mixin :return
|
374
|
+
end
|
229
375
|
end
|
230
376
|
end
|
231
377
|
end
|