rouge 3.13.0 → 3.18.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 +65 -50
- data/lib/rouge/cli.rb +18 -1
- data/lib/rouge/demos/cypher +5 -0
- data/lib/rouge/demos/datastudio +21 -0
- data/lib/rouge/demos/ecl +18 -0
- data/lib/rouge/demos/freefem +16 -0
- data/lib/rouge/demos/ghc-cmm +23 -0
- data/lib/rouge/demos/ghc-core +26 -0
- data/lib/rouge/demos/isbl +4 -0
- data/lib/rouge/demos/nasm +6 -6
- data/lib/rouge/demos/nesasm +11 -0
- data/lib/rouge/demos/objective_cpp +17 -0
- data/lib/rouge/demos/rego +8 -0
- data/lib/rouge/demos/slice +10 -0
- data/lib/rouge/demos/solidity +13 -0
- data/lib/rouge/demos/vcl +12 -0
- data/lib/rouge/demos/yang +17 -0
- data/lib/rouge/formatters/terminal256.rb +22 -6
- data/lib/rouge/formatters/terminal_truecolor.rb +37 -0
- data/lib/rouge/lexer.rb +5 -3
- data/lib/rouge/lexers/apache.rb +4 -8
- data/lib/rouge/lexers/apache/keywords.rb +15 -0
- data/lib/rouge/lexers/cmake.rb +1 -0
- data/lib/rouge/lexers/coffeescript.rb +47 -15
- data/lib/rouge/lexers/console.rb +88 -35
- data/lib/rouge/lexers/cpp.rb +12 -5
- data/lib/rouge/lexers/cypher.rb +108 -0
- data/lib/rouge/lexers/d.rb +4 -4
- data/lib/rouge/lexers/datastudio.rb +138 -0
- data/lib/rouge/lexers/dot.rb +2 -2
- data/lib/rouge/lexers/ecl.rb +175 -0
- data/lib/rouge/lexers/freefem.rb +240 -0
- data/lib/rouge/lexers/fsharp.rb +1 -0
- data/lib/rouge/lexers/ghc_cmm.rb +340 -0
- data/lib/rouge/lexers/ghc_core.rb +151 -0
- data/lib/rouge/lexers/gherkin.rb +1 -1
- data/lib/rouge/lexers/io.rb +2 -2
- data/lib/rouge/lexers/isbl.rb +97 -0
- data/lib/rouge/lexers/isbl/builtins.rb +17 -0
- data/lib/rouge/lexers/java.rb +4 -5
- data/lib/rouge/lexers/jinja.rb +5 -3
- data/lib/rouge/lexers/json.rb +3 -0
- data/lib/rouge/lexers/json_doc.rb +5 -3
- data/lib/rouge/lexers/kotlin.rb +4 -0
- data/lib/rouge/lexers/lasso.rb +4 -9
- data/lib/rouge/lexers/lasso/keywords.rb +14 -0
- data/lib/rouge/lexers/liquid.rb +1 -1
- data/lib/rouge/lexers/llvm.rb +55 -46
- data/lib/rouge/lexers/lua.rb +40 -2
- data/lib/rouge/lexers/m68k.rb +2 -2
- data/lib/rouge/lexers/magik.rb +1 -1
- data/lib/rouge/lexers/markdown.rb +9 -5
- data/lib/rouge/lexers/mathematica.rb +1 -1
- data/lib/rouge/lexers/matlab.rb +3 -4
- data/lib/rouge/lexers/matlab/builtins.rb +11 -0
- data/lib/rouge/lexers/nasm.rb +42 -168
- data/lib/rouge/lexers/nesasm.rb +78 -0
- data/lib/rouge/lexers/nginx.rb +1 -1
- data/lib/rouge/lexers/objective_c.rb +3 -172
- data/lib/rouge/lexers/objective_c/common.rb +184 -0
- data/lib/rouge/lexers/objective_cpp.rb +31 -0
- data/lib/rouge/lexers/pascal.rb +1 -1
- data/lib/rouge/lexers/php.rb +47 -32
- data/lib/rouge/lexers/pony.rb +1 -1
- data/lib/rouge/lexers/powershell.rb +5 -0
- data/lib/rouge/lexers/protobuf.rb +1 -1
- data/lib/rouge/lexers/python.rb +68 -58
- data/lib/rouge/lexers/racket.rb +24 -1
- data/lib/rouge/lexers/rego.rb +45 -0
- data/lib/rouge/lexers/ruby.rb +16 -3
- data/lib/rouge/lexers/rust.rb +3 -11
- data/lib/rouge/lexers/scala.rb +4 -4
- data/lib/rouge/lexers/shell.rb +1 -1
- data/lib/rouge/lexers/sieve.rb +1 -1
- data/lib/rouge/lexers/slice.rb +32 -0
- data/lib/rouge/lexers/solidity.rb +185 -0
- data/lib/rouge/lexers/sqf.rb +2 -2
- data/lib/rouge/lexers/swift.rb +2 -1
- data/lib/rouge/lexers/terraform.rb +15 -0
- data/lib/rouge/lexers/toml.rb +39 -1
- data/lib/rouge/lexers/typescript.rb +11 -0
- data/lib/rouge/lexers/varnish.rb +168 -0
- data/lib/rouge/lexers/verilog.rb +1 -1
- data/lib/rouge/lexers/viml.rb +1 -1
- data/lib/rouge/lexers/vue.rb +4 -1
- data/lib/rouge/lexers/yang.rb +147 -0
- data/lib/rouge/version.rb +1 -1
- metadata +37 -6
- data/lib/rouge/lexers/apache/keywords.yml +0 -764
- data/lib/rouge/lexers/lasso/keywords.yml +0 -446
- data/lib/rouge/lexers/matlab/builtins.yml +0 -3515
data/lib/rouge/lexers/racket.rb
CHANGED
@@ -488,6 +488,9 @@ module Rouge
|
|
488
488
|
state :root do
|
489
489
|
# comments
|
490
490
|
rule %r/;.*$/, Comment::Single
|
491
|
+
rule %r/#!.*/, Comment::Single
|
492
|
+
rule %r/#\|/, Comment::Multiline, :block_comment
|
493
|
+
rule %r/#;/, Comment::Multiline, :sexp_comment
|
491
494
|
rule %r/\s+/m, Text
|
492
495
|
|
493
496
|
rule %r/[+-]inf[.][f0]/, Num::Float
|
@@ -510,7 +513,7 @@ module Rouge
|
|
510
513
|
rule %r/['`]#{id}/i, Str::Symbol
|
511
514
|
rule %r/#\\([()\/'"._!\$%& ?=+-]{1}|[a-z0-9]+)/i,
|
512
515
|
Str::Char
|
513
|
-
rule %r/#t
|
516
|
+
rule %r/#t(rue)?|#f(alse)?/i, Name::Constant
|
514
517
|
rule %r/(?:'|#|`|,@|,|\.)/, Operator
|
515
518
|
|
516
519
|
rule %r/(['#])(\s*)(\()/m do
|
@@ -524,6 +527,26 @@ module Rouge
|
|
524
527
|
rule id, Name::Variable
|
525
528
|
end
|
526
529
|
|
530
|
+
state :block_comment do
|
531
|
+
rule %r/[^|#]+/, Comment::Multiline
|
532
|
+
rule %r/\|#/, Comment::Multiline, :pop!
|
533
|
+
rule %r/#\|/, Comment::Multiline, :block_comment
|
534
|
+
rule %r/[|#]/, Comment::Multiline
|
535
|
+
end
|
536
|
+
|
537
|
+
state :sexp_comment do
|
538
|
+
rule %r/[({\[]/, Comment::Multiline, :sexp_comment_inner
|
539
|
+
rule %r/"(?:\\"|[^"])*?"/, Comment::Multiline, :pop!
|
540
|
+
rule %r/[^\s]+/, Comment::Multiline, :pop!
|
541
|
+
rule(//) { pop! }
|
542
|
+
end
|
543
|
+
|
544
|
+
state :sexp_comment_inner do
|
545
|
+
rule %r/[^(){}\[\]]+/, Comment::Multiline
|
546
|
+
rule %r/[)}\]]/, Comment::Multiline, :pop!
|
547
|
+
rule %r/[({\[]/, Comment::Multiline, :sexp_comment_inner
|
548
|
+
end
|
549
|
+
|
527
550
|
state :command do
|
528
551
|
rule id, Name::Function do |m|
|
529
552
|
if self.class.keywords.include? m[0]
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Rouge
|
5
|
+
module Lexers
|
6
|
+
class Rego < RegexLexer
|
7
|
+
title "Rego"
|
8
|
+
desc "The Rego open-policy-agent (OPA) policy language (openpolicyagent.org)"
|
9
|
+
tag 'rego'
|
10
|
+
filenames '*.rego'
|
11
|
+
|
12
|
+
state :basic do
|
13
|
+
rule %r/\s+/, Text
|
14
|
+
rule %r/#.*/, Comment::Single
|
15
|
+
|
16
|
+
rule %r/[\[\](){}|.,;!]/, Punctuation
|
17
|
+
|
18
|
+
rule %r/"[^"]*"/, Str::Double
|
19
|
+
|
20
|
+
rule %r/-?\d+\.\d+([eE][+-]?\d+)?/, Num::Float
|
21
|
+
rule %r/-?\d+([eE][+-]?\d+)?/, Num
|
22
|
+
|
23
|
+
rule %r/\\u[0-9a-fA-F]{4}/, Num::Hex
|
24
|
+
rule %r/\\["\/bfnrt]/, Str::Escape
|
25
|
+
end
|
26
|
+
|
27
|
+
state :atoms do
|
28
|
+
rule %r/(true|false|null)/, Keyword::Constant
|
29
|
+
rule %r/[[:word:]]*/, Str::Symbol
|
30
|
+
end
|
31
|
+
|
32
|
+
state :operators do
|
33
|
+
rule %r/(=|!=|>=|<=|>|<|\+|-|\*|%|\/|\||&|:=)/, Operator
|
34
|
+
rule %r/(default|not|package|import|as|with|else|some)/, Operator
|
35
|
+
rule %r/[\/:?@^~]+/, Operator
|
36
|
+
end
|
37
|
+
|
38
|
+
state :root do
|
39
|
+
mixin :basic
|
40
|
+
mixin :operators
|
41
|
+
mixin :atoms
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/rouge/lexers/ruby.rb
CHANGED
@@ -170,8 +170,11 @@ module Rouge
|
|
170
170
|
rule %r/0_?[0-7]+(?:_[0-7]+)*/, Num::Oct
|
171
171
|
rule %r/0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*/, Num::Hex
|
172
172
|
rule %r/0b[01]+(?:_[01]+)*/, Num::Bin
|
173
|
-
|
174
|
-
|
173
|
+
|
174
|
+
decimal = %r/[\d]+(?:_\d+)*/
|
175
|
+
exp = %r/e[+-]?\d+/i
|
176
|
+
rule %r/#{decimal}(?:\.#{decimal}#{exp}?|#{exp})/, Num::Float
|
177
|
+
rule decimal, Num::Integer
|
175
178
|
|
176
179
|
# names
|
177
180
|
rule %r/@@[a-z_]\w*/i, Name::Variable::Class
|
@@ -306,6 +309,8 @@ module Rouge
|
|
306
309
|
|
307
310
|
state :classname do
|
308
311
|
rule %r/\s+/, Text
|
312
|
+
rule %r/\w+(::\w+)+/, Name::Class
|
313
|
+
|
309
314
|
rule %r/\(/ do
|
310
315
|
token Punctuation
|
311
316
|
push :defexpr
|
@@ -324,7 +329,15 @@ module Rouge
|
|
324
329
|
end
|
325
330
|
|
326
331
|
state :ternary do
|
327
|
-
rule(
|
332
|
+
rule %r/(:)(\s+)/ do
|
333
|
+
groups Punctuation, Text
|
334
|
+
goto :expr_start
|
335
|
+
end
|
336
|
+
|
337
|
+
rule %r/:(?![^#\n]*?[:\\])/ do
|
338
|
+
token Punctuation
|
339
|
+
goto :expr_start
|
340
|
+
end
|
328
341
|
|
329
342
|
mixin :root
|
330
343
|
end
|
data/lib/rouge/lexers/rust.rb
CHANGED
@@ -96,7 +96,7 @@ module Rouge
|
|
96
96
|
rule %r([=-]>), Keyword
|
97
97
|
rule %r(<->), Keyword
|
98
98
|
rule %r/[()\[\]{}|,:;]/, Punctuation
|
99
|
-
rule %r/[
|
99
|
+
rule %r/[*\/!@~&+%^<>=\?-]|\.{2,3}/, Operator
|
100
100
|
|
101
101
|
rule %r/([.]\s*)?#{id}(?=\s*[(])/m, Name::Function
|
102
102
|
rule %r/[.]\s*#{id}/, Name::Property
|
@@ -159,6 +159,7 @@ module Rouge
|
|
159
159
|
)x, Str::Char
|
160
160
|
|
161
161
|
rule %r/"/, Str, :string
|
162
|
+
rule %r/r(#*)".*?"\1/m, Str
|
162
163
|
|
163
164
|
# numbers
|
164
165
|
dot = /[.][0-9_]+/
|
@@ -185,16 +186,7 @@ module Rouge
|
|
185
186
|
state :string do
|
186
187
|
rule %r/"/, Str, :pop!
|
187
188
|
rule escapes, Str::Escape
|
188
|
-
rule %r
|
189
|
-
rule %r(
|
190
|
-
%
|
191
|
-
( [0-9]+ [$] )? # Parameter
|
192
|
-
[0#+-]* # Flag
|
193
|
-
( [0-9]+ [$]? )? # Width
|
194
|
-
( [.] [0-9]+ )? # Precision
|
195
|
-
[bcdfiostuxX?] # Type
|
196
|
-
)x, Str::Interpol
|
197
|
-
rule %r/[^%"\\]+/m, Str
|
189
|
+
rule %r/[^"\\]+/m, Str
|
198
190
|
end
|
199
191
|
end
|
200
192
|
end
|
data/lib/rouge/lexers/scala.rb
CHANGED
@@ -40,10 +40,10 @@ module Rouge
|
|
40
40
|
groups Keyword, Text
|
41
41
|
push :class
|
42
42
|
end
|
43
|
-
rule %r/'#{idrest}
|
43
|
+
rule %r/'#{idrest}(?!')/, Str::Symbol
|
44
44
|
rule %r/[^\S\n]+/, Text
|
45
45
|
|
46
|
-
rule %r(
|
46
|
+
rule %r(//.*), Comment::Single
|
47
47
|
rule %r(/\*), Comment::Multiline, :comment
|
48
48
|
|
49
49
|
rule %r/@#{idrest}/, Name::Decorator
|
@@ -117,7 +117,7 @@ module Rouge
|
|
117
117
|
rule %r/\s+/, Text
|
118
118
|
rule %r/{/, Operator, :pop!
|
119
119
|
rule %r/\(/, Operator, :pop!
|
120
|
-
rule %r(
|
120
|
+
rule %r(//.*), Comment::Single, :pop!
|
121
121
|
rule %r(#{idrest}|#{op}+|`[^`]+`), Name::Class, :pop!
|
122
122
|
end
|
123
123
|
|
@@ -142,7 +142,7 @@ module Rouge
|
|
142
142
|
pop!
|
143
143
|
end
|
144
144
|
|
145
|
-
rule %r(
|
145
|
+
rule %r(//.*), Comment::Single, :pop!
|
146
146
|
rule %r/\.|#{idrest}|#{op}+|`[^`]+`/, Keyword::Type
|
147
147
|
end
|
148
148
|
|
data/lib/rouge/lexers/shell.rb
CHANGED
@@ -64,7 +64,7 @@ module Rouge
|
|
64
64
|
# here-string
|
65
65
|
rule %r/<<</, Operator
|
66
66
|
|
67
|
-
rule %r/(<<-?)(\s*)(
|
67
|
+
rule %r/(<<-?)(\s*)(['"]?)(\\?)(\w+)(\3)/ do |m|
|
68
68
|
groups Operator, Text, Str::Heredoc, Str::Heredoc, Name::Constant, Str::Heredoc
|
69
69
|
@heredocstr = Regexp.escape(m[5])
|
70
70
|
push :heredoc
|
data/lib/rouge/lexers/sieve.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Rouge
|
5
|
+
module Lexers
|
6
|
+
load_lexer 'c.rb'
|
7
|
+
|
8
|
+
class Slice < C
|
9
|
+
tag 'slice'
|
10
|
+
filenames '*.ice'
|
11
|
+
mimetypes 'text/slice'
|
12
|
+
|
13
|
+
title "Slice"
|
14
|
+
desc "Specification Language for Ice (doc.zeroc.com)"
|
15
|
+
|
16
|
+
def self.keywords
|
17
|
+
@keywords ||= Set.new %w(
|
18
|
+
extends implements enum interface struct class module dictionary
|
19
|
+
const optional out throws exception local idempotent sequence
|
20
|
+
|
21
|
+
Object LocalObject Value
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.keywords_type
|
26
|
+
@keywords_type ||= Set.new %w(
|
27
|
+
bool string byte long float double int void short
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,185 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
|
3
|
+
module Rouge
|
4
|
+
module Lexers
|
5
|
+
class Solidity < RegexLexer
|
6
|
+
title "Solidity"
|
7
|
+
desc "Solidity, an Ethereum smart contract programming language"
|
8
|
+
tag 'solidity'
|
9
|
+
filenames '*.sol', '*.solidity'
|
10
|
+
mimetypes 'text/x-solidity'
|
11
|
+
|
12
|
+
# optional comment or whitespace
|
13
|
+
ws = %r((?:\s|//.*?\n|/[*].*?[*]/)+)
|
14
|
+
id = /[a-zA-Z$_][\w$_]*/
|
15
|
+
|
16
|
+
def self.detect?(text)
|
17
|
+
return true if text.start_with? 'pragma solidity'
|
18
|
+
end
|
19
|
+
|
20
|
+
# TODO: seperate by "type"
|
21
|
+
def self.keywords
|
22
|
+
@keywords ||= Set.new %w(
|
23
|
+
abstract anonymous as assembly break catch calldata constant
|
24
|
+
constructor continue contract do delete else emit enum event
|
25
|
+
external fallback for function hex if indexed interface
|
26
|
+
internal import is library mapping memory modifier new
|
27
|
+
override payable public pure pragma private receive return
|
28
|
+
returns storage struct throw try type using var view virtual
|
29
|
+
while
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.builtins
|
34
|
+
return @builtins if @builtins
|
35
|
+
|
36
|
+
@builtins = Set.new %w(
|
37
|
+
now
|
38
|
+
false true
|
39
|
+
balance now selector super this
|
40
|
+
blockhash gasleft
|
41
|
+
assert require revert
|
42
|
+
selfdestruct suicide
|
43
|
+
call callcode delegatecall
|
44
|
+
send transfer
|
45
|
+
addmod ecrecover keccak256 mulmod sha256 sha3 ripemd160
|
46
|
+
)
|
47
|
+
|
48
|
+
# TODO: use (currently shadowed by catch-all in :statements)
|
49
|
+
abi = %w(decode encode encodePacked encodeWithSelector encodeWithSignature)
|
50
|
+
@builtins.merge( abi.map { |i| "abi.#{i}" } )
|
51
|
+
block = %w(coinbase difficulty gaslimit hash number timestamp)
|
52
|
+
@builtins.merge( block.map { |i| "block.#{i}" } )
|
53
|
+
msg = %w(data gas sender sig value)
|
54
|
+
@builtins.merge( msg.map { |i| "msg.#{i}" } )
|
55
|
+
tx = %w(gasprice origin)
|
56
|
+
@builtins.merge( tx.map { |i| "tx.#{i}" } )
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.constants
|
60
|
+
@constants ||= Set.new %w(
|
61
|
+
wei finney szabo ether
|
62
|
+
seconds minutes hours days weeks years
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.keywords_type
|
67
|
+
@keywords_type ||= Set.new %w(
|
68
|
+
address bool byte bytes int string uint
|
69
|
+
)
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.reserved
|
73
|
+
@reserved ||= Set.new %w(
|
74
|
+
alias after apply auto case copyof default define final fixed
|
75
|
+
immutable implements in inline let macro match mutable null of
|
76
|
+
partial promise reference relocatable sealed sizeof static
|
77
|
+
supports switch typedef typeof ufixed unchecked
|
78
|
+
)
|
79
|
+
end
|
80
|
+
|
81
|
+
start { push :bol }
|
82
|
+
|
83
|
+
state :expr_bol do
|
84
|
+
mixin :inline_whitespace
|
85
|
+
|
86
|
+
rule(//) { pop! }
|
87
|
+
end
|
88
|
+
|
89
|
+
# :expr_bol is the same as :bol but without labels, since
|
90
|
+
# labels can only appear at the beginning of a statement.
|
91
|
+
state :bol do
|
92
|
+
mixin :expr_bol
|
93
|
+
end
|
94
|
+
|
95
|
+
# TODO: natspec in comments
|
96
|
+
state :inline_whitespace do
|
97
|
+
rule %r/[ \t\r]+/, Text
|
98
|
+
rule %r/\\\n/, Text # line continuation
|
99
|
+
rule %r(/\*), Comment::Multiline, :comment_multi
|
100
|
+
end
|
101
|
+
|
102
|
+
state :whitespace do
|
103
|
+
rule %r/\n+/m, Text, :bol
|
104
|
+
rule %r(//(\\.|.)*?\n), Comment::Single, :bol
|
105
|
+
mixin :inline_whitespace
|
106
|
+
end
|
107
|
+
|
108
|
+
state :expr_whitespace do
|
109
|
+
rule %r/\n+/m, Text, :expr_bol
|
110
|
+
mixin :whitespace
|
111
|
+
end
|
112
|
+
|
113
|
+
state :statements do
|
114
|
+
mixin :whitespace
|
115
|
+
rule %r/(hex)?\"/, Str, :string_double
|
116
|
+
rule %r/(hex)?\'/, Str, :string_single
|
117
|
+
rule %r('(\\.|\\[0-7]{1,3}|\\x[a-f0-9]{1,2}|[^\\'\n])')i, Str::Char
|
118
|
+
rule %r/\d\d*\.\d+([eE]\d+)?/i, Num::Float
|
119
|
+
rule %r/0x[0-9a-f]+/i, Num::Hex
|
120
|
+
rule %r/\d+([eE]\d+)?/i, Num::Integer
|
121
|
+
rule %r(\*/), Error
|
122
|
+
rule %r([~!%^&*+=\|?:<>/-]), Operator
|
123
|
+
rule %r/[()\[\],.]/, Punctuation
|
124
|
+
rule %r/u?fixed\d+x\d+/, Keyword::Reserved
|
125
|
+
rule %r/bytes\d+/, Keyword::Type
|
126
|
+
rule %r/u?int\d+/, Keyword::Type
|
127
|
+
rule id do |m|
|
128
|
+
name = m[0]
|
129
|
+
|
130
|
+
if self.class.keywords.include? name
|
131
|
+
token Keyword
|
132
|
+
elsif self.class.builtins.include? name
|
133
|
+
token Name::Builtin
|
134
|
+
elsif self.class.constants.include? name
|
135
|
+
token Keyword::Constant
|
136
|
+
elsif self.class.keywords_type.include? name
|
137
|
+
token Keyword::Type
|
138
|
+
elsif self.class.reserved.include? name
|
139
|
+
token Keyword::Reserved
|
140
|
+
else
|
141
|
+
token Name
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
state :root do
|
147
|
+
mixin :expr_whitespace
|
148
|
+
rule(//) { push :statement }
|
149
|
+
# TODO: function declarations
|
150
|
+
end
|
151
|
+
|
152
|
+
state :statement do
|
153
|
+
rule %r/;/, Punctuation, :pop!
|
154
|
+
mixin :expr_whitespace
|
155
|
+
mixin :statements
|
156
|
+
rule %r/[{}]/, Punctuation
|
157
|
+
end
|
158
|
+
|
159
|
+
state :string_common do
|
160
|
+
rule %r/\\(u[a-fA-F0-9]{4}|x..|[^x])/, Str::Escape
|
161
|
+
rule %r/[^\\\"\'\n]+/, Str
|
162
|
+
rule %r/\\\n/, Str # line continuation
|
163
|
+
rule %r/\\/, Str # stray backslash
|
164
|
+
end
|
165
|
+
|
166
|
+
state :string_double do
|
167
|
+
mixin :string_common
|
168
|
+
rule %r/\"/, Str, :pop!
|
169
|
+
rule %r/\'/, Str
|
170
|
+
end
|
171
|
+
|
172
|
+
state :string_single do
|
173
|
+
mixin :string_common
|
174
|
+
rule %r/\'/, Str, :pop!
|
175
|
+
rule %r/\"/, Str
|
176
|
+
end
|
177
|
+
|
178
|
+
state :comment_multi do
|
179
|
+
rule %r(\*/), Comment::Multiline, :pop!
|
180
|
+
rule %r([^*/]+), Comment::Multiline
|
181
|
+
rule %r([*/]), Comment::Multiline
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
data/lib/rouge/lexers/sqf.rb
CHANGED
@@ -55,7 +55,7 @@ module Rouge
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def self.commands
|
58
|
-
load File.join(
|
58
|
+
load File.join(Lexers::BASE_DIR, "sqf/commands.rb")
|
59
59
|
@commands = self.commands
|
60
60
|
end
|
61
61
|
|
@@ -65,7 +65,7 @@ module Rouge
|
|
65
65
|
|
66
66
|
# Preprocessor instructions
|
67
67
|
rule %r"/\*.*?\*/"m, Comment::Multiline
|
68
|
-
rule %r"
|
68
|
+
rule %r"//.*", Comment::Single
|
69
69
|
rule %r"#(define|undef|if(n)?def|else|endif|include)", Comment::Preproc
|
70
70
|
rule %r"\\\r?\n", Comment::Preproc
|
71
71
|
rule %r"__(EVAL|EXEC|LINE__|FILE__)", Name::Builtin
|