rouge 3.20.0 → 3.25.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/brightscript +6 -0
- data/lib/rouge/demos/email +11 -0
- data/lib/rouge/demos/j +12 -0
- data/lib/rouge/demos/janet +3 -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/formatters/html_line_highlighter.rb +24 -0
- data/lib/rouge/formatters/html_line_table.rb +1 -3
- data/lib/rouge/formatters/html_linewise.rb +2 -3
- data/lib/rouge/lexer.rb +38 -20
- data/lib/rouge/lexers/apex.rb +9 -7
- data/lib/rouge/lexers/batchfile.rb +3 -2
- data/lib/rouge/lexers/brightscript.rb +147 -0
- data/lib/rouge/lexers/cpp.rb +6 -5
- data/lib/rouge/lexers/css.rb +3 -1
- data/lib/rouge/lexers/docker.rb +2 -2
- 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/html.rb +6 -6
- 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 +11 -3
- 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/julia.rb +4 -2
- data/lib/rouge/lexers/kotlin.rb +8 -4
- data/lib/rouge/lexers/opentype_feature_file.rb +0 -1
- data/lib/rouge/lexers/perl.rb +27 -7
- data/lib/rouge/lexers/php.rb +274 -128
- data/lib/rouge/lexers/postscript.rb +93 -0
- data/lib/rouge/lexers/powershell.rb +41 -29
- data/lib/rouge/lexers/q.rb +1 -1
- data/lib/rouge/lexers/rego.rb +27 -12
- data/lib/rouge/lexers/ruby.rb +1 -1
- data/lib/rouge/lexers/rust.rb +5 -3
- 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/twig.rb +4 -4
- data/lib/rouge/lexers/velocity.rb +1 -1
- 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/regex_lexer.rb +56 -1
- data/lib/rouge/version.rb +1 -1
- metadata +17 -2
@@ -0,0 +1,218 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Rouge
|
5
|
+
module Lexers
|
6
|
+
class Janet < RegexLexer
|
7
|
+
title "Janet"
|
8
|
+
desc "The Janet programming language (janet-lang.org)"
|
9
|
+
|
10
|
+
tag 'janet'
|
11
|
+
aliases 'jdn'
|
12
|
+
|
13
|
+
filenames '*.janet', '*.jdn'
|
14
|
+
|
15
|
+
mimetypes 'text/x-janet', 'application/x-janet'
|
16
|
+
|
17
|
+
def self.specials
|
18
|
+
@specials ||= Set.new %w(
|
19
|
+
break def do fn if quote quasiquote splice set unquote var while
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.bundled
|
24
|
+
@bundled ||= Set.new %w(
|
25
|
+
% %= * *= + ++ += - -- -= -> ->> -?> -?>> / /= < <= = > >=
|
26
|
+
abstract? accumulate accumulate2 all all-bindings
|
27
|
+
all-dynamics and apply array array/concat array/ensure
|
28
|
+
array/fill array/insert array/new array/new-filled
|
29
|
+
array/peek array/pop array/push array/remove array/slice
|
30
|
+
array? as-> as?-> asm assert bad-compile bad-parse band
|
31
|
+
blshift bnot boolean? bor brshift brushift buffer buffer/bit
|
32
|
+
buffer/bit-clear buffer/bit-set buffer/bit-toggle
|
33
|
+
buffer/blit buffer/clear buffer/fill buffer/format
|
34
|
+
buffer/new buffer/new-filled buffer/popn buffer/push-byte
|
35
|
+
buffer/push-string buffer/push-word buffer/slice buffer?
|
36
|
+
bxor bytes? case cfunction? chr cli-main comment comp
|
37
|
+
compare compare= compare< compare<= compare> compare>=
|
38
|
+
compile complement comptime cond coro count debug
|
39
|
+
debug/arg-stack debug/break debug/fbreak debug/lineage
|
40
|
+
debug/stack debug/stacktrace debug/step debug/unbreak
|
41
|
+
debug/unfbreak debugger-env dec deep-not= deep= default
|
42
|
+
default-peg-grammar def- defer defmacro defmacro- defn defn-
|
43
|
+
defglobal describe dictionary? disasm distinct doc doc*
|
44
|
+
doc-format dofile drop drop-until drop-while dyn each eachk
|
45
|
+
eachp eachy edefer eflush empty? env-lookup eprin eprinf
|
46
|
+
eprint eprintf error errorf eval eval-string even? every?
|
47
|
+
extreme false? fiber/can-resume? fiber/current fiber/getenv
|
48
|
+
fiber/maxstack fiber/new fiber/root fiber/setenv
|
49
|
+
fiber/setmaxstack fiber/status fiber? file/close file/flush
|
50
|
+
file/open file/popen file/read file/seek file/temp
|
51
|
+
file/write filter find find-index first flatten flatten-into
|
52
|
+
flush for forv freeze frequencies function? gccollect
|
53
|
+
gcinterval gcsetinterval generate gensym get get-in getline
|
54
|
+
hash idempotent? identity import import* if-let if-not
|
55
|
+
if-with in inc indexed? int/s64 int/u64 int? interleave
|
56
|
+
interpose invert janet/build janet/config-bits janet/version
|
57
|
+
juxt juxt* keep keys keyword keyword? kvs label last length
|
58
|
+
let load-image load-image-dict loop macex macex1 make-env
|
59
|
+
make-image make-image-dict map mapcat marshal math/-inf
|
60
|
+
math/abs math/acos math/acosh math/asin math/asinh math/atan
|
61
|
+
math/atan2 math/atanh math/cbrt math/ceil math/cos math/cosh
|
62
|
+
math/e math/erf math/erfc math/exp math/exp2 math/expm1
|
63
|
+
math/floor math/gamma math/hypot math/inf math/log
|
64
|
+
math/log10 math/log1p math/log2 math/next math/pi math/pow
|
65
|
+
math/random math/rng math/rng-buffer math/rng-int
|
66
|
+
math/rng-uniform math/round math/seedrandom math/sin
|
67
|
+
math/sinh math/sqrt math/tan math/tanh math/trunc match max
|
68
|
+
mean merge merge-into min mod module/add-paths module/cache
|
69
|
+
module/expand-path module/find module/loaders module/loading
|
70
|
+
module/paths nan? nat? native neg? net/chunk net/close
|
71
|
+
net/connect net/read net/server net/write next nil? not not=
|
72
|
+
number? odd? one? or os/arch os/cd os/chmod os/clock
|
73
|
+
os/cryptorand os/cwd os/date os/dir os/environ os/execute
|
74
|
+
os/exit os/getenv os/link os/lstat os/mkdir os/mktime
|
75
|
+
os/perm-int os/perm-string os/readlink os/realpath os/rename
|
76
|
+
os/rm os/rmdir os/setenv os/shell os/sleep os/stat
|
77
|
+
os/symlink os/time os/touch os/umask os/which pairs parse
|
78
|
+
parser/byte parser/clone parser/consume parser/eof
|
79
|
+
parser/error parser/flush parser/has-more parser/insert
|
80
|
+
parser/new parser/produce parser/state parser/status
|
81
|
+
parser/where partial partition peg/compile peg/match pos?
|
82
|
+
postwalk pp prewalk prin prinf print printf product prompt
|
83
|
+
propagate protect put put-in quit range reduce reduce2
|
84
|
+
repeat repl require resume return reverse reversed root-env
|
85
|
+
run-context scan-number seq setdyn shortfn signal slice
|
86
|
+
slurp some sort sort-by sorted sorted-by spit stderr stdin
|
87
|
+
stdout string string/ascii-lower string/ascii-upper
|
88
|
+
string/bytes string/check-set string/find string/find-all
|
89
|
+
string/format string/from-bytes string/has-prefix?
|
90
|
+
string/has-suffix? string/join string/repeat string/replace
|
91
|
+
string/replace-all string/reverse string/slice string/split
|
92
|
+
string/trim string/triml string/trimr string? struct struct?
|
93
|
+
sum symbol symbol? table table/clone table/getproto
|
94
|
+
table/new table/rawget table/setproto table/to-struct table?
|
95
|
+
take take-until take-while tarray/buffer tarray/copy-bytes
|
96
|
+
tarray/length tarray/new tarray/properties tarray/slice
|
97
|
+
tarray/swap-bytes thread/close thread/current thread/new
|
98
|
+
thread/receive thread/send trace tracev true? truthy? try
|
99
|
+
tuple tuple/brackets tuple/setmap tuple/slice
|
100
|
+
tuple/sourcemap tuple/type tuple? type unless unmarshal
|
101
|
+
untrace update update-in use values var- varfn varglobal
|
102
|
+
walk walk-ind walk-dict when when-let when-with with
|
103
|
+
with-dyns with-syms with-vars yield zero? zipcoll
|
104
|
+
)
|
105
|
+
end
|
106
|
+
|
107
|
+
def name_token(name)
|
108
|
+
if self.class.specials.include? name
|
109
|
+
Keyword
|
110
|
+
elsif self.class.bundled.include? name
|
111
|
+
Keyword::Reserved
|
112
|
+
else
|
113
|
+
Name::Function
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
punctuation = %r/[_!$%^&*+=~<>.?\/-]/o
|
118
|
+
symbol = %r/([[:alpha:]]|#{punctuation})([[:word:]]|#{punctuation}|:)*/o
|
119
|
+
|
120
|
+
state :root do
|
121
|
+
rule %r/#.*?$/, Comment::Single
|
122
|
+
rule %r/\s+/m, Text::Whitespace
|
123
|
+
|
124
|
+
rule %r/(true|false|nil)\b/, Name::Constant
|
125
|
+
rule %r/(['~])(#{symbol})/ do
|
126
|
+
groups Operator, Str::Symbol
|
127
|
+
end
|
128
|
+
rule %r/:([[:word:]]|#{punctuation}|:)*/, Keyword::Constant
|
129
|
+
|
130
|
+
# radix-specified numbers
|
131
|
+
rule %r/[+-]?\d{1,2}r[\w.]+(&[+-]?\w+)?/, Num::Float
|
132
|
+
|
133
|
+
# hex numbers
|
134
|
+
rule %r/[+-]?0x\h[\h_]*(\.\h[\h_]*)?/, Num::Hex
|
135
|
+
rule %r/[+-]?0x\.\h[\h_]*/, Num::Hex
|
136
|
+
|
137
|
+
# decimal numbers (Janet treats all decimals as floats)
|
138
|
+
rule %r/[+-]?\d[\d_]*(\.\d[\d_]*)?([e][+-]?\d+)?/i, Num::Float
|
139
|
+
rule %r/[+-]?\.\d[\d_]*([e][+-]?\d+)?/i, Num::Float
|
140
|
+
|
141
|
+
rule %r/@?"/, Str::Double, :string
|
142
|
+
rule %r/@?(`+).*?\1/m, Str::Heredoc
|
143
|
+
|
144
|
+
rule %r/\(/, Punctuation, :function
|
145
|
+
|
146
|
+
rule %r/(')(@?[(\[{])/ do
|
147
|
+
groups Operator, Punctuation
|
148
|
+
push :quote
|
149
|
+
end
|
150
|
+
|
151
|
+
rule %r/(~)(@?[(\[{])/ do
|
152
|
+
groups Operator, Punctuation
|
153
|
+
push :quasiquote
|
154
|
+
end
|
155
|
+
|
156
|
+
rule %r/[\#~,';\|]/, Operator
|
157
|
+
|
158
|
+
rule %r/@?[(){}\[\]]/, Punctuation
|
159
|
+
|
160
|
+
rule symbol, Name
|
161
|
+
end
|
162
|
+
|
163
|
+
state :string do
|
164
|
+
rule %r/"/, Str::Double, :pop!
|
165
|
+
rule %r/\\(u\h{4}|U\h{6})/, Str::Escape
|
166
|
+
rule %r/\\./, Str::Escape
|
167
|
+
rule %r/[^"\\]+/, Str::Double
|
168
|
+
end
|
169
|
+
|
170
|
+
state :function do
|
171
|
+
rule %r/[\)]/, Punctuation, :pop!
|
172
|
+
|
173
|
+
rule symbol do |m|
|
174
|
+
case m[0]
|
175
|
+
when "quote"
|
176
|
+
token Keyword
|
177
|
+
goto :quote
|
178
|
+
when "quasiquote"
|
179
|
+
token Keyword
|
180
|
+
goto :quasiquote
|
181
|
+
else
|
182
|
+
token name_token(m[0])
|
183
|
+
goto :root
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
mixin :root
|
188
|
+
end
|
189
|
+
|
190
|
+
state :quote do
|
191
|
+
rule %r/[(\[{]/, Punctuation, :push
|
192
|
+
rule %r/[)\]}]/, Punctuation, :pop!
|
193
|
+
rule symbol, Str::Escape
|
194
|
+
mixin :root
|
195
|
+
end
|
196
|
+
|
197
|
+
state :quasiquote do
|
198
|
+
rule %r/(,)(\()/ do
|
199
|
+
groups Operator, Punctuation
|
200
|
+
push :function
|
201
|
+
end
|
202
|
+
rule %r/(\()(\s*)(unquote)(\s+)(\()/ do
|
203
|
+
groups Punctuation, Text, Keyword, Text, Punctuation
|
204
|
+
push :function
|
205
|
+
end
|
206
|
+
|
207
|
+
rule %r/(,)(#{symbol})/ do
|
208
|
+
groups Operator, Name
|
209
|
+
end
|
210
|
+
rule %r/(\()(\s*)(unquote)(\s+)(#{symbol})/ do
|
211
|
+
groups Punctuation, Text, Keyword, Text, Name
|
212
|
+
end
|
213
|
+
|
214
|
+
mixin :quote
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
@@ -19,6 +19,8 @@ module Rouge
|
|
19
19
|
mimetypes 'application/javascript', 'application/x-javascript',
|
20
20
|
'text/javascript', 'text/x-javascript'
|
21
21
|
|
22
|
+
# Pseudo-documentation: https://stackoverflow.com/questions/1661197/what-characters-are-valid-for-javascript-variable-names
|
23
|
+
|
22
24
|
def self.detect?(text)
|
23
25
|
return 1 if text.shebang?('node')
|
24
26
|
return 1 if text.shebang?('jsc')
|
@@ -138,7 +140,7 @@ module Rouge
|
|
138
140
|
end
|
139
141
|
|
140
142
|
def self.id_regex
|
141
|
-
/[$
|
143
|
+
/[\p{L}\p{Nl}$_][\p{Word}]*/io
|
142
144
|
end
|
143
145
|
|
144
146
|
id = self.id_regex
|
@@ -160,6 +162,10 @@ module Rouge
|
|
160
162
|
push :template_string
|
161
163
|
end
|
162
164
|
|
165
|
+
# special case for the safe navigation operator ?.
|
166
|
+
# so that we don't start detecting a ternary expr
|
167
|
+
rule %r/[?][.]/, Punctuation
|
168
|
+
|
163
169
|
rule %r/[?]/ do
|
164
170
|
token Punctuation
|
165
171
|
push :ternary
|
@@ -263,9 +269,11 @@ module Rouge
|
|
263
269
|
|
264
270
|
# template strings
|
265
271
|
state :template_string do
|
266
|
-
rule %r
|
272
|
+
rule %r/[$]{/, Punctuation, :template_string_expr
|
267
273
|
rule %r/`/, Str::Double, :pop!
|
268
|
-
rule %r
|
274
|
+
rule %r/\\[$`]/, Str::Escape
|
275
|
+
rule %r/[^$`\\]+/, Str::Double
|
276
|
+
rule %r/[\\$]/, Str::Double
|
269
277
|
end
|
270
278
|
|
271
279
|
state :template_string_expr do
|
data/lib/rouge/lexers/jinja.rb
CHANGED
@@ -40,6 +40,17 @@ module Rouge
|
|
40
40
|
rule %r/{#/, Comment, :comment
|
41
41
|
rule %r/##.*/, Comment
|
42
42
|
|
43
|
+
# Raw and verbatim
|
44
|
+
rule %r/({%-?)(\s*)(raw|verbatim)(\s*)(-?%})/ do |m|
|
45
|
+
groups Comment::Preproc, Text, Keyword, Text, Comment::Preproc
|
46
|
+
case m[3]
|
47
|
+
when "raw"
|
48
|
+
push :raw
|
49
|
+
when "verbatim"
|
50
|
+
push :verbatim
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
43
54
|
# Statements
|
44
55
|
rule %r/\{\%/ do
|
45
56
|
token Comment::Preproc
|
@@ -114,11 +125,6 @@ module Rouge
|
|
114
125
|
end
|
115
126
|
|
116
127
|
state :statement do
|
117
|
-
rule %r/(raw|verbatim)(\s+)(\%\})/ do
|
118
|
-
groups Keyword, Text, Comment::Preproc
|
119
|
-
goto :raw
|
120
|
-
end
|
121
|
-
|
122
128
|
rule %r/(\w+\.?)/ do |m|
|
123
129
|
if self.class.keywords.include?(m[0])
|
124
130
|
groups Keyword
|
@@ -142,12 +148,21 @@ module Rouge
|
|
142
148
|
end
|
143
149
|
|
144
150
|
state :raw do
|
145
|
-
rule %r
|
151
|
+
rule %r/({%-?)(\s*)(endraw)(\s*)(-?%})/ do
|
146
152
|
groups Comment::Preproc, Text, Keyword, Text, Comment::Preproc
|
147
153
|
pop!
|
148
154
|
end
|
155
|
+
rule %r/[^{]+/, Text
|
156
|
+
rule %r/{/, Text
|
157
|
+
end
|
149
158
|
|
150
|
-
|
159
|
+
state :verbatim do
|
160
|
+
rule %r/({%-?)(\s*)(endverbatim)(\s*)(-?%})/ do
|
161
|
+
groups Comment::Preproc, Text, Keyword, Text, Comment::Preproc
|
162
|
+
pop!
|
163
|
+
end
|
164
|
+
rule %r/[^{]+/, Text
|
165
|
+
rule %r/{/, Text
|
151
166
|
end
|
152
167
|
end
|
153
168
|
end
|
data/lib/rouge/lexers/jsl.rb
CHANGED
data/lib/rouge/lexers/jsonnet.rb
CHANGED
@@ -126,6 +126,7 @@ module Rouge
|
|
126
126
|
|
127
127
|
state :string do
|
128
128
|
rule %r/\\([\\\/bfnrt]|(u[0-9a-fA-F]{4}))/, Str::Escape
|
129
|
+
rule %r/\\./, Str::Escape
|
129
130
|
end
|
130
131
|
|
131
132
|
state :string_double do
|
@@ -137,15 +138,15 @@ module Rouge
|
|
137
138
|
|
138
139
|
state :string_single do
|
139
140
|
mixin :string
|
140
|
-
rule %r/\\'/, Str::Escape
|
141
141
|
rule %r/'/, Str, :pop!
|
142
142
|
rule %r/[^\\']+/, Str
|
143
143
|
end
|
144
144
|
|
145
145
|
state :string_block do
|
146
146
|
mixin :string
|
147
|
-
rule %r
|
148
|
-
rule %r
|
147
|
+
rule %r/[|][|][|]/, Str, :pop!
|
148
|
+
rule %r/[^|\\]+/, Str
|
149
|
+
rule %r/[|]/, Str
|
149
150
|
end
|
150
151
|
end
|
151
152
|
end
|
data/lib/rouge/lexers/jsp.rb
CHANGED
data/lib/rouge/lexers/julia.rb
CHANGED
@@ -11,6 +11,8 @@ module Rouge
|
|
11
11
|
filenames '*.jl'
|
12
12
|
mimetypes 'text/x-julia', 'application/x-julia'
|
13
13
|
|
14
|
+
# Documentation: https://docs.julialang.org/en/v1/manual/variables/#Allowed-Variable-Names-1
|
15
|
+
|
14
16
|
def self.detect?(text)
|
15
17
|
return true if text.shebang? 'julia'
|
16
18
|
end
|
@@ -252,13 +254,13 @@ module Rouge
|
|
252
254
|
|
253
255
|
|
254
256
|
state :funcname do
|
255
|
-
rule %r/[
|
257
|
+
rule %r/[\p{L}\p{Nl}\p{S}_][\p{Word}\p{S}\p{Po}!]*/, Name::Function, :pop!
|
256
258
|
rule %r/\([^\s\w{]{1,2}\)/, Operator, :pop!
|
257
259
|
rule %r/[^\s\w{]{1,2}/, Operator, :pop!
|
258
260
|
end
|
259
261
|
|
260
262
|
state :typename do
|
261
|
-
rule %r/[
|
263
|
+
rule %r/[\p{L}\p{Nl}\p{S}_][\p{Word}\p{S}\p{Po}!]*/, Name::Class, :pop!
|
262
264
|
end
|
263
265
|
|
264
266
|
state :stringescape do
|
data/lib/rouge/lexers/kotlin.rb
CHANGED
@@ -53,7 +53,7 @@ module Rouge
|
|
53
53
|
groups Keyword::Declaration, Text
|
54
54
|
push :property
|
55
55
|
end
|
56
|
-
rule %r'(return|continue|break|this|super)(@#{name})
|
56
|
+
rule %r'(return|continue|break|this|super)(@#{name})?\b' do
|
57
57
|
groups Keyword, Name::Decorator
|
58
58
|
end
|
59
59
|
rule %r'\bfun\b', Keyword
|
@@ -65,6 +65,9 @@ module Rouge
|
|
65
65
|
rule %r'/[*].*[*]/', Comment::Multiline # single line block comment
|
66
66
|
rule %r'/[*].*', Comment::Multiline, :comment # multiline block comment
|
67
67
|
rule %r'\n', Text
|
68
|
+
rule %r'(::)(class)' do
|
69
|
+
groups Operator, Keyword
|
70
|
+
end
|
68
71
|
rule %r'::|!!|\?[:.]', Operator
|
69
72
|
rule %r"(\.\.)", Operator
|
70
73
|
# Number literals
|
@@ -130,9 +133,10 @@ module Rouge
|
|
130
133
|
end
|
131
134
|
|
132
135
|
state :comment do
|
133
|
-
rule %r'
|
134
|
-
rule %r'
|
135
|
-
rule %r'
|
136
|
+
rule %r'/[*]', Comment::Multiline, :comment
|
137
|
+
rule %r'[*]/', Comment::Multiline, :pop!
|
138
|
+
rule %r'[^/*]+', Comment::Multiline
|
139
|
+
rule %r'[/*]', Comment::Multiline
|
136
140
|
end
|
137
141
|
end
|
138
142
|
end
|
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
|
@@ -107,9 +110,10 @@ module Rouge
|
|
107
110
|
|
108
111
|
rule %r/(__(END|DATA)__)\b/, Comment::Preproc, :end_part
|
109
112
|
rule %r/\$\^[ADEFHILMOPSTWX]/, Name::Variable::Global
|
110
|
-
rule %r/\$[\\"'\[\]&`+*.,;=%~?@$!<>(
|
113
|
+
rule %r/\$[\\"'\[\]&`+*.,;=%~?@$!<>(^\|\/_-](?!\w)/, Name::Variable::Global
|
114
|
+
rule %r/[$@%&*][$@%&*#_]*(?=[a-z{\[;])/i, Name::Variable, :varname
|
115
|
+
|
111
116
|
rule %r/[-+\/*%=<>&^\|!\\~]=?/, Operator
|
112
|
-
rule %r/[$@%#]+/, Name::Variable, :varname
|
113
117
|
|
114
118
|
rule %r/0_?[0-7]+(_[0-7]+)*/, Num::Oct
|
115
119
|
rule %r/0x[0-9A-Fa-f]+(_[0-9A-Fa-f]+)*/, Num::Hex
|
@@ -142,6 +146,13 @@ module Rouge
|
|
142
146
|
rule %r/.*?\n/, Str::Interpol
|
143
147
|
end
|
144
148
|
|
149
|
+
state :fat_comma do
|
150
|
+
rule %r/#.*/, Comment::Single
|
151
|
+
rule %r/\w+/, Str
|
152
|
+
rule %r/\s+/, Text
|
153
|
+
rule %r/=>/, Operator, :pop!
|
154
|
+
end
|
155
|
+
|
145
156
|
state :name_common do
|
146
157
|
rule %r/\w+::/, Name::Namespace
|
147
158
|
rule %r/[\w:]+/, Name::Variable, :pop!
|
@@ -149,8 +160,9 @@ module Rouge
|
|
149
160
|
|
150
161
|
state :varname do
|
151
162
|
rule %r/\s+/, Text
|
152
|
-
rule %r
|
153
|
-
rule %r
|
163
|
+
rule %r/[{\[]/, Punctuation, :pop! # hash syntax
|
164
|
+
rule %r/[),]/, Punctuation, :pop! # arg specifier
|
165
|
+
rule %r/[;]/, Punctuation, :pop! # postfix
|
154
166
|
mixin :name_common
|
155
167
|
end
|
156
168
|
|
@@ -178,16 +190,24 @@ module Rouge
|
|
178
190
|
end
|
179
191
|
|
180
192
|
state :sq do
|
181
|
-
rule %r/\\[']/, Str::Escape
|
193
|
+
rule %r/\\[\\']/, Str::Escape
|
182
194
|
rule %r/[^\\']+/, Str::Single
|
183
195
|
rule %r/'/, Punctuation, :pop!
|
196
|
+
rule %r/\\/, Str::Single
|
184
197
|
end
|
185
198
|
|
186
199
|
state :dq do
|
187
200
|
mixin :string_intp
|
188
|
-
rule %r/\\[\\
|
201
|
+
rule %r/\\[\\tnrabefluLUE"$@]/, Str::Escape
|
202
|
+
rule %r/\\0\d{2}/, Str::Escape
|
203
|
+
rule %r/\\o\{\d+\}/, Str::Escape
|
204
|
+
rule %r/\\x\h{2}/, Str::Escape
|
205
|
+
rule %r/\\x\{\h+\}/, Str::Escape
|
206
|
+
rule %r/\\c./, Str::Escape
|
207
|
+
rule %r/\\N\{[^\}]+\}/, Str::Escape
|
189
208
|
rule %r/[^\\"]+?/, Str::Double
|
190
209
|
rule %r/"/, Punctuation, :pop!
|
210
|
+
rule %r/\\/, Str::Escape
|
191
211
|
end
|
192
212
|
|
193
213
|
state :bq do
|