rouge 1.11.0 → 1.11.1
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 +8 -0
- data/lib/rouge/cli.rb +3 -3
- data/lib/rouge/demos/cfscript +18 -0
- data/lib/rouge/demos/kotlin +3 -0
- data/lib/rouge/demos/pascal +14 -0
- data/lib/rouge/guesser.rb +46 -0
- data/lib/rouge/guessers/filename.rb +25 -0
- data/lib/rouge/guessers/glob_mapping.rb +46 -0
- data/lib/rouge/guessers/mimetype.rb +14 -0
- data/lib/rouge/guessers/modeline.rb +42 -0
- data/lib/rouge/guessers/source.rb +39 -0
- data/lib/rouge/lexer.rb +11 -85
- data/lib/rouge/lexers/cfscript.rb +153 -0
- data/lib/rouge/lexers/d.rb +1 -1
- data/lib/rouge/lexers/groovy.rb +8 -4
- data/lib/rouge/lexers/http.rb +3 -3
- data/lib/rouge/lexers/javascript.rb +16 -1
- data/lib/rouge/lexers/kotlin.rb +84 -0
- data/lib/rouge/lexers/pascal.rb +66 -0
- data/lib/rouge/lexers/praat.rb +107 -100
- data/lib/rouge/theme.rb +5 -5
- data/lib/rouge/themes/gruvbox.rb +167 -0
- data/lib/rouge/version.rb +1 -1
- metadata +15 -3
- data/lib/rouge/formatters/html_wrapper.rb +0 -11
data/lib/rouge/lexers/d.rb
CHANGED
data/lib/rouge/lexers/groovy.rb
CHANGED
@@ -57,10 +57,14 @@ module Rouge
|
|
57
57
|
rule /package\b/, Keyword::Namespace, :import
|
58
58
|
rule /import\b/, Keyword::Namespace, :import
|
59
59
|
|
60
|
-
|
61
|
-
rule /
|
62
|
-
rule
|
63
|
-
|
60
|
+
# TODO: highlight backslash escapes
|
61
|
+
rule /""".*?"""/m, Str::Double
|
62
|
+
rule /'''.*?'''/m, Str::Single
|
63
|
+
|
64
|
+
rule /"(\\.|\\\n|.)*?"/, Str::Double
|
65
|
+
rule /'(\\.|\\\n|.)*?'/, Str::Single
|
66
|
+
rule %r(\$/(\$.|.)*?/\$)m, Str
|
67
|
+
rule %r(/(\\.|\\\n|.)*?/), Str
|
64
68
|
rule /'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'/, Str::Char
|
65
69
|
rule /(\.)([a-zA-Z_][a-zA-Z0-9_]*)/ do
|
66
70
|
groups Operator, Name::Attribute
|
data/lib/rouge/lexers/http.rb
CHANGED
@@ -7,8 +7,8 @@ module Rouge
|
|
7
7
|
title "HTTP"
|
8
8
|
desc 'http requests and responses'
|
9
9
|
|
10
|
-
def self.
|
11
|
-
@
|
10
|
+
def self.http_methods
|
11
|
+
@http_methods ||= %w(GET POST PUT DELETE HEAD OPTIONS TRACE PATCH)
|
12
12
|
end
|
13
13
|
|
14
14
|
def content_lexer
|
@@ -24,7 +24,7 @@ module Rouge
|
|
24
24
|
state :root do
|
25
25
|
# request
|
26
26
|
rule %r(
|
27
|
-
(#{HTTP.
|
27
|
+
(#{HTTP.http_methods.join('|')})([ ]+) # method
|
28
28
|
([^ ]+)([ ]+) # path
|
29
29
|
(HTTPS?)(/)(1[.][01])(\r?\n|$) # http version
|
30
30
|
)ox do
|
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
module Rouge
|
4
4
|
module Lexers
|
5
|
+
# IMPORTANT NOTICE:
|
6
|
+
#
|
7
|
+
# Please do not copy this lexer and open a pull request
|
8
|
+
# for a new language. It will not get merged, you will
|
9
|
+
# be unhappy, and kittens will cry.
|
10
|
+
#
|
5
11
|
class Javascript < RegexLexer
|
6
12
|
title "JavaScript"
|
7
13
|
desc "JavaScript, the browser scripting language"
|
@@ -33,7 +39,10 @@ module Rouge
|
|
33
39
|
goto :regex
|
34
40
|
end
|
35
41
|
|
36
|
-
rule /[{]
|
42
|
+
rule /[{]/ do
|
43
|
+
token Punctuation
|
44
|
+
goto :object
|
45
|
+
end
|
37
46
|
|
38
47
|
rule //, Text, :pop!
|
39
48
|
end
|
@@ -177,6 +186,12 @@ module Rouge
|
|
177
186
|
# object literals
|
178
187
|
state :object do
|
179
188
|
mixin :comments_and_whitespace
|
189
|
+
|
190
|
+
rule /[{]/ do
|
191
|
+
token Punctuation
|
192
|
+
push
|
193
|
+
end
|
194
|
+
|
180
195
|
rule /[}]/ do
|
181
196
|
token Punctuation
|
182
197
|
goto :statement
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
|
3
|
+
module Rouge
|
4
|
+
module Lexers
|
5
|
+
class Kotlin < RegexLexer
|
6
|
+
title "Kotlin"
|
7
|
+
desc "Kotlin <http://kotlinlang.org>"
|
8
|
+
|
9
|
+
tag 'kotlin'
|
10
|
+
filenames '*.kt'
|
11
|
+
mimetypes 'text/x-kotlin'
|
12
|
+
|
13
|
+
keywords = %w(
|
14
|
+
abstract annotation as break by catch class companion const
|
15
|
+
constructor continue crossinline do dynamic else enum
|
16
|
+
external false final finally for fun get if import in infix
|
17
|
+
inline inner interface internal is lateinit noinline null
|
18
|
+
object open operator out override package private protected
|
19
|
+
public reified return sealed set super tailrec this throw
|
20
|
+
true try typealias typeof val var vararg when where while
|
21
|
+
yield
|
22
|
+
)
|
23
|
+
|
24
|
+
name = %r'@?[_\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Nl}][\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Nl}\p{Nd}\p{Pc}\p{Cf}\p{Mn}\p{Mc}]*'
|
25
|
+
|
26
|
+
id = %r'(#{name}|`#{name}`)'
|
27
|
+
|
28
|
+
state :root do
|
29
|
+
rule %r'^\s*\[.*?\]', Name::Attribute
|
30
|
+
rule %r'[^\S\n]+', Text
|
31
|
+
rule %r'\\\n', Text # line continuation
|
32
|
+
rule %r'//.*?\n', Comment::Single
|
33
|
+
rule %r'/[*].*?[*]/'m, Comment::Multiline
|
34
|
+
rule %r'\n', Text
|
35
|
+
rule %r'::|!!|\?[:.]', Operator
|
36
|
+
rule %r"(\.\.)", Operator
|
37
|
+
rule %r'[~!%^&*()+=|\[\]:;,.<>/?-]', Punctuation
|
38
|
+
rule %r'[{}]', Punctuation
|
39
|
+
rule %r'@"(""|[^"])*"'m, Str
|
40
|
+
rule %r'""".*?"""'m, Str
|
41
|
+
rule %r'"(\\\\|\\"|[^"\n])*["\n]'m, Str
|
42
|
+
rule %r"'\\.'|'[^\\]'", Str::Char
|
43
|
+
rule %r"[0-9](\.[0-9]+)?([eE][+-][0-9]+)?[flFL]?|0[xX][0-9a-fA-F]+[Ll]?", Num
|
44
|
+
rule %r'(class)(\s+)(object)' do
|
45
|
+
groups Keyword, Text, Keyword
|
46
|
+
end
|
47
|
+
rule %r'(class|data\s+class|interface|object)(\s+)' do
|
48
|
+
groups Keyword::Declaration, Text
|
49
|
+
push :class
|
50
|
+
end
|
51
|
+
rule %r'(package|import)(\s+)' do
|
52
|
+
groups Keyword, Text
|
53
|
+
push :package
|
54
|
+
end
|
55
|
+
rule %r'(val|var)(\s+)' do
|
56
|
+
groups Keyword::Declaration, Text
|
57
|
+
push :property
|
58
|
+
end
|
59
|
+
rule %r'(fun)(\s+)' do
|
60
|
+
groups Keyword, Text
|
61
|
+
push :function
|
62
|
+
end
|
63
|
+
rule /(?:#{keywords.join('|')})\b/, Keyword
|
64
|
+
rule id, Name
|
65
|
+
end
|
66
|
+
|
67
|
+
state :package do
|
68
|
+
rule /\S+/, Name::Namespace, :pop!
|
69
|
+
end
|
70
|
+
|
71
|
+
state :class do
|
72
|
+
rule id, Name::Class, :pop!
|
73
|
+
end
|
74
|
+
|
75
|
+
state :property do
|
76
|
+
rule id, Name::Property, :pop!
|
77
|
+
end
|
78
|
+
|
79
|
+
state :function do
|
80
|
+
rule id, Name::Function, :pop!
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
|
3
|
+
module Rouge
|
4
|
+
module Lexers
|
5
|
+
class Pascal < RegexLexer
|
6
|
+
tag 'pascal'
|
7
|
+
title "Pascal"
|
8
|
+
desc 'a procedural programming language commonly used as a teaching language.'
|
9
|
+
filenames '*.pas'
|
10
|
+
|
11
|
+
mimetypes 'text/x-pascal'
|
12
|
+
|
13
|
+
id = /@?[_a-z]\w*/i
|
14
|
+
|
15
|
+
keywords = %w(
|
16
|
+
absolute abstract all and and_then array as asm assembler attribute
|
17
|
+
begin bindable case class const constructor delay destructor div do
|
18
|
+
downto else end except exit export exports external far file finalization
|
19
|
+
finally for forward function goto if implementation import in inc index
|
20
|
+
inherited initialization inline interface interrupt is label library
|
21
|
+
message mod module near nil not object of on only operator or or_else
|
22
|
+
otherwise out overload override packed pascal pow private procedure program
|
23
|
+
property protected public published qualified raise read record register
|
24
|
+
repeat resident resourcestring restricted safecall segment set shl shr
|
25
|
+
stdcall stored string then threadvar to try type unit until uses value var
|
26
|
+
view virtual while with write writeln xor
|
27
|
+
)
|
28
|
+
|
29
|
+
keywords_type = %w(
|
30
|
+
ansichar ansistring bool boolean byte bytebool cardinal char comp currency
|
31
|
+
double dword extended int64 integer iunknown longbool longint longword pansichar
|
32
|
+
pansistring pbool pboolean pbyte pbytearray pcardinal pchar pcomp pcurrency
|
33
|
+
pdate pdatetime pdouble pdword pextended phandle pint64 pinteger plongint plongword
|
34
|
+
pointer ppointer pshortint pshortstring psingle psmallint pstring pvariant pwidechar
|
35
|
+
pwidestring pword pwordarray pwordbool real real48 shortint shortstring single
|
36
|
+
smallint string tclass tdate tdatetime textfile thandle tobject ttime variant
|
37
|
+
widechar widestring word wordbool
|
38
|
+
)
|
39
|
+
|
40
|
+
state :whitespace do
|
41
|
+
# Spaces
|
42
|
+
rule /\s+/m, Text
|
43
|
+
# // Comments
|
44
|
+
rule %r((//).*$\n?), Comment::Single
|
45
|
+
# -- Comments
|
46
|
+
rule %r((--).*$\n?), Comment::Single
|
47
|
+
# (* Comments *)
|
48
|
+
rule %r(\(\*.*?\*\))m, Comment::Multiline
|
49
|
+
# { Comments }
|
50
|
+
rule %r(\{.*?\})m, Comment::Multiline
|
51
|
+
end
|
52
|
+
|
53
|
+
state :root do
|
54
|
+
mixin :whitespace
|
55
|
+
|
56
|
+
rule %r{((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?}, Num
|
57
|
+
rule %r{[~!@#\$%\^&\*\(\)\+`\-={}\[\]:;<>\?,\.\/\|\\]}, Punctuation
|
58
|
+
rule %r{'([^']|'')*'}, Str
|
59
|
+
rule /(true|false|nil)\b/i, Name::Builtin
|
60
|
+
rule /\b(#{keywords.join('|')})\b/i, Keyword
|
61
|
+
rule /\b(#{keywords_type.join('|')})\b/i, Keyword::Type
|
62
|
+
rule id, Name
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/lib/rouge/lexers/praat.rb
CHANGED
@@ -16,7 +16,7 @@ module Rouge
|
|
16
16
|
|
17
17
|
keywords = %w(
|
18
18
|
if then else elsif elif endif fi for from to endfor endproc while
|
19
|
-
endwhile repeat until select plus minus demo assert stopwatch
|
19
|
+
endwhile repeat until select plus minus demo assert stopwatch
|
20
20
|
nocheck nowarn noprogress editor endeditor clearinfo
|
21
21
|
)
|
22
22
|
|
@@ -39,7 +39,7 @@ module Rouge
|
|
39
39
|
endSendPraat endsWith erb erbToHertz erf erfc exitScript exp
|
40
40
|
extractNumber fileReadable fisherP fisherQ floor gaussP gaussQ
|
41
41
|
hertzToBark hertzToErb hertzToMel hertzToSemitones imax imin
|
42
|
-
incompleteBeta incompleteGammaP index index_regex invBinomialP
|
42
|
+
incompleteBeta incompleteGammaP index index_regex integer invBinomialP
|
43
43
|
invBinomialQ invChiSquareQ invFisherQ invGaussQ invSigmoid invStudentQ
|
44
44
|
length ln lnBeta lnGamma log10 log2 max melToHertz min minusObject
|
45
45
|
natural number numberOfColumns numberOfRows numberOfSelected
|
@@ -47,10 +47,10 @@ module Rouge
|
|
47
47
|
phonToDifferenceLimens plusObject positive randomBinomial randomGauss
|
48
48
|
randomInteger randomPoisson randomUniform real readFile removeObject
|
49
49
|
rindex rindex_regex round runScript runSystem runSystem_nocheck
|
50
|
-
selectObject selected semitonesToHertz sentencetext sigmoid
|
51
|
-
sincpi sinh soundPressureToPhon sqrt startsWith studentP
|
52
|
-
tanh variableExists word writeFile writeFileLine
|
53
|
-
writeInfoLine
|
50
|
+
selectObject selected semitonesToHertz sentence sentencetext sigmoid
|
51
|
+
sin sinc sincpi sinh soundPressureToPhon sqrt startsWith studentP
|
52
|
+
studentQ tan tanh text variableExists word writeFile writeFileLine
|
53
|
+
writeInfo writeInfoLine
|
54
54
|
)
|
55
55
|
|
56
56
|
functions_array = %w(
|
@@ -62,29 +62,31 @@ module Rouge
|
|
62
62
|
BarkFilter BarkSpectrogram CCA Categories Cepstrogram Cepstrum
|
63
63
|
Cepstrumc ChebyshevSeries ClassificationTable Cochleagram Collection
|
64
64
|
ComplexSpectrogram Configuration Confusion ContingencyTable Corpus
|
65
|
-
Correlation Covariance CrossCorrelationTable
|
66
|
-
DataModeler Diagonalizer Discriminant
|
67
|
-
Distributions DurationTier EEG ERP ERPTier
|
68
|
-
EditDistanceTable Eigen Excitation Excitations
|
69
|
-
FeatureWeights FileInMemory FilesInMemory Formant
|
70
|
-
FormantGrid FormantModeler FormantPoint FormantTier
|
71
|
-
HMM_Observation HMM_ObservationSequence HMM_State
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
65
|
+
Correlation Covariance CrossCorrelationTable CrossCorrelationTableList
|
66
|
+
CrossCorrelationTables DTW DataModeler Diagonalizer Discriminant
|
67
|
+
Dissimilarity Distance Distributions DurationTier EEG ERP ERPTier
|
68
|
+
EditCostsTable EditDistanceTable Eigen Excitation Excitations
|
69
|
+
ExperimentMFC FFNet FeatureWeights FileInMemory FilesInMemory Formant
|
70
|
+
FormantFilter FormantGrid FormantModeler FormantPoint FormantTier
|
71
|
+
GaussianMixture HMM HMM_Observation HMM_ObservationSequence HMM_State
|
72
|
+
HMM_StateSequence HMMObservation HMMObservationSequence HMMState
|
73
|
+
HMMStateSequence Harmonicity ISpline Index Intensity IntensityTier
|
74
|
+
IntervalTier KNN KlattGrid KlattTable LFCC LPC Label LegendreSeries
|
75
|
+
LinearRegression LogisticRegression LongSound Ltas MFCC MSpline ManPages
|
76
|
+
Manipulation Matrix MelFilter MelSpectrogram MixingMatrix Movie Network
|
77
|
+
OTGrammar OTHistory OTMulti PCA PairDistribution ParamCurve Pattern
|
78
|
+
Permutation Photo Pitch PitchModeler PitchTier PointProcess Polygon
|
79
|
+
Polynomial PowerCepstrogram PowerCepstrum Procrustes RealPoint RealTier
|
80
|
+
ResultsMFC Roots SPINET SSCP SVD Salience ScalarProduct Similarity
|
81
|
+
SimpleString SortedSetOfString Sound Speaker Spectrogram Spectrum
|
82
|
+
SpectrumTier SpeechSynthesizer SpellingChecker Strings StringsIndex
|
83
|
+
Table TableOfReal TextGrid TextInterval TextPoint TextTier Tier
|
84
|
+
Transition VocalTract VocalTractTier Weight WordList
|
84
85
|
)
|
85
86
|
|
86
87
|
variables_numeric = %w(
|
87
|
-
macintosh
|
88
|
+
all average e left macintosh mono pi praatVersion right stereo
|
89
|
+
undefined unix windows
|
88
90
|
)
|
89
91
|
|
90
92
|
variables_string = %w(
|
@@ -93,6 +95,10 @@ module Rouge
|
|
93
95
|
defaultDirectory
|
94
96
|
)
|
95
97
|
|
98
|
+
object_attributes = %w(
|
99
|
+
ncol nrow xmin ymin xmax ymax nx ny dx dy
|
100
|
+
)
|
101
|
+
|
96
102
|
state :root do
|
97
103
|
rule /(\s+)(#.*?$)/ do
|
98
104
|
groups Text, Comment::Single
|
@@ -107,6 +113,7 @@ module Rouge
|
|
107
113
|
|
108
114
|
mixin :function_call
|
109
115
|
|
116
|
+
rule /\b(?:select all)\b/, Keyword
|
110
117
|
rule /\b(?:#{keywords.join('|')})\b/, Keyword
|
111
118
|
|
112
119
|
rule /(\bform\b)(\s+)([^\n]+)/ do
|
@@ -132,51 +139,25 @@ module Rouge
|
|
132
139
|
|
133
140
|
rule /\b(?=[A-Z])/, Text, :command
|
134
141
|
rule /(\.{3}|[)(,\$])/, Punctuation
|
135
|
-
rule /./, Generic::Error
|
136
142
|
end
|
137
143
|
|
138
144
|
state :command do
|
139
145
|
rule /( ?[\w()-]+ ?)/, Keyword
|
140
|
-
|
141
|
-
rule /\.{3}/, Keyword, :old_arguments
|
142
|
-
rule /:/, Keyword, :comma_list
|
143
|
-
rule /[\s\n]/, Text, :pop!
|
144
|
-
end
|
146
|
+
mixin :string_interpolated
|
145
147
|
|
146
|
-
|
147
|
-
|
148
|
-
rule /\b(#{functions_array.join('|')})#(?=\s*[:(])/, Name::Function, :function
|
149
|
-
rule /\b(#{functions_numeric.join('|')})(?=\s*[:(])/, Name::Function, :function
|
150
|
-
end
|
151
|
-
|
152
|
-
state :old_arguments do
|
153
|
-
rule /\n/ do
|
154
|
-
token Text
|
148
|
+
rule /\.{3}/ do
|
149
|
+
token Keyword
|
155
150
|
pop!
|
156
|
-
|
151
|
+
push :old_arguments
|
157
152
|
end
|
158
153
|
|
159
|
-
mixin :function_call
|
160
|
-
mixin :operator
|
161
|
-
mixin :number
|
162
|
-
|
163
|
-
rule /"/, Literal::String, :string
|
164
|
-
rule /[^\n]/, Text
|
165
|
-
end
|
166
|
-
|
167
|
-
state :function do
|
168
|
-
rule /\s+/, Text
|
169
|
-
|
170
154
|
rule /:/ do
|
171
|
-
token
|
172
|
-
push :comma_list
|
173
|
-
end
|
174
|
-
|
175
|
-
rule /\s*\(/ do
|
176
|
-
token Punctuation
|
155
|
+
token Keyword
|
177
156
|
pop!
|
178
157
|
push :comma_list
|
179
158
|
end
|
159
|
+
|
160
|
+
rule /[\s\n]/, Text, :pop!
|
180
161
|
end
|
181
162
|
|
182
163
|
state :procedure_call do
|
@@ -184,10 +165,14 @@ module Rouge
|
|
184
165
|
|
185
166
|
rule /([\w.]+)(:|\s*\()/ do
|
186
167
|
groups Name::Function, Punctuation
|
187
|
-
|
168
|
+
pop!
|
188
169
|
end
|
189
170
|
|
190
|
-
rule /([\w.]+)
|
171
|
+
rule /([\w.]+)/ do
|
172
|
+
token Name::Function
|
173
|
+
pop!
|
174
|
+
push :old_arguments
|
175
|
+
end
|
191
176
|
end
|
192
177
|
|
193
178
|
state :procedure_definition do
|
@@ -204,16 +189,28 @@ module Rouge
|
|
204
189
|
end
|
205
190
|
end
|
206
191
|
|
192
|
+
state :function_call do
|
193
|
+
rule /\b(#{functions_string.join('|')})\$(?=\s*[:(])/, Name::Function, :function
|
194
|
+
rule /\b(#{functions_array.join('|')})#(?=\s*[:(])/, Name::Function, :function
|
195
|
+
rule /\b(#{functions_numeric.join('|')})(?=\s*[:(])/, Name::Function, :function
|
196
|
+
end
|
197
|
+
|
198
|
+
state :function do
|
199
|
+
rule /\s+/, Text
|
200
|
+
|
201
|
+
rule /(?::|\s*\()/ do
|
202
|
+
token Text
|
203
|
+
pop!
|
204
|
+
push :comma_list
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
207
208
|
state :comma_list do
|
208
209
|
rule /(\s*\n\s*)(\.{3})/ do
|
209
210
|
groups Text, Punctuation
|
210
211
|
end
|
211
212
|
|
212
|
-
rule /\s*
|
213
|
-
token Punctuation
|
214
|
-
pop!
|
215
|
-
pop! unless state? :root
|
216
|
-
end
|
213
|
+
rule /\s*[\])\n]/, Text, :pop!
|
217
214
|
|
218
215
|
rule /\s+/, Text
|
219
216
|
rule /"/, Literal::String, :string
|
@@ -224,9 +221,21 @@ module Rouge
|
|
224
221
|
mixin :operator
|
225
222
|
mixin :number
|
226
223
|
|
224
|
+
rule /[()]/, Text
|
227
225
|
rule /,/, Punctuation
|
228
226
|
end
|
229
227
|
|
228
|
+
state :old_arguments do
|
229
|
+
rule /\n/, Text, :pop!
|
230
|
+
|
231
|
+
mixin :variable_name
|
232
|
+
mixin :operator
|
233
|
+
mixin :number
|
234
|
+
|
235
|
+
rule /"/, Literal::String, :string
|
236
|
+
rule /[^\n]/, Text
|
237
|
+
end
|
238
|
+
|
230
239
|
state :number do
|
231
240
|
rule /\n/, Text, :pop!
|
232
241
|
rule /\b\d+(\.\d*)?([eE][-+]?\d+)?%?/, Literal::Number
|
@@ -237,43 +246,45 @@ module Rouge
|
|
237
246
|
mixin :number
|
238
247
|
|
239
248
|
rule /\b(?:#{variables_string.join('|')})\$/, Name::Builtin
|
240
|
-
rule /\b(?:#{variables_numeric.join('|')})\b/, Name::Builtin
|
249
|
+
rule /\b(?:#{variables_numeric.join('|')})(?!\$)\b/, Name::Builtin
|
241
250
|
|
242
|
-
rule /\b(Object|#{objects.join('|')})_
|
243
|
-
|
244
|
-
|
245
|
-
groups Name::Builtin, Literal::String::Interpol
|
246
|
-
push :object_attributes
|
247
|
-
push :string_interpolated
|
251
|
+
rule /\b(Object|#{objects.join('|')})_/ do
|
252
|
+
token Name::Builtin
|
253
|
+
push :object_reference
|
248
254
|
end
|
249
255
|
|
250
256
|
rule /\.?[a-z][a-zA-Z0-9_.]*(\$|#)?/, Text
|
251
|
-
rule /[\[\]]/,
|
252
|
-
|
257
|
+
rule /[\[\]]/, Text, :comma_list
|
258
|
+
mixin :string_interpolated
|
253
259
|
end
|
254
260
|
|
255
|
-
state :
|
256
|
-
|
257
|
-
rule /(
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
rule
|
262
|
-
|
263
|
-
|
264
|
-
|
261
|
+
state :object_reference do
|
262
|
+
mixin :string_interpolated
|
263
|
+
rule /([a-z][a-zA-Z0-9_]*|\d+)/, Name::Builtin
|
264
|
+
|
265
|
+
rule /\.(#{object_attributes.join('|')})\b/, Name::Builtin, :pop!
|
266
|
+
|
267
|
+
rule /\$/, Name::Builtin
|
268
|
+
rule /\[/, Text, :pop!
|
269
|
+
end
|
270
|
+
|
271
|
+
state :operator do
|
272
|
+
# This rule incorrectly matches === or +++++, which are not operators
|
273
|
+
rule /([+\/*<>=!-]=?|[&*|][&*|]?|\^|<>)/, Operator
|
274
|
+
rule /(?<![\w.])(and|or|not|div|mod)(?![\w.])/, Operator::Word
|
265
275
|
end
|
266
276
|
|
267
277
|
state :string_interpolated do
|
268
|
-
rule
|
269
|
-
rule /'/, Literal::String::Interpol, :pop!
|
278
|
+
rule /'[\._a-z][^\[\]'":]*(\[([\d,]+|"[\w\d,]+")\])?(:[0-9]+)?'/, Literal::String::Interpol
|
270
279
|
end
|
271
280
|
|
272
281
|
state :string_unquoted do
|
273
282
|
rule /\n\s*\.{3}/, Punctuation
|
274
283
|
rule /\n/, Text, :pop!
|
275
284
|
rule /\s/, Text
|
276
|
-
|
285
|
+
|
286
|
+
mixin :string_interpolated
|
287
|
+
|
277
288
|
rule /'/, Literal::String
|
278
289
|
rule /[^'\n]+/, Literal::String
|
279
290
|
end
|
@@ -281,12 +292,18 @@ module Rouge
|
|
281
292
|
state :string do
|
282
293
|
rule /\n\s*\.{3}/, Punctuation
|
283
294
|
rule /"/, Literal::String, :pop!
|
284
|
-
|
295
|
+
|
296
|
+
mixin :string_interpolated
|
297
|
+
|
285
298
|
rule /'/, Literal::String
|
286
299
|
rule /[^'"\n]+/, Literal::String
|
287
300
|
end
|
288
301
|
|
289
302
|
state :old_form do
|
303
|
+
rule /(\s+)(#.*?$)/ do
|
304
|
+
groups Text, Comment::Single
|
305
|
+
end
|
306
|
+
|
290
307
|
rule /\s+/, Text
|
291
308
|
|
292
309
|
rule /(optionmenu|choice)([ \t]+\S+:[ \t]+)/ do
|
@@ -294,11 +311,6 @@ module Rouge
|
|
294
311
|
push :number
|
295
312
|
end
|
296
313
|
|
297
|
-
rule /(option|button)([ \t]+)/ do
|
298
|
-
groups Keyword, Text
|
299
|
-
push :number
|
300
|
-
end
|
301
|
-
|
302
314
|
rule /(option|button)([ \t]+)/ do
|
303
315
|
groups Keyword, Text
|
304
316
|
push :string_unquoted
|
@@ -310,7 +322,7 @@ module Rouge
|
|
310
322
|
end
|
311
323
|
|
312
324
|
rule /(word)([ \t]+\S+[ \t]*)(\S+)?([ \t]+.*)?/ do
|
313
|
-
groups Keyword, Text, Literal::String,
|
325
|
+
groups Keyword, Text, Literal::String, Text
|
314
326
|
end
|
315
327
|
|
316
328
|
rule /(boolean)(\s+\S+\s*)(0|1|"?(?:yes|no)"?)/ do
|
@@ -330,11 +342,6 @@ module Rouge
|
|
330
342
|
rule /\bendform\b/, Keyword, :pop!
|
331
343
|
end
|
332
344
|
|
333
|
-
state :operator do
|
334
|
-
# This rule incorrectly matches === or +++++, which are not operators
|
335
|
-
rule /([+\/*<>=!-]=?|[&*|][&*|]?|\^|<>)/, Operator
|
336
|
-
rule /\b(and|or|not|div|mod)\b/, Operator::Word
|
337
|
-
end
|
338
345
|
end
|
339
346
|
end
|
340
347
|
end
|