rouge 3.30.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,99 +15,138 @@ module Rouge
15
15
  return true if text.shebang? 'praat'
16
16
  end
17
17
 
18
- keywords = %w(
19
- if then else elsif elif endif fi for from to endfor endproc while
20
- endwhile repeat until select plus minus demo assert stopwatch
21
- nocheck nowarn noprogress editor endeditor clearinfo
22
- )
23
-
24
- functions_string = %w(
25
- backslashTrigraphsToUnicode chooseDirectory chooseReadFile
26
- chooseWriteFile date demoKey do environment extractLine extractWord
27
- fixed info left mid percent readFile replace replace_regex right
28
- selected string unicodeToBackslashTrigraphs
29
- )
30
-
31
- functions_numeric = %w(
32
- abs appendFile appendFileLine appendInfo appendInfoLine arccos arccosh
33
- arcsin arcsinh arctan arctan2 arctanh barkToHertz beginPause
34
- beginSendPraat besselI besselK beta beta2 binomialP binomialQ boolean
35
- ceiling chiSquareP chiSquareQ choice comment cos cosh createDirectory
36
- deleteFile demoClicked demoClickedIn demoCommandKeyPressed
37
- demoExtraControlKeyPressed demoInput demoKeyPressed
38
- demoOptionKeyPressed demoShiftKeyPressed demoShow demoWaitForInput
39
- demoWindowTitle demoX demoY differenceLimensToPhon do editor endPause
40
- endSendPraat endsWith erb erbToHertz erf erfc exitScript exp
41
- extractNumber fileReadable fisherP fisherQ floor gaussP gaussQ hash
42
- hertzToBark hertzToErb hertzToMel hertzToSemitones imax imin
43
- incompleteBeta incompleteGammaP index index_regex integer invBinomialP
44
- invBinomialQ invChiSquareQ invFisherQ invGaussQ invSigmoid invStudentQ
45
- length ln lnBeta lnGamma log10 log2 max melToHertz min minusObject
46
- natural number numberOfColumns numberOfRows numberOfSelected
47
- objectsAreIdentical option optionMenu pauseScript
48
- phonToDifferenceLimens plusObject positive randomBinomial randomGauss
49
- randomInteger randomPoisson randomUniform real readFile removeObject
50
- rindex rindex_regex round runScript runSystem runSystem_nocheck
51
- selectObject selected semitonesToHertz sentence sentencetext sigmoid
52
- sin sinc sincpi sinh soundPressureToPhon sqrt startsWith studentP
53
- studentQ tan tanh text variableExists word writeFile writeFileLine
54
- writeInfo writeInfoLine
55
- )
56
-
57
- functions_array = %w(
58
- linear randomGauss randomInteger randomUniform zero
59
- )
60
-
61
- objects = %w(
62
- Activation AffineTransform AmplitudeTier Art Artword Autosegment
63
- BarkFilter BarkSpectrogram CCA Categories Cepstrogram Cepstrum
64
- Cepstrumc ChebyshevSeries ClassificationTable Cochleagram Collection
65
- ComplexSpectrogram Configuration Confusion ContingencyTable Corpus
66
- Correlation Covariance CrossCorrelationTable CrossCorrelationTableList
67
- CrossCorrelationTables DTW DataModeler Diagonalizer Discriminant
68
- Dissimilarity Distance Distributions DurationTier EEG ERP ERPTier
69
- EditCostsTable EditDistanceTable Eigen Excitation Excitations
70
- ExperimentMFC FFNet FeatureWeights FileInMemory FilesInMemory Formant
71
- FormantFilter FormantGrid FormantModeler FormantPoint FormantTier
72
- GaussianMixture HMM HMM_Observation HMM_ObservationSequence HMM_State
73
- HMM_StateSequence HMMObservation HMMObservationSequence HMMState
74
- HMMStateSequence Harmonicity ISpline Index Intensity IntensityTier
75
- IntervalTier KNN KlattGrid KlattTable LFCC LPC Label LegendreSeries
76
- LinearRegression LogisticRegression LongSound Ltas MFCC MSpline ManPages
77
- Manipulation Matrix MelFilter MelSpectrogram MixingMatrix Movie Network
78
- OTGrammar OTHistory OTMulti PCA PairDistribution ParamCurve Pattern
79
- Permutation Photo Pitch PitchModeler PitchTier PointProcess Polygon
80
- Polynomial PowerCepstrogram PowerCepstrum Procrustes RealPoint RealTier
81
- ResultsMFC Roots SPINET SSCP SVD Salience ScalarProduct Similarity
82
- SimpleString SortedSetOfString Sound Speaker Spectrogram Spectrum
83
- SpectrumTier SpeechSynthesizer SpellingChecker Strings StringsIndex
84
- Table TableOfReal TextGrid TextInterval TextPoint TextTier Tier
85
- Transition VocalTract VocalTractTier Weight WordList
86
- )
87
-
88
- variables_numeric = %w(
89
- all average e left macintosh mono pi praatVersion right stereo
90
- undefined unix windows
91
- )
92
-
93
- variables_string = %w(
94
- praatVersion tab shellDirectory homeDirectory
95
- preferencesDirectory newline temporaryDirectory
96
- defaultDirectory
97
- )
98
-
99
- object_attributes = %w(
100
- ncol nrow xmin ymin xmax ymax nx ny dx dy
101
- )
18
+ def self.keywords
19
+ @keywords ||= %w(
20
+ if then else elsif elif endif fi for from to endfor endproc while
21
+ endwhile repeat until select plus minus demo assert stopwatch
22
+ nocheck nowarn noprogress editor endeditor clearinfo
23
+ )
24
+ end
25
+
26
+ def self.functions_string
27
+ @functions_string ||= %w(
28
+ backslashTrigraphsToUnicode$ chooseDirectory$ chooseReadFile$
29
+ chooseWriteFile$ date$ demoKey$ do$ environment$ extractLine$ extractWord$
30
+ fixed$ info$ left$ mid$ percent$ readFile$ replace$ replace_regex$ right$
31
+ selected$ string$ unicodeToBackslashTrigraphs$
32
+ )
33
+ end
34
+
35
+ def self.functions_numeric
36
+ @functions_numeric ||= %w(
37
+ abs appendFile appendFileLine appendInfo appendInfoLine arccos arccosh
38
+ arcsin arcsinh arctan arctan2 arctanh barkToHertz beginPause
39
+ beginSendPraat besselI besselK beta beta2 binomialP binomialQ boolean
40
+ ceiling chiSquareP chiSquareQ choice comment cos cosh createDirectory
41
+ deleteFile demoClicked demoClickedIn demoCommandKeyPressed
42
+ demoExtraControlKeyPressed demoInput demoKeyPressed
43
+ demoOptionKeyPressed demoShiftKeyPressed demoShow demoWaitForInput
44
+ demoWindowTitle demoX demoY differenceLimensToPhon do editor endPause
45
+ endSendPraat endsWith erb erbToHertz erf erfc exitScript exp
46
+ extractNumber fileReadable fisherP fisherQ floor gaussP gaussQ hash
47
+ hertzToBark hertzToErb hertzToMel hertzToSemitones imax imin
48
+ incompleteBeta incompleteGammaP index index_regex integer invBinomialP
49
+ invBinomialQ invChiSquareQ invFisherQ invGaussQ invSigmoid invStudentQ
50
+ length ln lnBeta lnGamma log10 log2 max melToHertz min minusObject
51
+ natural number numberOfColumns numberOfRows numberOfSelected
52
+ objectsAreIdentical option optionMenu pauseScript
53
+ phonToDifferenceLimens plusObject positive randomBinomial randomGauss
54
+ randomInteger randomPoisson randomUniform real readFile removeObject
55
+ rindex rindex_regex round runScript runSystem runSystem_nocheck
56
+ selectObject selected semitonesToHertz sentence sentencetext sigmoid
57
+ sin sinc sincpi sinh soundPressureToPhon sqrt startsWith studentP
58
+ studentQ tan tanh text variableExists word writeFile writeFileLine
59
+ writeInfo writeInfoLine
60
+ )
61
+ end
62
+
63
+ def self.functions_array
64
+ @functions_array ||= %w(
65
+ linear# randomGauss# randomInteger# randomUniform# zero#
66
+ )
67
+ end
68
+
69
+ def self.functions_matrix
70
+ @functions_matrix ||= %w(
71
+ linear## mul## mul_fast## mul_metal## mul_nt## mul_tn## mul_tt## outer## peaks##
72
+ randomGamma## randomGauss## randomInteger## randomUniform## softmaxPerRow##
73
+ solve## transpose## zero##
74
+ )
75
+ end
76
+
77
+ def self.functions_string_vector
78
+ @functions_string_vector ||= %w(
79
+ empty$# fileNames$# folderNames$# readLinesFromFile$# splitByWhitespace$#
80
+ )
81
+ end
82
+
83
+ def self.functions_builtin
84
+ @functions_builtin ||=
85
+ self.functions_string |
86
+ self.functions_numeric |
87
+ self.functions_array |
88
+ self.functions_matrix |
89
+ self.functions_string_vector
90
+ end
91
+
92
+ def self.objects
93
+ @objects ||= %w(
94
+ Activation AffineTransform AmplitudeTier Art Artword Autosegment
95
+ BarkFilter BarkSpectrogram CCA Categories Cepstrogram Cepstrum
96
+ Cepstrumc ChebyshevSeries ClassificationTable Cochleagram Collection
97
+ ComplexSpectrogram Configuration Confusion ContingencyTable Corpus
98
+ Correlation Covariance CrossCorrelationTable CrossCorrelationTableList
99
+ CrossCorrelationTables DTW DataModeler Diagonalizer Discriminant
100
+ Dissimilarity Distance Distributions DurationTier EEG ERP ERPTier
101
+ EditCostsTable EditDistanceTable Eigen Excitation Excitations
102
+ ExperimentMFC FFNet FeatureWeights FileInMemory FilesInMemory Formant
103
+ FormantFilter FormantGrid FormantModeler FormantPoint FormantTier
104
+ GaussianMixture HMM HMM_Observation HMM_ObservationSequence HMM_State
105
+ HMM_StateSequence HMMObservation HMMObservationSequence HMMState
106
+ HMMStateSequence Harmonicity ISpline Index Intensity IntensityTier
107
+ IntervalTier KNN KlattGrid KlattTable LFCC LPC Label LegendreSeries
108
+ LinearRegression LogisticRegression LongSound Ltas MFCC MSpline ManPages
109
+ Manipulation Matrix MelFilter MelSpectrogram MixingMatrix Movie Network
110
+ OTGrammar OTHistory OTMulti PCA PairDistribution ParamCurve Pattern
111
+ Permutation Photo Pitch PitchModeler PitchTier PointProcess Polygon
112
+ Polynomial PowerCepstrogram PowerCepstrum Procrustes RealPoint RealTier
113
+ ResultsMFC Roots SPINET SSCP SVD Salience ScalarProduct Similarity
114
+ SimpleString SortedSetOfString Sound Speaker Spectrogram Spectrum
115
+ SpectrumTier SpeechSynthesizer SpellingChecker Strings StringsIndex
116
+ Table TableOfReal TextGrid TextInterval TextPoint TextTier Tier
117
+ Transition VocalTract VocalTractTier Weight WordList
118
+ )
119
+ end
120
+
121
+ def self.variables_numeric
122
+ @variables_numeric ||= %w(
123
+ all average e left macintosh mono pi praatVersion right stereo
124
+ undefined unix windows
125
+ )
126
+ end
127
+
128
+ def self.variables_string
129
+ @variables_string ||= %w(
130
+ praatVersion$ tab$ shellDirectory$ homeDirectory$
131
+ preferencesDirectory$ newline$ temporaryDirectory$
132
+ defaultDirectory$
133
+ )
134
+ end
135
+
136
+ def self.object_attributes
137
+ @object_attributes ||= %w(
138
+ ncol nrow xmin ymin xmax ymax nx ny dx dy
139
+ )
140
+ end
102
141
 
