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/swift.rb
CHANGED
@@ -25,7 +25,7 @@ module Rouge
|
|
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
|
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
|
29
29
|
)
|
30
30
|
|
31
31
|
constants = Set.new %w(
|
@@ -67,6 +67,7 @@ module Rouge
|
|
67
67
|
|
68
68
|
state :root do
|
69
69
|
mixin :whitespace
|
70
|
+
|
70
71
|
rule %r/\$(([1-9]\d*)?\d)/, Name::Variable
|
71
72
|
|
72
73
|
rule %r{[()\[\]{}:;,?\\]}, Punctuation
|
@@ -81,9 +81,24 @@ module Rouge
|
|
81
81
|
mixin :expression
|
82
82
|
end
|
83
83
|
|
84
|
+
state :regexps do
|
85
|
+
rule %r/"\// do
|
86
|
+
token Str::Delimiter
|
87
|
+
goto :regexp_inner
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
state :regexp_inner do
|
92
|
+
rule %r/[^"\/\\]+/, Str::Regex
|
93
|
+
rule %r/\\./, Str::Regex
|
94
|
+
rule %r/\/"/, Str::Delimiter, :pop!
|
95
|
+
rule %r/["\/]/, Str::Regex
|
96
|
+
end
|
97
|
+
|
84
98
|
id = /[$a-z_\-][a-z0-9_\-]*/io
|
85
99
|
|
86
100
|
state :expression do
|
101
|
+
mixin :regexps
|
87
102
|
mixin :primitives
|
88
103
|
rule %r/\s+/, Text
|
89
104
|
|
data/lib/rouge/lexers/toml.rb
CHANGED
@@ -17,6 +17,12 @@ module Rouge
|
|
17
17
|
rule %r/\s+/, Text
|
18
18
|
rule %r/#.*?$/, Comment
|
19
19
|
rule %r/(true|false)/, Keyword::Constant
|
20
|
+
|
21
|
+
rule %r/(\S+)(\s*)(=)(\s*)(\{)/ do |m|
|
22
|
+
groups Name::Namespace, Text, Operator, Text, Punctuation
|
23
|
+
push :inline
|
24
|
+
end
|
25
|
+
|
20
26
|
rule %r/(?<!=)\s*\[[\S]+\]/, Name::Namespace
|
21
27
|
|
22
28
|
rule %r/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/, Literal::Date
|
@@ -33,7 +39,6 @@ module Rouge
|
|
33
39
|
groups Name::Property, Text, Punctuation
|
34
40
|
push :value
|
35
41
|
end
|
36
|
-
|
37
42
|
end
|
38
43
|
|
39
44
|
state :value do
|
@@ -43,7 +48,10 @@ module Rouge
|
|
43
48
|
|
44
49
|
state :content do
|
45
50
|
mixin :basic
|
51
|
+
rule %r/"""/, Str, :mdq
|
46
52
|
rule %r/"/, Str, :dq
|
53
|
+
rule %r/'''/, Str, :msq
|
54
|
+
rule %r/'/, Str, :sq
|
47
55
|
mixin :esc_str
|
48
56
|
rule %r/\,/, Punctuation
|
49
57
|
rule %r/\[/, Punctuation, :array
|
@@ -51,8 +59,28 @@ module Rouge
|
|
51
59
|
|
52
60
|
state :dq do
|
53
61
|
rule %r/"/, Str, :pop!
|
62
|
+
rule %r/\n/, Error, :pop!
|
63
|
+
mixin :esc_str
|
64
|
+
rule %r/[^\\"\n]+/, Str
|
65
|
+
end
|
66
|
+
|
67
|
+
state :mdq do
|
68
|
+
rule %r/"""/, Str, :pop!
|
54
69
|
mixin :esc_str
|
55
70
|
rule %r/[^\\"]+/, Str
|
71
|
+
rule %r/"+/, Str
|
72
|
+
end
|
73
|
+
|
74
|
+
state :sq do
|
75
|
+
rule %r/'/, Str, :pop!
|
76
|
+
rule %r/\n/, Error, :pop!
|
77
|
+
rule %r/[^'\n]+/, Str
|
78
|
+
end
|
79
|
+
|
80
|
+
state :msq do
|
81
|
+
rule %r/'''/, Str, :pop!
|
82
|
+
rule %r/[^']+/, Str
|
83
|
+
rule %r/'+/, Str
|
56
84
|
end
|
57
85
|
|
58
86
|
state :esc_str do
|
@@ -63,6 +91,16 @@ module Rouge
|
|
63
91
|
mixin :content
|
64
92
|
rule %r/\]/, Punctuation, :pop!
|
65
93
|
end
|
94
|
+
|
95
|
+
state :inline do
|
96
|
+
mixin :content
|
97
|
+
|
98
|
+
rule %r/(#{identifier})(\s*)(=)/ do
|
99
|
+
groups Name::Property, Text, Punctuation
|
100
|
+
end
|
101
|
+
|
102
|
+
rule %r/\}/, Punctuation, :pop!
|
103
|
+
end
|
66
104
|
end
|
67
105
|
end
|
68
106
|
end
|
@@ -18,6 +18,17 @@ module Rouge
|
|
18
18
|
filenames '*.ts', '*.d.ts'
|
19
19
|
|
20
20
|
mimetypes 'text/typescript'
|
21
|
+
|
22
|
+
prepend :root do
|
23
|
+
rule %r/[?][.]/, Punctuation
|
24
|
+
end
|
25
|
+
|
26
|
+
prepend :statement do
|
27
|
+
rule %r/(#{Javascript.id_regex})(\??)(\s*)(:)/ do
|
28
|
+
groups Name::Label, Punctuation, Text, Punctuation
|
29
|
+
push :expr_start
|
30
|
+
end
|
31
|
+
end
|
21
32
|
end
|
22
33
|
end
|
23
34
|
end
|
@@ -0,0 +1,168 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Rouge
|
5
|
+
module Lexers
|
6
|
+
class Varnish < RegexLexer
|
7
|
+
title 'VCL: Varnish Configuration Language'
|
8
|
+
desc 'The configuration language for Varnish HTTP Cache (varnish-cache.org)'
|
9
|
+
|
10
|
+
tag 'vcl'
|
11
|
+
aliases 'varnishconf', 'varnish'
|
12
|
+
filenames '*.vcl'
|
13
|
+
mimetypes 'text/x-varnish', 'text/x-vcl'
|
14
|
+
|
15
|
+
SPACE = '[ \f\n\r\t\v]+'
|
16
|
+
|
17
|
+
# backend acl
|
18
|
+
def self.keywords
|
19
|
+
@keywords ||= Set.new %w[
|
20
|
+
vcl set unset include import if else elseif elif elsif director probe
|
21
|
+
backend acl
|
22
|
+
|
23
|
+
declare local
|
24
|
+
BOOL FLOAT INTEGER IP RTIME STRING TIME
|
25
|
+
]
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.functions
|
29
|
+
@functions ||= Set.new %w[
|
30
|
+
ban call hash_data new regsub regsuball return rollback
|
31
|
+
std.cache_req_body std.collect std.duration std.fileread std.healthy
|
32
|
+
std.integer std.ip std.log std.port std.querysort std.random std.real
|
33
|
+
std.real2time std.rollback std.set_ip_tos std.strstr std.syslog
|
34
|
+
std.time std.time2integer std.time2real std.timestamp std.tolower
|
35
|
+
std.toupper synth synthetic
|
36
|
+
]
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.variables
|
40
|
+
@variables ||= Set.new %w[
|
41
|
+
bereq bereq.backend bereq.between_bytes_timeout bereq.connect_timeout
|
42
|
+
bereq.first_byte_timeout bereq.method bereq.proto bereq.retries
|
43
|
+
bereq.uncacheable bereq.url bereq.xid beresp beresp.age
|
44
|
+
beresp.backend beresp.backend.ip beresp.backend.name beresp.do_esi
|
45
|
+
beresp.do_gunzip beresp.do_gzip beresp.do_stream beresp.grace
|
46
|
+
beresp.keep beresp.proto beresp.reason beresp.status
|
47
|
+
beresp.storage_hint beresp.ttl beresp.uncacheable beresp.was_304
|
48
|
+
client.identity client.ip local.ip now obj.age obj.grace obj.hits
|
49
|
+
obj.keep obj.proto obj.reason obj.status obj.ttl obj.uncacheable
|
50
|
+
remote.ip req req.backend_hint req.can_gzip req.esi req.esi_level
|
51
|
+
req.hash_always_miss req.hash_ignore_busy req.method req.proto
|
52
|
+
req.restarts req.ttl req.url req.xid resp resp.proto resp.reason
|
53
|
+
resp.status server.hostname server.identity server.ip
|
54
|
+
]
|
55
|
+
end
|
56
|
+
|
57
|
+
# This is never used
|
58
|
+
# def self.routines
|
59
|
+
# @routines ||= Set.new %w[
|
60
|
+
# backend_error backend_fetch backend_response purge deliver fini hash
|
61
|
+
# hit init miss pass pipe recv synth
|
62
|
+
# ]
|
63
|
+
# end
|
64
|
+
|
65
|
+
state :root do
|
66
|
+
# long strings ({" ... "})
|
67
|
+
rule %r/\{".*?"}/m, Str::Single
|
68
|
+
|
69
|
+
# heredoc style long strings ({xyz"..."xyz})
|
70
|
+
rule %r/\{(\w+)".*?"(\1)\}/m, Str::Single
|
71
|
+
|
72
|
+
# comments
|
73
|
+
rule %r'/\*.*?\*/'m, Comment::Multiline
|
74
|
+
rule %r'(?://|#).*', Comment::Single
|
75
|
+
|
76
|
+
rule %r/true|false/, Keyword::Constant
|
77
|
+
|
78
|
+
# "wildcard variables"
|
79
|
+
var_prefix = Regexp.union(%w(beresp bereq resp req obj))
|
80
|
+
rule %r/(?:#{var_prefix})\.http\.[\w.-]+/ do
|
81
|
+
token Name::Variable
|
82
|
+
end
|
83
|
+
|
84
|
+
# local variables (var.*)
|
85
|
+
rule %r/(?:var)\.[\w.-]+/ do
|
86
|
+
token Name::Variable
|
87
|
+
end
|
88
|
+
|
89
|
+
rule %r/(sub)(#{SPACE})([\w-]+)/ do
|
90
|
+
groups Keyword, Text, Name::Function
|
91
|
+
end
|
92
|
+
|
93
|
+
# inline C (C{ ... }C)
|
94
|
+
rule %r/C\{/ do
|
95
|
+
token Comment::Preproc
|
96
|
+
push :inline_c
|
97
|
+
end
|
98
|
+
|
99
|
+
rule %r/\.?[a-z_][\w.-]*/i do |m|
|
100
|
+
next token Keyword if self.class.keywords.include? m[0]
|
101
|
+
next token Name::Function if self.class.functions.include? m[0]
|
102
|
+
next token Name::Variable if self.class.variables.include? m[0]
|
103
|
+
token Text
|
104
|
+
end
|
105
|
+
|
106
|
+
## for number literals
|
107
|
+
|
108
|
+
decimal = %r/[0-9]+/
|
109
|
+
hex = %r/[0-9a-f]+/i
|
110
|
+
|
111
|
+
numeric = %r{
|
112
|
+
(?:
|
113
|
+
0x#{hex}
|
114
|
+
(?:\.#{hex})?
|
115
|
+
(?:p[+-]?#{hex})?
|
116
|
+
)
|
117
|
+
|
|
118
|
+
(?:
|
119
|
+
#{decimal}
|
120
|
+
(?:\.#{decimal})?
|
121
|
+
(?:e[+-]?#{decimal})?
|
122
|
+
)
|
123
|
+
}xi
|
124
|
+
|
125
|
+
# duration literals
|
126
|
+
duration_suffix = Regexp.union(%w(ms s m h d w y))
|
127
|
+
rule %r/#{numeric}#{duration_suffix}/, Num::Other
|
128
|
+
|
129
|
+
# numeric literals (integer / float)
|
130
|
+
rule numeric do |m|
|
131
|
+
case m[0]
|
132
|
+
when /^#{decimal}$/
|
133
|
+
token Num::Integer
|
134
|
+
when /^0x#{hex}$/
|
135
|
+
token Num::Integer
|
136
|
+
else
|
137
|
+
token Num::Float
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
# standard strings
|
142
|
+
rule %r/"/, Str::Double, :string
|
143
|
+
|
144
|
+
rule %r'[&|+-]{2}|[<=>!*/+-]=|<<|>>|!~|[-+*/%><=!&|~]', Operator
|
145
|
+
|
146
|
+
rule %r/[{}();.,]/, Punctuation
|
147
|
+
|
148
|
+
rule %r/\r\n?|\n/, Text
|
149
|
+
rule %r/./, Text
|
150
|
+
end
|
151
|
+
|
152
|
+
state :string do
|
153
|
+
rule %r/"/, Str::Double, :pop!
|
154
|
+
rule %r/\\[\\"nt]/, Str::Escape
|
155
|
+
|
156
|
+
rule %r/\r\n?|\n/, Str::Double
|
157
|
+
rule %r/./, Str::Double
|
158
|
+
end
|
159
|
+
|
160
|
+
state :inline_c do
|
161
|
+
rule %r/}C/, Comment::Preproc, :pop!
|
162
|
+
rule %r/.*?(?=}C)/m do
|
163
|
+
delegate C
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
data/lib/rouge/lexers/verilog.rb
CHANGED
data/lib/rouge/lexers/viml.rb
CHANGED
data/lib/rouge/lexers/vue.rb
CHANGED
@@ -58,6 +58,10 @@ module Rouge
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
+
prepend :tag do
|
62
|
+
rule %r/[a-zA-Z0-9_:#\[\]()*.-]+\s*=\s*/m, Name::Attribute, :attr
|
63
|
+
end
|
64
|
+
|
61
65
|
state :style do
|
62
66
|
rule %r/(<\s*\/\s*)(style)(\s*>)/ do
|
63
67
|
groups Name::Tag, Keyword, Name::Tag
|
@@ -121,4 +125,3 @@ module Rouge
|
|
121
125
|
end
|
122
126
|
end
|
123
127
|
end
|
124
|
-
|
@@ -0,0 +1,147 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Rouge
|
5
|
+
module Lexers
|
6
|
+
class YANG < RegexLexer
|
7
|
+
title 'YANG'
|
8
|
+
desc "Lexer for the YANG 1.1 modeling language (RFC7950)"
|
9
|
+
tag 'yang'
|
10
|
+
filenames '*.yang'
|
11
|
+
mimetypes 'application/yang'
|
12
|
+
|
13
|
+
id = /[\w_-]+(?=[^\w\-\:])\b/
|
14
|
+
|
15
|
+
#Keywords from RFC7950 ; oriented at BNF style
|
16
|
+
def self.top_stmts_keywords
|
17
|
+
@top_stms_keywords ||= Set.new %w(
|
18
|
+
module submodule
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.module_header_stmts_keywords
|
23
|
+
@module_header_stmts_keywords ||= Set.new %w(
|
24
|
+
belongs-to namespace prefix yang-version
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.meta_stmts_keywords
|
29
|
+
@meta_stmts_keywords ||= Set.new %w(
|
30
|
+
contact description organization reference revision
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.linkage_stmts_keywords
|
35
|
+
@linkage_stmts_keywords ||= Set.new %w(
|
36
|
+
import include revision-date
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.body_stmts_keywords
|
41
|
+
@body_stms_keywords ||= Set.new %w(
|
42
|
+
action argument augment deviation extension feature grouping identity
|
43
|
+
if-feature input notification output rpc typedef
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.data_def_stmts_keywords
|
48
|
+
@data_def_stms_keywords ||= Set.new %w(
|
49
|
+
anydata anyxml case choice config container deviate leaf leaf-list
|
50
|
+
list must presence refine uses when
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.type_stmts_keywords
|
55
|
+
@type_stmts_keywords ||= Set.new %w(
|
56
|
+
base bit default enum error-app-tag error-message fraction-digits
|
57
|
+
length max-elements min-elements modifier ordered-by path pattern
|
58
|
+
position range require-instance status type units value yin-element
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.list_stmts_keywords
|
63
|
+
@list_stmts_keywords ||= Set.new %w(
|
64
|
+
key mandatory unique
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
68
|
+
#RFC7950 other keywords
|
69
|
+
def self.constants_keywords
|
70
|
+
@constants_keywords ||= Set.new %w(
|
71
|
+
add current delete deprecated false invert-match max min
|
72
|
+
not-supported obsolete replace true unbounded user
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
#RFC7950 Built-In Types
|
77
|
+
def self.types
|
78
|
+
@types ||= Set.new %w(
|
79
|
+
binary bits boolean decimal64 empty enumeration identityref
|
80
|
+
instance-identifier int16 int32 int64 int8 leafref string uint16
|
81
|
+
uint32 uint64 uint8 union
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
state :comment do
|
86
|
+
rule %r/[^*\/]/, Comment
|
87
|
+
rule %r/\/\*/, Comment, :comment
|
88
|
+
rule %r/\*\//, Comment, :pop!
|
89
|
+
rule %r/[*\/]/, Comment
|
90
|
+
end
|
91
|
+
|
92
|
+
#Keyword::Reserved
|
93
|
+
#groups Name::Tag, Text::Whitespace
|
94
|
+
state :root do
|
95
|
+
rule %r/\s+/, Text::Whitespace
|
96
|
+
rule %r/[\{\}\;]+/, Punctuation
|
97
|
+
rule %r/(?<![\-\w])(and|or|not|\+|\.)(?![\-\w])/, Operator
|
98
|
+
|
99
|
+
rule %r/"(?:\\"|[^"])*?"/, Str::Double #for double quotes
|
100
|
+
rule %r/'(?:\\'|[^'])*?'/, Str::Single #for single quotes
|
101
|
+
|
102
|
+
rule %r/\/\*/, Comment, :comment
|
103
|
+
rule %r/\/\/.*?$/, Comment
|
104
|
+
|
105
|
+
#match BNF stmt for `node-identifier` with [ prefix ":"]
|
106
|
+
rule %r/(?:^|(?<=[\s{};]))([\w.-]+)(:)([\w.-]+)(?=[\s{};])/ do
|
107
|
+
groups Name::Namespace, Punctuation, Name
|
108
|
+
end
|
109
|
+
|
110
|
+
#match BNF stmt `date-arg-str`
|
111
|
+
rule %r/([0-9]{4}\-[0-9]{2}\-[0-9]{2})(?=[\s\{\}\;])/, Name::Label
|
112
|
+
rule %r/([0-9]+\.[0-9]+)(?=[\s\{\}\;])/, Num::Float
|
113
|
+
rule %r/([0-9]+)(?=[\s\{\}\;])/, Num::Integer
|
114
|
+
|
115
|
+
rule id do |m|
|
116
|
+
name = m[0].downcase
|
117
|
+
|
118
|
+
if self.class.top_stmts_keywords.include? name
|
119
|
+
token Keyword::Declaration
|
120
|
+
elsif self.class.module_header_stmts_keywords.include? name
|
121
|
+
token Keyword::Declaration
|
122
|
+
elsif self.class.meta_stmts_keywords.include? name
|
123
|
+
token Keyword::Declaration
|
124
|
+
elsif self.class.linkage_stmts_keywords.include? name
|
125
|
+
token Keyword::Declaration
|
126
|
+
elsif self.class.body_stmts_keywords.include? name
|
127
|
+
token Keyword::Declaration
|
128
|
+
elsif self.class.data_def_stmts_keywords.include? name
|
129
|
+
token Keyword::Declaration
|
130
|
+
elsif self.class.type_stmts_keywords.include? name
|
131
|
+
token Keyword::Declaration
|
132
|
+
elsif self.class.list_stmts_keywords.include? name
|
133
|
+
token Keyword::Declaration
|
134
|
+
elsif self.class.types.include? name
|
135
|
+
token Keyword::Type
|
136
|
+
elsif self.class.constants_keywords.include? name
|
137
|
+
token Name::Constant
|
138
|
+
else
|
139
|
+
token Name
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
rule %r/[^;{}\s'"]+/, Name
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|