rouge 3.26.0 → 3.30.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -1
  3. data/lib/rouge/cli.rb +23 -20
  4. data/lib/rouge/demos/brainfuck +1 -1
  5. data/lib/rouge/demos/brightscript +1 -1
  6. data/lib/rouge/demos/bsl +1 -1
  7. data/lib/rouge/demos/cfscript +1 -1
  8. data/lib/rouge/demos/coq +1 -1
  9. data/lib/rouge/demos/csvs +1 -1
  10. data/lib/rouge/demos/dafny +16 -0
  11. data/lib/rouge/demos/datastudio +0 -1
  12. data/lib/rouge/demos/ecl +0 -1
  13. data/lib/rouge/demos/erlang +1 -1
  14. data/lib/rouge/demos/fluent +13 -0
  15. data/lib/rouge/demos/fsharp +1 -1
  16. data/lib/rouge/demos/glsl +1 -1
  17. data/lib/rouge/demos/haxe +0 -1
  18. data/lib/rouge/demos/idris +13 -0
  19. data/lib/rouge/demos/isabelle +16 -0
  20. data/lib/rouge/demos/lean +8 -0
  21. data/lib/rouge/demos/meson +10 -0
  22. data/lib/rouge/demos/nesasm +1 -1
  23. data/lib/rouge/demos/nial +35 -0
  24. data/lib/rouge/demos/opentype_feature_file +0 -1
  25. data/lib/rouge/demos/plsql +2 -0
  26. data/lib/rouge/demos/smarty +0 -1
  27. data/lib/rouge/demos/stan +13 -0
  28. data/lib/rouge/demos/stata +14 -0
  29. data/lib/rouge/demos/syzlang +15 -0
  30. data/lib/rouge/demos/syzprog +8 -0
  31. data/lib/rouge/formatter.rb +2 -2
  32. data/lib/rouge/formatters/html_inline.rb +0 -1
  33. data/lib/rouge/guessers/disambiguation.rb +7 -0
  34. data/lib/rouge/lexer.rb +2 -2
  35. data/lib/rouge/lexers/apache/keywords.rb +1 -1
  36. data/lib/rouge/lexers/apple_script.rb +1 -1
  37. data/lib/rouge/lexers/c.rb +12 -2
  38. data/lib/rouge/lexers/ceylon.rb +2 -2
  39. data/lib/rouge/lexers/console.rb +1 -1
  40. data/lib/rouge/lexers/cpp.rb +8 -5
  41. data/lib/rouge/lexers/cypher.rb +8 -0
  42. data/lib/rouge/lexers/dafny.rb +128 -0
  43. data/lib/rouge/lexers/dart.rb +10 -9
  44. data/lib/rouge/lexers/docker.rb +4 -0
  45. data/lib/rouge/lexers/eex.rb +2 -2
  46. data/lib/rouge/lexers/eiffel.rb +0 -1
  47. data/lib/rouge/lexers/factor.rb +2 -2
  48. data/lib/rouge/lexers/fluent.rb +74 -0
  49. data/lib/rouge/lexers/ghc_core.rb +1 -1
  50. data/lib/rouge/lexers/gherkin/keywords.rb +1 -1
  51. data/lib/rouge/lexers/groovy.rb +1 -1
  52. data/lib/rouge/lexers/handlebars.rb +1 -1
  53. data/lib/rouge/lexers/hcl.rb +1 -0
  54. data/lib/rouge/lexers/hylang.rb +0 -1
  55. data/lib/rouge/lexers/idris.rb +210 -0
  56. data/lib/rouge/lexers/isabelle.rb +251 -0
  57. data/lib/rouge/lexers/javascript.rb +1 -1
  58. data/lib/rouge/lexers/jsl.rb +6 -7
  59. data/lib/rouge/lexers/jsx.rb +1 -2
  60. data/lib/rouge/lexers/kotlin.rb +3 -1
  61. data/lib/rouge/lexers/lasso/keywords.rb +1 -1
  62. data/lib/rouge/lexers/lean.rb +164 -0
  63. data/lib/rouge/lexers/llvm/keywords.rb +1 -1
  64. data/lib/rouge/lexers/lua/keywords.rb +1 -1
  65. data/lib/rouge/lexers/mathematica/keywords.rb +1 -1
  66. data/lib/rouge/lexers/matlab/keywords.rb +1 -1
  67. data/lib/rouge/lexers/matlab.rb +3 -2
  68. data/lib/rouge/lexers/meson.rb +159 -0
  69. data/lib/rouge/lexers/nial.rb +166 -0
  70. data/lib/rouge/lexers/ocl.rb +0 -1
  71. data/lib/rouge/lexers/pascal.rb +2 -1
  72. data/lib/rouge/lexers/php/keywords.rb +1 -1
  73. data/lib/rouge/lexers/php.rb +7 -5
  74. data/lib/rouge/lexers/plsql.rb +578 -0
  75. data/lib/rouge/lexers/prometheus.rb +0 -1
  76. data/lib/rouge/lexers/python.rb +3 -1
  77. data/lib/rouge/lexers/q.rb +0 -1
  78. data/lib/rouge/lexers/rust.rb +82 -19
  79. data/lib/rouge/lexers/sparql.rb +5 -4
  80. data/lib/rouge/lexers/sqf/keywords.rb +1 -1
  81. data/lib/rouge/lexers/sql.rb +7 -7
  82. data/lib/rouge/lexers/stan.rb +451 -0
  83. data/lib/rouge/lexers/stata.rb +165 -0
  84. data/lib/rouge/lexers/supercollider.rb +0 -1
  85. data/lib/rouge/lexers/swift.rb +3 -3
  86. data/lib/rouge/lexers/syzlang.rb +317 -0
  87. data/lib/rouge/lexers/syzprog.rb +122 -0
  88. data/lib/rouge/lexers/tap.rb +0 -1
  89. data/lib/rouge/lexers/toml.rb +16 -9
  90. data/lib/rouge/lexers/tsx.rb +0 -1
  91. data/lib/rouge/lexers/tulip.rb +0 -1
  92. data/lib/rouge/lexers/viml/keywords.rb +1 -1
  93. data/lib/rouge/lexers/yaml.rb +1 -1
  94. data/lib/rouge/version.rb +1 -1
  95. metadata +30 -6