103
142
  state :root do
104
143
  rule %r/(\s+)(#.*?$)/ do
105
144
  groups Text, Comment::Single
106
145
  end
107
146
 
108
- rule %r/^#.*?$/, Comment::Single
109
- rule %r/;[^\n]*/, Comment::Single
110
- rule %r/\s+/, Text
147
+ rule %r/^#.*?$/, Comment::Single
148
+ rule %r/;[^\n]*/, Comment::Single
149
+ rule %r/\s+/, Text
111
150
 
112
151
  rule %r/(\bprocedure)(\s+)/ do
113
152
  groups Keyword, Text
@@ -119,12 +158,11 @@ module Rouge
119
158
  push :procedure_call
120
159
  end
121
160
 
122
- rule %r/@/, Name::Function, :procedure_call
161
+ rule %r/@/, Name::Function, :procedure_call
123
162
 
124
163
  mixin :function_call
125
164
 
126
165
  rule %r/\b(?:select all)\b/, Keyword
127
- rule %r/\b(?:#{keywords.join('|')})\b/, Keyword
128
166
 
129
167
  rule %r/(\bform\b)(\s+)([^\n]+)/ do
130
168
  groups Keyword, Text, Literal::String
@@ -142,13 +180,31 @@ module Rouge
142
180
 
143
181
  mixin :variable_name
144
182
  mixin :number
183
+ mixin :vector_literal
145
184
 
146
185
  rule %r/"/, Literal::String, :string
147
186
 
148
- rule %r/\b(?:#{objects.join('|')})(?=\s+\S+\n)/, Name::Class, :string_unquoted
187
+ rule %r/\b([A-Z][a-zA-Z0-9]+)(?=\s+\S+\n)/ do |m|
188
+ match = m[0]
189
+ if self.class.objects.include?(match)
190
+ token Name::Class
191
+ push :string_unquoted
192
+ else
193
+ token Keyword
194
+ end
195
+ end
149
196
 
150
197
  rule %r/\b(?=[A-Z])/, Text, :command
151
198
  rule %r/(\.{3}|[)(,\$])/, Punctuation
199
+
200
+ rule %r/[a_z]+/ do |m|
201
+ match = m[0]
202
+ if self.class.keywords.include?(match)
203
+ token Keyword
204
+ else
205
+ token Text
206
+ end
207
+ end
152
208
  end
153
209
 
154
210
  state :command do
@@ -167,7 +223,7 @@ module Rouge
167
223
  push :comma_list
168
224
  end
169
225
 
170
- rule %r/[\s]/, Text, :pop!
226
+ rule %r/[\s]/, Text, :pop!
171
227
  end
172
228
 
173
229
  state :procedure_call do
@@ -175,7 +231,7 @@ module Rouge
175
231
 
176
232
  rule %r/(:|\s*\()/, Punctuation, :pop!
177
233
 
178
- rule %r/'/, Name::Function
234
+ rule %r/'/, Name::Function
179
235
  rule %r/[^:\('\s]+/, Name::Function
180
236
 
181
237
  rule %r/(?=\s+)/ do
@@ -194,9 +250,17 @@ module Rouge
194
250
  end
195
251
 
196
252
  state :function_call do
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
253
+ rule %r/\b([a-z][a-zA-Z0-9_.]+)(\$#|##|\$|#)?(?=\s*[:(])/ do |m|
254
+ match = m[0]
255
+ if self.class.functions_builtin.include?(match)
256
+ token Name::Function
257
+ push :function
258
+ elsif self.class.keywords.include?(match)
259
+ token Keyword
260
+ else
261
+ token Operator::Word
262
+ end
263
+ end
200
264
  end
201
265
 
202
266
  state :function do
@@ -214,16 +278,17 @@ module Rouge
214
278
  groups Text, Punctuation
215
279
  end
216
280
 
217
- rule %r/\s*[\])\n]/, Text, :pop!
281
+ rule %r/\s*[\]\})\n]/, Text, :pop!
218
282
 
219
283
  rule %r/\s+/, Text
220
- rule %r/"/, Literal::String, :string
284
+ rule %r/"/, Literal::String, :string
221
285
  rule %r/\b(if|then|else|fi|endif)\b/, Keyword
222
286
 
223
287
  mixin :function_call
224
288
  mixin :variable_name
225
289
  mixin :operator
226
290
  mixin :number
291
+ mixin :vector_literal
227
292
 
228
293
  rule %r/[()]/, Text
229
294
  rule %r/,/, Punctuation
@@ -249,24 +314,47 @@ module Rouge
249
314
  mixin :operator
250
315
  mixin :number
251
316
 
252
- rule %r/\b(?:#{variables_string.join('|')})\$/, Name::Builtin
253
- rule %r/\b(?:#{variables_numeric.join('|')})(?!\$)\b/, Name::Builtin
317
+ rule %r/\b([A-Z][a-zA-Z0-9]+)_/ do |m|
318
+ match = m[1]
319
+ if (['Object'] | self.class.objects).include?(match)
320
+ token Name::Builtin
321
+ push :object_reference
322
+ else
323
+ token Name::Variable
324
+ end
325
+ end
254
326
 
255
- rule %r/\b(Object|#{objects.join('|')})_/ do
256
- token Name::Builtin
257
- push :object_reference
327
+ rule %r/\.?[a-z][a-zA-Z0-9_.]*(\$#|##|\$|#)?/ do |m|
328
+ match = m[0]
329
+ if self.class.variables_string.include?(match) ||
330
+ self.class.variables_numeric.include?(match)
331
+ token Name::Builtin
332
+ elsif self.class.keywords.include?(match)
333
+ token Keyword
334
+ else
335
+ token Name::Variable
336
+ end
258
337
  end
259
338
 
260
- rule %r/\.?[a-z][a-zA-Z0-9_.]*(\$|#)?/, Text
261
339
  rule %r/[\[\]]/, Text, :comma_list
262
340
  mixin :string_interpolated
263
341
  end
264
342
 
343
+ state :vector_literal do
344
+ rule %r/(\{)/, Text, :comma_list
345
+ end
346
+
265
347
  state :object_reference do
266
348
  mixin :string_interpolated
267
349
  rule %r/([a-z][a-zA-Z0-9_]*|\d+)/, Name::Builtin
268
350
 
269
- rule %r/\.(#{object_attributes.join('|')})\b/, Name::Builtin, :pop!
351
+ rule %r/\.([a-z]+)\b/ do |m|
352
+ match = m[1]
353
+ if self.class.object_attributes.include?(match)
354
+ token Name::Builtin
355
+ pop!
356
+ end
357
+ end
270
358
 
271
359
  rule %r/\$/, Name::Builtin
272
360
  rule %r/\[/, Text, :pop!
@@ -274,7 +362,7 @@ module Rouge
274
362
 
275
363
  state :operator do
276
364
  # This rule incorrectly matches === or +++++, which are not operators
277
- rule %r/([+\/*<>=!-]=?|[&*|][&*|]?|\^|<>)/, Operator
365
+ rule %r/([+\/*<>=!-]=?|[&*|][&*|]?|\^|<>)/, Operator
278
366
  rule %r/(?<![\w.])(and|or|not|div|mod)(?![\w.])/, Operator::Word
279
367
  end
280
368
 
@@ -284,23 +372,23 @@ module Rouge
284
372
 
285
373
  state :string_unquoted do
286
374
  rule %r/\n\s*\.{3}/, Punctuation
287
- rule %r/\n/, Text, :pop!
288
- rule %r/\s/, Text
375
+ rule %r/\n/, Text, :pop!
376
+ rule %r/\s/, Text
289
377
 
290
378
  mixin :string_interpolated
291
379
 
292
- rule %r/'/, Literal::String
293
- rule %r/[^'\n]+/, Literal::String
380
+ rule %r/'/, Literal::String
381
+ rule %r/[^'\n]+/, Literal::String
294
382
  end
295
383
 
296
384
  state :string do
297
385
  rule %r/\n\s*\.{3}/, Punctuation
298
- rule %r/"/, Literal::String, :pop!
386
+ rule %r/"/, Literal::String, :pop!
299
387
 
300
388
  mixin :string_interpolated
301
389
 
302
- rule %r/'/, Literal::String
303
- rule %r/[^'"\n]+/, Literal::String
390
+ rule %r/'/, Literal::String
391
+ rule %r/[^'"\n]+/, Literal::String
304
392
  end
305
393
 
306
394
  state :old_form do
@@ -345,7 +433,6 @@ module Rouge
345
433
 
346
434
  rule %r/\bendform\b/, Keyword, :pop!
347
435
  end
348
-
349
436
  end
350
437
  end
351
438
  end
@@ -0,0 +1,142 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ class RML < RegexLexer
7
+ title "RML"
8
+ desc "A system agnostic domain-specific language for runtime monitoring and verification (https://rmlatdibris.github.io/)"
9
+ tag 'rml'
10
+ filenames '*.rml'
11
+
12
+ def self.keywords
13
+ @keywords ||= Set.new %w(
14
+ matches not with empty
15
+ all if else true false
16
+ )
17
+ end
18
+
19
+ def self.arithmetic_keywords
20
+ @arithmetic_keywords ||= Set.new %w(
21
+ abs sin cos tan min max
22
+ )
23
+ end
24
+
25
+ id_char = /[a-zA-Z0-9_]/
26
+ uppercase_id = /[A-Z]#{id_char}*/
27
+ lowercase_id = /[a-z]#{id_char}*/
28
+
29
+ ellipsis = /(\.){3}/
30
+ int = /[0-9]+/
31
+ float = /#{int}\.#{int}/
32
+ string = /'(\\'|[ a-zA-Z0-9_.])*'/
33
+
34
+ whitespace = /[ \t\r\n]+/
35
+ comment = /\/\/[^\r\n]*/
36
+
37
+ state :common_rules do
38
+ rule %r/#{whitespace}/, Text
39
+ rule %r/#{comment}/, Comment::Single
40
+ rule %r/#{string}/, Literal::String
41
+ rule %r/#{float}/, Num::Float
42
+ rule %r/#{int}/, Num::Integer
43
+ end
44
+
45
+ state :root do
46
+ mixin :common_rules
47
+ rule %r/(#{lowercase_id})(\()/ do
48
+ groups Name::Function, Operator
49
+ push :event_type_params
50
+ end
51
+ rule %r/#{lowercase_id}/ do |m|
52
+ if m[0] == 'with'
53
+ token Keyword
54
+ push :data_expression_with
55
+ elsif self.class.keywords.include? m[0]
56
+ token Keyword
57
+ else
58
+ token Name::Function
59
+ end
60
+ end
61
+ rule %r/\(|\{|\[/, Operator, :event_type_params
62
+ rule %r/[_\|]/, Operator
63
+ rule %r/#{uppercase_id}/, Name::Class, :equation_block_expression
64
+ rule %r/;/, Operator
65
+ end
66
+
67
+ state :event_type_params do
68
+ mixin :common_rules
69
+ rule %r/\(|\{|\[/, Operator, :push
70
+ rule %r/\)|\}|\]/, Operator, :pop!
71
+ rule %r/#{lowercase_id}(?=:)/, Name::Entity
72
+ rule %r/(#{lowercase_id})/ do |m|
73
+ if self.class.keywords.include? m[0]
74
+ token Keyword
75
+ else
76
+ token Literal::String::Regex
77
+ end
78
+ end
79
+ rule %r/#{ellipsis}/, Literal::String::Symbol
80
+ rule %r/[_\|;,:]/, Operator
81
+ end
82
+
83
+ state :equation_block_expression do
84
+ mixin :common_rules
85
+ rule %r/[<,>]/, Operator
86
+ rule %r/#{lowercase_id}/, Literal::String::Regex
87
+ rule %r/=/ do
88
+ token Operator
89
+ goto :exp
90
+ end
91
+ rule %r/;/, Operator, :pop!
92
+ end
93
+
94
+ state :exp do
95
+ mixin :common_rules
96
+ rule %r/(if)(\()/ do
97
+ groups Keyword, Operator
98
+ push :data_expression
99
+ end
100
+ rule %r/let|var/, Keyword, :equation_block_expression
101
+ rule %r/(#{lowercase_id})(\()/ do
102
+ groups Name::Function, Operator
103
+ push :event_type_params
104
+ end
105
+ rule %r/(#{lowercase_id})/ do |m|
106
+ if self.class.keywords.include? m[0]
107
+ token Keyword
108
+ else
109
+ token Name::Function
110
+ end
111
+ end
112
+ rule %r/#{uppercase_id}(?=<)/, Name::Class, :data_expression
113
+ rule %r/#{uppercase_id}/, Name::Class
114
+ rule %r/[=(){}*+\/\\\|!>?]/, Operator
115
+ rule %r/;/, Operator, :pop!
116
+ end
117
+
118
+ state :data_expression do
119
+ mixin :common_rules
120
+ rule %r/#{lowercase_id}/ do |m|
121
+ if (self.class.arithmetic_keywords | self.class.keywords).include? m[0]
122
+ token Keyword
123
+ else
124
+ token Literal::String::Regex
125
+ end
126
+ end
127
+ rule %r/\(/, Operator, :push
128
+ rule %r/\)/, Operator, :pop!
129
+ rule %r/(>)(?=[^A-Z;]+[A-Z;>])/, Operator, :pop!
130
+ rule %r/[*^?!%&\[\]<>\|+=:,.\/\\_-]/, Operator
131
+ rule %r/;/, Operator, :pop!
132
+ end
133
+
134
+ state :data_expression_with do
135
+ mixin :common_rules
136
+ rule %r/>/, Operator
137
+ mixin :data_expression
138
+
139
+ end
140
+ end
141
+ end
142
+ end
@@ -27,7 +27,7 @@ module Rouge
27
27
  rule %r/(.*?)(\\\n)/ do
28
28
  groups Text, Str::Escape
29
29
  end
30
- rule %r/(.*)'/, Text, :pop!
30
+ rule %r/(.*)'?/, Text, :pop!
31
31
  end
32
32
  end
33
33
  end
@@ -5,10 +5,10 @@ module Rouge
5
5
  module Lexers
6
6
  class TOML < RegexLexer
7
7
  title "TOML"
8
- desc 'the TOML configuration format (https://github.com/mojombo/toml)'
8
+ desc 'the TOML configuration format (https://github.com/toml-lang/toml)'
9
9
  tag 'toml'
10
10
 
11
- filenames '*.toml', 'Pipfile'
11
+ filenames '*.toml', 'Pipfile', 'poetry.lock'
12
12
  mimetypes 'text/x-toml'
13
13
 
14
14
  # bare keys and quoted keys
@@ -24,8 +24,6 @@ module Rouge
24
24
  push :inline
25
25
  end
26
26
 
27
- rule %r/(?<!=)\s*\[[\S]+\]/, Name::Namespace
28
-
29
27
  rule %r/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/, Literal::Date
30
28
 
31
29
  rule %r/[+-]?\d+(?:_\d+)*\.\d+(?:_\d+)*(?:[eE][+-]?\d+(?:_\d+)*)?/, Num::Float
@@ -41,6 +39,8 @@ module Rouge
41
39
  state :root do
42
40
  mixin :basic
43
41
 
42
+ rule %r/(?<!=)\s*\[.*?\]+/, Name::Namespace
43
+
44
44
  rule %r/(#{identifier})(\s*)(=)/ do
45
45
  groups Name::Property, Text, Punctuation
46
46
  push :value
@@ -20,6 +20,13 @@ module Rouge
20
20
  groups Name::Other, Punctuation
21
21
  pop! 3
22
22
  end
23
+
24
+ rule %r/</, Punctuation, :type
25
+ end
26
+
27
+ state :type do
28
+ mixin :object
29
+ rule %r/>/, Punctuation, :pop!
23
30
  end
24
31
  end
25
32
  end
@@ -26,7 +26,10 @@ module Rouge
26
26
 
27
27
  def builtins
28
28
  @builtins ||= super + %w(
29
- Pick Partial Readonly Record
29
+ Capitalize ConstructorParameters Exclude Extract InstanceType
30
+ Lowercase NonNullable Omit OmitThisParameter Parameters
31
+ Partial Pick Readonly Record Required
32
+ ReturnType ThisParameterType ThisType Uncapitalize Uppercase
30
33
  )
31
34
  end
32
35
 
@@ -5,7 +5,7 @@ module Rouge
5
5
  module Lexers
6
6
  class Vala < RegexLexer
7
7
  tag 'vala'
8
- filenames '*.vala'
8
+ filenames '*.vala', '*.vapi'
9
9
  mimetypes 'text/x-vala'
10
10
 
11
11
  title "Vala"
@@ -175,7 +175,7 @@ module Rouge
175
175
 
176
176
  state :block_nodes do
177
177
  # implicit key
178
- rule %r/([^#,:?\[\]{}"'\n]+)(:)(?=\s|$)/ do |m|
178
+ rule %r/([^#,?\[\]{}"'\n]+)(:)(?=\s|$)/ do |m|
179
179
  groups Name::Attribute, Punctuation::Indicator
180
180
  set_indent m[0], :implicit => true
181
181
  end