@@ -0,0 +1,165 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ class Stata < RegexLexer
7
+ title "Stata"
8
+ desc "The Stata programming language (www.stata.com)"
9
+ tag 'stata'
10
+ filenames '*.do', '*.ado'
11
+ mimetypes 'application/x-stata', 'text/x-stata'
12
+
13
+ ###
14
+ # Stata reference manual is available online at: https://www.stata.com/features/documentation/
15
+ ###
16
+
17
+ # Partial list of common programming and estimation commands, as of Stata 16
18
+ # Note: not all abbreviations are included
19
+ KEYWORDS = %w(
20
+ do run include clear assert set mata log
21
+ by bys bysort cap capt capture char class classutil which cdir confirm new existence creturn
22
+ _datasignature discard di dis disp displ displa display ereturn error _estimates exit file open read write seek close query findfile fvexpand
23
+ gettoken java home heapmax java_heapmax icd9 icd9p icd10 icd10cm icd10pcs initialize javacall levelsof
24
+ tempvar tempname tempfile macro shift uniq dups retokenize clean sizeof posof
25
+ makecns matcproc marksample mark markout markin svymarkout matlist
26
+ accum define dissimilarity eigenvalues get rowjoinbyname rownames score svd symeigen dir list ren rename
27
+ more pause plugin call postfile _predict preserve restore program define drop end python qui quietly noi noisily _return return _rmcoll rmsg _robust
28
+ serset locale_functions locale_ui signestimationsample checkestimationsample sleep syntax sysdir adopath adosize
29
+ tabdisp timer tokenize trace unab unabcmd varabbrev version viewsource
30
+ window fopen fsave manage menu push stopbox
31
+ net from cd link search install sj stb ado update uninstall pwd ssc ls
32
+ using insheet outsheet mkmat svmat sum summ summarize
33
+ graph gr_edit twoway histogram kdensity spikeplot
34
+ mi miss missing var varname order compress append
35
+ gen gene gener genera generat generate egen replace duplicates
36
+ estimates nlcom lincom test testnl predict suest
37
+ _regress reg regr regre regres regress probit logit ivregress logistic svy gmm ivprobit ivtobit
38
+ bsample assert codebook collapse compare contract copy count cross datasignature d ds desc describe destring tostring
39
+ drawnorm edit encode decode erase expand export filefilter fillin format frame frget frlink gsort
40
+ import dbase delimited excel fred haver sas sasxport5 sasxport8 spss infile infix input insobs inspect ipolate isid
41
+ joinby label language labelbook lookfor memory mem merge mkdir mvencode notes obs odbc order outfile
42
+ pctile xtile _pctile putmata range recast recode rename group reshape rm rmdir sample save saveold separate shell snapshot sort split splitsample stack statsby sysuse
43
+ type unicode use varmanage vl webuse xpose zipfile
44
+ number keep tab table tabulate stset stcox tsset xtset
45
+ )
46
+
47
+ # Complete list of functions by name, as of Stata 16
48
+ PRIMITIVE_FUNCTIONS = %w(
49
+ abbrev abs acos acosh age age_frac asin asinh atan atan2 atanh autocode
50
+ betaden binomial binomialp binomialtail binormal birthday bofd byteorder
51
+ c _caller cauchy cauchyden cauchytail Cdhms ceil char chi2 chi2den chi2tail Chms
52
+ chop cholesky clip Clock clock clockdiff cloglog Cmdyhms Cofc cofC Cofd cofd coleqnumb
53
+ collatorlocale collatorversion colnfreeparms colnumb colsof comb cond corr cos cosh
54
+ daily date datediff datediff_frac day det dgammapda dgammapdada dgammapdadx dgammapdxdx dhms
55
+ diag diag0cnt digamma dofb dofC dofc dofh dofm dofq dofw dofy dow doy dunnettprob e el epsdouble
56
+ epsfloat exp expm1 exponential exponentialden exponentialtail
57
+ F Fden fileexists fileread filereaderror filewrite float floor fmtwidth frval _frval Ftail
58
+ fammaden gammap gammaptail get hadamard halfyear halfyearly has_eprop hh hhC hms hofd hours
59
+ hypergeometric hypergeometricp
60
+ I ibeta ibetatail igaussian igaussianden igaussiantail indexnot inlist inrange int inv invbinomial invbinomialtail
61
+ invcauchy invcauchytail invchi2 invchi2tail invcloglog invdunnettprob invexponential invexponentialtail invF
62
+ invFtail invgammap invgammaptail invibeta invibetatail invigaussian invigaussiantail invlaplace invlaplacetail
63
+ invlogistic invlogistictail invlogit invnbinomial invnbinomialtail invnchi2 invnchi2tail invnF invnFtail invnibeta invnormal invnt invnttail
64
+ invpoisson invpoissontail invsym invt invttail invtukeyprob invweibull invweibullph invweibullphtail invweibulltail irecode islepyear issymmetric
65
+ J laplace laplaceden laplacetail ln ln1m ln1p lncauchyden lnfactorial lngamma lnigammaden lnigaussianden lniwishartden lnlaplaceden lnmvnormalden
66
+ lnnormal lnnormalden lnnormalden lnnormalden lnwishartden log log10 log1m log1p logistic logisticden logistictail logit
67
+ matmissing matrix matuniform max maxbyte maxdouble maxfloat maxint maxlong mdy mdyhms mi min minbyte mindouble minfloat minint minlong minutes
68
+ missing mm mmC mod mofd month monthly mreldif msofhours msofminutes msofseconds
69
+ nbetaden nbinomial nbinomialp nbinomialtail nchi2 nchi2den nchi2tail nextbirthday nextleapyear nF nFden nFtail nibeta
70
+ normal normalden npnchi2 npnF npnt nt ntden nttail nullmat
71
+ plural poisson poissonp poissontail previousbirthday previousleapyear qofd quarter quarterly r rbeta rbinomial rcauchy rchi2 recode
72
+ real regexm regexr regexs reldif replay return rexponential rgamma rhypergeometric rigaussian rlaplace rlogistic rnormal
73
+ round roweqnumb rownfreeparms rownumb rowsof rpoisson rt runiform runiformint rweibull rweibullph
74
+ s scalar seconds sign sin sinh smallestdouble soundex soundex_nara sqrt ss ssC strcat strdup string stritrim strlen strlower
75
+ strltrim strmatch strofreal strpos strproper strreverse strrpos strrtrim strtoname strtrim strupper subinstr subinword substr sum sweep
76
+ t tan tanh tC tc td tden th tin tm tobytes tq trace trigamma trunc ttail tukeyprob tw twithin
77
+ uchar udstrlen udsubstr uisdigit uisletter uniform ustrcompare ustrcompareex ustrfix ustrfrom ustrinvalidcnt ustrleft ustrlen ustrlower
78
+ ustrltrim ustrnormalize ustrpos ustrregexm ustrregexra ustrregexrf ustrregexs ustrreverse ustrright ustrrpos ustrrtrim ustrsortkey
79
+ ustrsortkeyex ustrtitle ustrto ustrtohex ustrtoname ustrtrim ustrunescape ustrupper ustrword ustrwordcount usubinstr usubstr
80
+ vec vecdiag week weekly weibull weibullden weibullph weibullphden weibullphtail weibulltail wofd word wordbreaklocale wordcount
81
+ year yearly yh ym yofd yq yw
82
+ )
83
+
84
+ # Note: types `str1-str2045` handled separately below
85
+ def self.type_keywords
86
+ @type_keywords ||= Set.new %w(byte int long float double str strL numeric string integer scalar matrix local global numlist varlist newlist)
87
+ end
88
+
89
+ # Stata commands used with braces. Includes all valid abbreviations for 'forvalues'.
90
+ def self.reserved_keywords
91
+ @reserved_keywords ||= Set.new %w(if else foreach forv forva forval forvalu forvalue forvalues to while in of continue break nobreak)
92
+ end
93
+
94
+ ###
95
+ # Lexer state and rules
96
+ ###
97
+ state :root do
98
+
99
+ # Pre-processor commands: #
100
+ rule %r/^\s*#.*$/, Comment::Preproc
101
+
102
+ # Hashbang comments: *!
103
+ rule %r/^\*!.*$/, Comment::Hashbang
104
+
105
+ # Single-line comment: *
106
+ rule %r/^\s*\*.*$/, Comment::Single
107
+
108
+ # Keywords: recognize only when they are the first word
109
+ rule %r/^\s*(#{KEYWORDS.join('|')})\b/, Keyword
110
+
111
+ # Whitespace. Classify `\n` as `Text` to avoid interference with `Comment` and `Keyword` above
112
+ rule(/[ \t]+/, Text::Whitespace)
113
+ rule(/[\n\r]+/, Text)
114
+
115
+ # In-line comment: //
116
+ rule %r/\/\/.*?$/, Comment::Single
117
+
118
+ # Multi-line comment: /* and */
119
+ rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline
120
+
121
+ # Strings indicated by compound double-quotes (`""') and double-quotes ("")
122
+ rule %r/`"(\\.|.)*?"'/, Str::Double
123
+ rule %r/"(\\.|.)*?"/, Str::Double
124
+
125
+ # Format locals (`') and globals ($) as strings
126
+ rule %r/`(\\.|.)*?'/, Str::Double
127
+ rule %r/(?<!\w)\$\w+/, Str::Double
128
+
129
+ # Display formats
130
+ rule %r/\%\S+/, Name::Property
131
+
132
+ # Additional string types: str1-str2045
133
+ rule %r/\bstr(204[0-5]|20[0-3][0-9]|[01][0-9][0-9][0-9]|[0-9][0-9][0-9]|[0-9][0-9]|[1-9])\b/, Keyword::Type
134
+
135
+ # Only recognize primitive functions when they are actually used as a function call, i.e. followed by an opening parenthesis
136
+ # `Name::Builtin` would be more logical, but is not usually highlighted, so use `Name::Function` instead
137
+ rule %r/\b(#{PRIMITIVE_FUNCTIONS.join('|')})(?=\()/, Name::Function
138
+
139
+ # Matrix operator `..` (declare here instead of with other operators, in order to avoid conflict with numbers below)
140
+ rule %r/\.\.(?=.*\])/, Operator
141
+
142
+ # Numbers
143
+ rule %r/[+-]?(\d+([.]\d+)?|[.]\d+)([eE][+-]?\d+)?/, Num
144
+
145
+ # Factor variable and time series operators
146
+ rule %r/\b[ICOicoLFDSlfds]\w*\./, Operator
147
+ rule %r/\b[ICOicoLFDSlfds]\w*(?=\(.*\)\.)/, Operator
148
+
149
+ rule %r/\w+/ do |m|
150
+ if self.class.reserved_keywords.include? m[0]
151
+ token Keyword::Reserved
152
+ elsif self.class.type_keywords.include? m[0]
153
+ token Keyword::Type
154
+ else
155
+ token Name
156
+ end
157
+ end
158
+
159
+ rule %r/[\[\]{}();,]/, Punctuation
160
+
161
+ rule %r([-<>?*+'^/\\!#.=~:&|]), Operator
162
+ end
163
+ end
164
+ end
165
+ end
@@ -113,4 +113,3 @@ module Rouge
113
113
  end
114
114
  end
115
115
  end
116
-
@@ -15,17 +15,17 @@ module Rouge
15
15
  id = /#{id_head}#{id_rest}*/
16
16
 
17
17
  keywords = Set.new %w(
18
- break case continue default do else fallthrough if in for return switch where while try catch throw guard defer repeat
18
+ await break case continue default do else fallthrough if in for return switch where while try catch throw guard defer repeat
19
19
 
20
20
  as dynamicType is new super self Self Type __COLUMN__ __FILE__ __FUNCTION__ __LINE__
21
21
 
22
- associativity didSet get infix inout mutating none nonmutating operator override postfix precedence prefix set unowned weak willSet throws rethrows precedencegroup
22
+ associativity async didSet get infix inout isolated mutating none nonmutating operator override postfix precedence prefix set unowned weak willSet throws rethrows precedencegroup
23
23
 
24
24
  #available #colorLiteral #column #else #elseif #endif #error #file #fileLiteral #function #if #imageLiteral #line #selector #sourceLocation #warning
25
25
  )
26
26
 
27
27
  declarations = Set.new %w(
28
- class deinit enum convenience extension final func import init internal lazy let optional private protocol public required static struct subscript typealias var dynamic indirect associatedtype open fileprivate some
28
+ actor class deinit enum convenience extension final func import init internal lazy let nonisolated optional private protocol public required static struct subscript typealias var dynamic indirect associatedtype open fileprivate some
29
29
  )
30
30
 
31
31
  constants = Set.new %w(
@@ -0,0 +1,317 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ class Syzlang < RegexLexer
7
+ title "Syzlang"
8
+ desc "Syscall description language used by syzkaller"
9
+ tag 'syzlang'
10
+
11
+ def self.keywords
12
+ @keywords ||= Set.new %w(
13
+ align breaks_returns dec define disabled hex ignore_return in incdir
14
+ include inet inout oct opt out packed parent prog_timeout pseudo
15
+ resource size syscall timeout type varlen
16
+ )
17
+ end
18
+
19
+ def self.keywords_type
20
+ @keywords_type ||= Set.new %w(
21
+ array bitsize bool16 bool32 bool64 bool8 boolptr buffer bytesize
22
+ bytesize2 bytesize4 bytesize8 const csum filename fileoff flags fmt
23
+ int16 int16be int32 int32be int64 int64be int8 int8be intptr len
24
+ offsetof optional proc ptr ptr64 string stringnoz text vma vma64 void
25
+ )
26
+ end
27
+
28
+ comment = /#.*$/
29
+ inline_spaces = /[ \t]+/
30
+ eol_spaces = /[\n\r]+/
31
+ spaces = /\s+/
32
+
33
+ state :inline_break do
34
+ rule inline_spaces, Text
35
+ rule %r//, Text, :pop!
36
+ end
37
+
38
+ state :space_break do
39
+ rule spaces, Text
40
+ rule comment, Comment
41
+ rule %r//, Text, :pop!
42
+ end
43
+
44
+ id = /[a-zA-Z_][a-zA-Z0-9_]*/
45
+ num_id = /[a-zA-Z0-9_]+/
46
+
47
+ state :mixin_name do
48
+ rule id, Name
49
+ end
50
+
51
+ state :mixin_number do
52
+ rule %r/-?0x[\da-f]+/i, Num::Hex
53
+ rule %r/-?\d+/, Num::Integer
54
+ rule %r/'[^']?'/, Str::Char
55
+ end
56
+
57
+ state :mixin_string do
58
+ rule %r/"[^"]*"/, Str::Double
59
+ rule %r/`[^`]*`/, Str::Backtick
60
+ end
61
+
62
+ state :mixin_term do
63
+ mixin :mixin_number
64
+ mixin :mixin_string
65
+
66
+ # Keywords.
67
+ rule id do |m|
68
+ if self.class.keywords.include?(m[0])
69
+ token Keyword
70
+ elsif self.class.keywords_type.include?(m[0])
71
+ token Keyword::Type
72
+ else
73
+ token Name
74
+ end
75
+ end
76
+
77
+ # Ranges.
78
+ rule %r/:/, Punctuation
79
+
80
+ # "struct$type" struct name format.
81
+ rule %r/\$/, Name
82
+ end
83
+
84
+ state :term_list do
85
+ rule spaces, Text
86
+ rule comment, Comment
87
+ mixin :mixin_term
88
+ rule %r/\[/, Punctuation, :term_list
89
+ rule %r/,/, Punctuation
90
+ rule %r/[\]\)]/, Punctuation, :pop!
91
+ end
92
+
93
+ state :arg_type do
94
+ mixin :mixin_term
95
+ rule %r/\[/, Punctuation, :term_list
96
+ rule %r//, Text, :pop!
97
+ end
98
+
99
+ state :include do
100
+ rule %r/(<)([^>]+)(>)/ do |m|
101
+ groups Punctuation, Str, Punctuation
102
+ end
103
+ rule %r//, Text, :pop!
104
+ end
105
+
106
+ state :define_name do
107
+ mixin :mixin_name
108
+ rule %r//, Text, :pop!
109
+ end
110
+
111
+ state :define_exp do
112
+ mixin :mixin_name
113
+ mixin :mixin_number
114
+ mixin :mixin_string
115
+ rule %r/[~!%\^&\*\-\+\/\|<>\?:]/, Operator
116
+ rule %r/[\(\){}\[\];,]/, Punctuation
117
+ rule inline_spaces, Text
118
+ rule %r//, Text, :pop!
119
+ end
120
+
121
+ state :resource_name do
122
+ mixin :mixin_name
123
+ rule %r//, Text, :pop!
124
+ end
125
+
126
+ state :resource_type do
127
+ rule %r/\[/, Punctuation, :arg_type
128
+ rule %r/\]/, Punctuation, :pop!
129
+ end
130
+
131
+ state :resource_values do
132
+ rule %r/:/ do
133
+ token Punctuation
134
+ push :resource_values_list
135
+ push :space_break
136
+ end
137
+ rule %r//, Text, :pop!
138
+ end
139
+
140
+ state :resource_values_list do
141
+ rule inline_spaces, Text
142
+ mixin :mixin_name
143
+ mixin :mixin_number
144
+ mixin :mixin_string
145
+ rule %r/,/, Punctuation, :space_break
146
+ rule %r//, Text, :pop!
147
+ end
148
+
149
+ state :flags_list do
150
+ rule inline_spaces, Text
151
+ rule %r/\./, Punctuation
152
+ mixin :mixin_name
153
+ mixin :mixin_number
154
+ mixin :mixin_string
155
+ rule %r/,/, Punctuation, :space_break
156
+ rule %r//, Punctuation, :pop!
157
+ end
158
+
159
+ state :syscall_args do
160
+ rule spaces, Text
161
+ rule comment, Comment
162
+ rule %r/\./, Punctuation
163
+ rule id do
164
+ token Name
165
+ push :arg_type
166
+ push :space_break
167
+ end
168
+ rule %r/,/, Punctuation
169
+ rule %r/\)/, Punctuation, :pop!
170
+ end
171
+
172
+ state :syscall_retval do
173
+ mixin :mixin_name
174
+ rule %r//, Text, :pop!
175
+ end
176
+
177
+ state :syscall_mods do
178
+ rule %r/\(/, Punctuation, :term_list
179
+ rule %r//, Text, :pop!
180
+ end
181
+
182
+ state :struct_fields do
183
+ rule id do
184
+ token Name
185
+ push :space_break
186
+ push :struct_field_mods
187
+ push :inline_break
188
+ push :arg_type
189
+ push :space_break
190
+ end
191
+ rule %r/[}\]]/, Punctuation, :pop!
192
+ end
193
+
194
+ state :struct_field_mods do
195
+ rule %r/\(/, Punctuation, :term_list
196
+ rule %r//, Text, :pop!
197
+ end
198
+
199
+ state :struct_mods do
200
+ rule %r/\[/, Punctuation, :term_list
201
+ rule %r//, Text, :pop!
202
+ end
203
+
204
+ state :type_name do
205
+ mixin :mixin_name
206
+ rule %r//, Text, :pop!
207
+ end
208
+
209
+ state :type_args do
210
+ rule %r/\[/, Punctuation, :type_args_list
211
+ rule %r//, Text, :pop!
212
+ end
213
+
214
+ state :type_args_list do
215
+ rule spaces, Text
216
+ rule comment, Comment
217
+ mixin :mixin_name
218
+ rule %r/,/, Punctuation
219
+ rule %r/\]/, Punctuation, :pop!
220
+ end
221
+
222
+ state :type_body do
223
+ rule %r/[{\[]/ do
224
+ token Punctuation
225
+ pop!
226
+ push :space_break
227
+ push :struct_mods
228
+ push :inline_break
229
+ push :struct_fields
230
+ push :space_break
231
+ end
232
+ rule %r// do
233
+ pop!
234
+ push :arg_type
235
+ end
236
+ end
237
+
238
+ state :root do
239
+ # Whitespace.
240
+ rule spaces, Text
241
+
242
+ # Comments.
243
+ rule comment, Comment
244
+
245
+ # Includes.
246
+ rule %r/(include|incdir)/ do
247
+ token Keyword
248
+ push :include
249
+ push :space_break
250
+ end
251
+
252
+ # Defines.
253
+ rule %r/define/ do
254
+ token Keyword
255
+ push :define_exp
256
+ push :space_break
257
+ push :define_name
258
+ push :space_break
259
+ end
260
+
261
+ # Resources.
262
+ rule %r/resource/ do
263
+ token Keyword
264
+ push :resource_values
265
+ push :inline_break
266
+ push :resource_type
267
+ push :inline_break
268
+ push :resource_name
269
+ push :space_break
270
+ end
271
+
272
+ # Flags and strings.
273
+ rule %r/(#{id}|_)(#{spaces})(=)/ do |m|
274
+ if m[1] == "_"
275
+ groups Keyword, Text, Punctuation
276
+ else
277
+ groups Name, Text, Punctuation
278
+ end
279
+ push :flags_list
280
+ push :space_break
281
+ end
282
+
283
+ # Syscalls.
284
+ rule %r/(#{id})(\$)?(#{num_id})?(#{spaces})?(\()/ do |m|
285
+ groups Name::Function, Punctuation, Name::Function::Magic, Text, Punctuation
286
+ push :syscall_mods
287
+ push :inline_break
288
+ push :syscall_retval
289
+ push :inline_break
290
+ push :syscall_args
291
+ push :space_break
292
+ end
293
+
294
+ # Structs and unions.
295
+ rule %r/(#{id}|#{id}\$#{num_id})(#{spaces})?([{\[])/ do |m|
296
+ groups Name, Text, Punctuation
297
+ push :inline_break
298
+ push :struct_mods
299
+ push :inline_break
300
+ push :struct_fields
301
+ push :space_break
302
+ end
303
+
304
+ # Types.
305
+ rule %r/type/ do
306
+ token Keyword
307
+ push :type_body
308
+ push :space_break
309
+ push :type_args
310
+ push :type_name
311
+ push :space_break
312
+ end
313
+ end
314
+
315
+ end
316
+ end
317
+ end
@@ -0,0 +1,122 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ class Syzprog < RegexLexer
7
+ title "Syzprog"
8
+ desc "Program description language used by syzkaller"
9
+ tag 'syzprog'
10
+
11
+ def self.keywords
12
+ @keywords ||= Set.new %w(
13
+ ANY ANYBLOB ANYPTR ANYPTR64 ANYPTRS ANYRES16 ANYRES32 ANYRES64
14
+ ANYRESDEC ANYRESHEX ANYRESOCT ANYUNION AUTO false nil true void
15
+ async fail_nth rerun
16
+ )
17
+ end
18
+
19
+ comment = /#.*$/
20
+ inline_spaces = /[ \t]+/
21
+ eol_spaces = /[\n\r]+/
22
+ spaces = /\s+/
23
+
24
+ id = /[a-zA-Z_][a-zA-Z0-9_]*/
25
+ num_id = /[a-zA-Z0-9_]+/
26
+ res_id = /r[0-9]+/
27
+
28
+ state :inline_break do
29
+ rule inline_spaces, Text
30
+ rule %r//, Text, :pop!
31
+ end
32
+
33
+ state :eol_break do
34
+ rule eol_spaces, Text
35
+ rule comment, Comment
36
+ rule %r//, Text, :pop!
37
+ end
38
+
39
+ state :space_break do
40
+ rule spaces, Text
41
+ rule comment, Comment
42
+ rule %r//, Text, :pop!
43
+ end
44
+
45
+ state :mixin_number do
46
+ rule %r/-?0x[\da-f]+/i, Num::Hex
47
+ rule %r/-?\d+/, Num::Integer
48
+ end
49
+
50
+ state :mixin_string do
51
+ rule %r/"[^"]*"/, Str::Double
52
+ rule %r/`[^`]*`/, Str::Backtick
53
+ rule %r/'[^']*'/, Str::Single
54
+ end
55
+
56
+ state :mixin_term do
57
+ mixin :mixin_number
58
+ mixin :mixin_string
59
+
60
+ rule %r/#{res_id}/, Keyword::Pseudo
61
+ rule id do |m|
62
+ if self.class.keywords.include?(m[0])
63
+ token Keyword
64
+ else
65
+ token Name
66
+ end
67
+ end
68
+ end
69
+
70
+ state :mods_list do
71
+ rule spaces, Text
72
+ rule comment, Comment
73
+ mixin :mixin_term
74
+ rule %r/[,:]/, Punctuation
75
+ rule %r/\)/, Punctuation, :pop!
76
+ end
77
+
78
+ state :syscall_mods do
79
+ rule %r/\(/, Punctuation, :mods_list
80
+ rule %r//, Text, :pop!
81
+ end
82
+
83
+ state :syscall_args do
84
+ rule spaces, Text
85
+ rule comment, Comment
86
+ mixin :mixin_term
87
+ mixin :mixin_number
88
+ mixin :mixin_string
89
+ # This punctuation is a part of the syntax:
90
+ rule %r/[@&=,<>{}\[\]]/, Punctuation
91
+ # This punctuation is not, highlight just in case:
92
+ rule %r/[!#\$%\^\*\-\+\/\|~:;.\?]/, Punctuation
93
+ rule %r/\(/, Punctuation, :syscall_args
94
+ rule %r/\)/, Punctuation, :pop!
95
+ end
96
+
97
+ state :root do
98
+ # Whitespace.
99
+ rule spaces, Text
100
+
101
+ # Comments.
102
+ rule comment, Comment
103
+
104
+ # Return values.
105
+ rule %r/(#{res_id})(#{spaces})(=)/ do
106
+ groups Keyword::Pseudo, Text, Punctuation
107
+ end
108
+
109
+ # Syscalls.
110
+ rule %r/(#{id})(\$)?(#{num_id})?(#{spaces})?(\()/ do |m|
111
+ groups Name::Function, Punctuation, Name::Function::Magic, Text, Punctuation
112
+ push :syscall_mods
113
+ push :inline_break
114
+ push :syscall_args
115
+ push :space_break
116
+ end
117
+
118
+ end
119
+
120
+ end
121
+ end
122
+ end
@@ -86,4 +86,3 @@ module Rouge
86
86
  end
87
87
  end
88
88
  end
89
-
@@ -11,14 +11,15 @@ module Rouge
11
11
  filenames '*.toml', 'Pipfile'
12
12
  mimetypes 'text/x-toml'
13
13
 
14
- identifier = /\S+/
14
+ # bare keys and quoted keys
15
+ identifier = %r/(?:\S+|"[^"]+"|'[^']+')/
15
16
 
16
17
  state :basic do
17
18
  rule %r/\s+/, Text
18
19
  rule %r/#.*?$/, Comment
19
20
  rule %r/(true|false)/, Keyword::Constant
20
21
 
21
- rule %r/(\S+)(\s*)(=)(\s*)(\{)/ do |m|
22
+ rule %r/(#{identifier})(\s*)(=)(\s*)(\{)/ do
22
23
  groups Name::Namespace, Text, Operator, Text, Punctuation
23
24
  push :inline
24
25
  end
@@ -27,9 +28,14 @@ module Rouge
27
28
 
28
29
  rule %r/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/, Literal::Date
29
30
 
30
- rule %r/(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?/, Num::Float
31
- rule %r/\d+[eE][+-]?[0-9]+j?/, Num::Float
32
- rule %r/\-?\d+/, Num::Integer
31
+ rule %r/[+-]?\d+(?:_\d+)*\.\d+(?:_\d+)*(?:[eE][+-]?\d+(?:_\d+)*)?/, Num::Float
32
+ rule %r/[+-]?\d+(?:_\d+)*[eE][+-]?\d+(?:_\d+)*/, Num::Float
33
+ rule %r/[+-]?(?:nan|inf)/, Num::Float
34
+
35
+ rule %r/0x\h+(?:_\h+)*/, Num::Hex
36
+ rule %r/0o[0-7]+(?:_[0-7]+)*/, Num::Oct
37
+ rule %r/0b[01]+(?:_[01]+)*/, Num::Bin
38
+ rule %r/[+-]?\d+(?:_\d+)*/, Num::Integer
33
39
  end
34
40
 
35
41
  state :root do
@@ -48,6 +54,11 @@ module Rouge
48
54
 
49
55
  state :content do
50
56
  mixin :basic
57
+
58
+ rule %r/(#{identifier})(\s*)(=)/ do
59
+ groups Name::Property, Text, Punctuation
60
+ end
61
+
51
62
  rule %r/"""/, Str, :mdq
52
63
  rule %r/"/, Str, :dq
53
64
  rule %r/'''/, Str, :msq
@@ -95,10 +106,6 @@ module Rouge
95
106
  state :inline do
96
107
  mixin :content
97
108
 
98
- rule %r/(#{identifier})(\s*)(=)/ do
99
- groups Name::Property, Text, Punctuation
100
- end
101
-
102
109
  rule %r/\}/, Punctuation, :pop!
103
110
  end
104
111
  end