rouge 3.28.0 → 3.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -1
- data/lib/rouge/demos/brainfuck +1 -1
- data/lib/rouge/demos/brightscript +1 -1
- data/lib/rouge/demos/bsl +1 -1
- data/lib/rouge/demos/cfscript +1 -1
- data/lib/rouge/demos/coq +1 -1
- data/lib/rouge/demos/csvs +1 -1
- data/lib/rouge/demos/datastudio +0 -1
- data/lib/rouge/demos/ecl +0 -1
- data/lib/rouge/demos/erlang +1 -1
- data/lib/rouge/demos/fsharp +1 -1
- data/lib/rouge/demos/glsl +1 -1
- data/lib/rouge/demos/haxe +0 -1
- data/lib/rouge/demos/idris +13 -0
- data/lib/rouge/demos/lean +8 -0
- data/lib/rouge/demos/nesasm +1 -1
- data/lib/rouge/demos/opentype_feature_file +0 -1
- data/lib/rouge/demos/plsql +2 -0
- data/lib/rouge/demos/smarty +0 -1
- data/lib/rouge/demos/syzlang +15 -0
- data/lib/rouge/demos/syzprog +8 -0
- data/lib/rouge/formatters/html_inline.rb +0 -1
- data/lib/rouge/lexer.rb +2 -2
- data/lib/rouge/lexers/apache/keywords.rb +1 -1
- data/lib/rouge/lexers/docker.rb +4 -0
- data/lib/rouge/lexers/eiffel.rb +0 -1
- data/lib/rouge/lexers/gherkin/keywords.rb +1 -1
- data/lib/rouge/lexers/handlebars.rb +1 -1
- data/lib/rouge/lexers/hylang.rb +0 -1
- data/lib/rouge/lexers/idris.rb +210 -0
- data/lib/rouge/lexers/jsx.rb +0 -1
- data/lib/rouge/lexers/lasso/keywords.rb +1 -1
- data/lib/rouge/lexers/lean.rb +164 -0
- data/lib/rouge/lexers/llvm/keywords.rb +1 -1
- data/lib/rouge/lexers/lua/keywords.rb +1 -1
- data/lib/rouge/lexers/mathematica/keywords.rb +1 -1
- data/lib/rouge/lexers/matlab/keywords.rb +1 -1
- data/lib/rouge/lexers/matlab.rb +3 -2
- data/lib/rouge/lexers/ocl.rb +0 -1
- data/lib/rouge/lexers/php/keywords.rb +1 -1
- data/lib/rouge/lexers/plsql.rb +578 -0
- data/lib/rouge/lexers/prometheus.rb +0 -1
- data/lib/rouge/lexers/python.rb +3 -1
- data/lib/rouge/lexers/q.rb +0 -1
- data/lib/rouge/lexers/sqf/keywords.rb +1 -1
- data/lib/rouge/lexers/supercollider.rb +0 -1
- data/lib/rouge/lexers/syzlang.rb +317 -0
- data/lib/rouge/lexers/syzprog.rb +122 -0
- data/lib/rouge/lexers/tap.rb +0 -1
- data/lib/rouge/lexers/tsx.rb +0 -1
- data/lib/rouge/lexers/tulip.rb +0 -1
- data/lib/rouge/lexers/viml/keywords.rb +1 -1
- data/lib/rouge/version.rb +1 -1
- metadata +16 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15e78361e4f2dde8ae802ffcd36cc0b1e8e9124c2bbe0d3182a767244047a9e0
|
4
|
+
data.tar.gz: 661838ffd5b8c6ff8ac894312293aa6c46b36abed76ccc8f0932358e6478c8b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21f210c421a0a0137d57f2c7fd3b3d931a1b481a276e6fe6eb296a5e1572ccb7ffd3912a8455e98c362b863ab52773b27c7d9135e2cddaa7b75b5fa324f4036e
|
7
|
+
data.tar.gz: 9bb3d495c856a8e790cc38736afb4e187b5b34fa8d1f0c1b99ff60af63cec60a9312ee4a69a642e31938dd4586647e224f311afdde6d343bcafa35b64110f2a3
|
data/Gemfile
CHANGED
@@ -11,7 +11,8 @@ gem 'minitest-power_assert'
|
|
11
11
|
gem 'power_assert', '~> 1.2'
|
12
12
|
|
13
13
|
gem 'parallel', '~> 1.13.0' if RUBY_VERSION < '2.2.0'
|
14
|
-
gem 'rubocop', '~> 0.
|
14
|
+
gem 'rubocop', '~> 1.0', '<= 1.11'
|
15
|
+
gem 'rubocop-performance'
|
15
16
|
|
16
17
|
# don't try to install redcarpet under jruby
|
17
18
|
gem 'redcarpet', :platforms => :ruby
|
data/lib/rouge/demos/brainfuck
CHANGED
data/lib/rouge/demos/bsl
CHANGED
data/lib/rouge/demos/cfscript
CHANGED
data/lib/rouge/demos/coq
CHANGED
data/lib/rouge/demos/csvs
CHANGED
data/lib/rouge/demos/datastudio
CHANGED
data/lib/rouge/demos/ecl
CHANGED
data/lib/rouge/demos/erlang
CHANGED
data/lib/rouge/demos/fsharp
CHANGED
data/lib/rouge/demos/glsl
CHANGED
data/lib/rouge/demos/haxe
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
import Data.Vect
|
2
|
+
|
3
|
+
insert : Ord elem =>
|
4
|
+
(x : elem) -> (xsSorted : Vect len elem) -> Vect (S len) elem
|
5
|
+
insert x [] = [x]
|
6
|
+
insert x (y :: xs) = case x < y of
|
7
|
+
True => x :: y :: xs
|
8
|
+
False => y :: insert x xs
|
9
|
+
|
10
|
+
insSort : Ord elem => Vect n elem -> Vect n elem
|
11
|
+
insSort [] = []
|
12
|
+
insSort (x :: xs) = let xsSorted = insSort xs in
|
13
|
+
insert x xsSorted
|
data/lib/rouge/demos/nesasm
CHANGED
data/lib/rouge/demos/smarty
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
include <linux/test.h>
|
2
|
+
|
3
|
+
resource fd_test[fd]
|
4
|
+
|
5
|
+
openat$test(fd const[AT_FDCWD], file ptr[in, string["/dev/test"]], flags flags[open_flags], mode const[0]) fd_test
|
6
|
+
|
7
|
+
ioctl$TEST(fd fd_test, cmd const[TEST], arg ptr[in, test])
|
8
|
+
|
9
|
+
test {
|
10
|
+
number int32
|
11
|
+
size len[data, int32]
|
12
|
+
data array[int8]
|
13
|
+
}
|
14
|
+
|
15
|
+
_ = TEST
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Source: https://github.com/google/syzkaller/blob/master/sys/linux/test/vusb_hid
|
2
|
+
|
3
|
+
r0 = syz_usb_connect$hid(0x0, 0x36, &(0x7f0000000040)=ANY=[@ANYBLOB="12010000000018105e04da07000000000001090224000100000000090400000903000000092100000001222200090581030800000000"], 0x0)
|
4
|
+
syz_usb_control_io$hid(r0, 0x0, 0x0)
|
5
|
+
syz_usb_control_io$hid(r0, &(0x7f00000001c0)={0x24, 0x0, 0x0, &(0x7f0000000000)={0x0, 0x22, 0x22, {[@global=@item_012={0x2, 0x1, 0x9, "2313"}, @global=@item_012={0x2, 0x1, 0x0, "e53f"}, @global=@item_4={0x3, 0x1, 0x0, '\f\x00'}, @local=@item_012={0x2, 0x2, 0x2, "9000"}, @global=@item_4={0x3, 0x1, 0x0, "0900be00"}, @main=@item_4={0x3, 0x0, 0x8, '\x00'}, @local=@item_4={0x3, 0x2, 0x0, "09007a15"}, @local=@item_4={0x3, 0x2, 0x0, "5d8c3dda"}]}}, 0x0}, 0x0)
|
6
|
+
syz_usb_ep_write(r0, 0x81, 0x7, &(0x7f0000000000)='BBBBBBB')
|
7
|
+
syz_usb_ep_write(r0, 0x81, 0x7, &(0x7f0000000000)='BBBBBBB')
|
8
|
+
syz_usb_ep_write(r0, 0x81, 0x7, &(0x7f0000000000)='BBBBBBB')
|
data/lib/rouge/lexer.rb
CHANGED
@@ -293,8 +293,8 @@ module Rouge
|
|
293
293
|
|
294
294
|
# @private
|
295
295
|
def assert_utf8!(str)
|
296
|
-
encoding = str.encoding
|
297
|
-
return if encoding ==
|
296
|
+
encoding = str.encoding
|
297
|
+
return if encoding == Encoding::US_ASCII || encoding == Encoding::UTF_8 || encoding == Encoding::BINARY
|
298
298
|
|
299
299
|
raise EncodingError.new(
|
300
300
|
"Bad encoding: #{str.encoding.names.join(',')}. " +
|
data/lib/rouge/lexers/docker.rb
CHANGED
@@ -20,6 +20,10 @@ module Rouge
|
|
20
20
|
state :root do
|
21
21
|
rule %r/\s+/, Text
|
22
22
|
|
23
|
+
rule %r/^(FROM)(\s+)(.*)(\s+)(AS)(\s+)(.*)/io do
|
24
|
+
groups Keyword, Text::Whitespace, Str, Text::Whitespace, Keyword, Text::Whitespace, Str
|
25
|
+
end
|
26
|
+
|
23
27
|
rule %r/^(ONBUILD)(\s+)(#{KEYWORDS})(.*)/io do
|
24
28
|
groups Keyword, Text::Whitespace, Keyword, Str
|
25
29
|
end
|
data/lib/rouge/lexers/eiffel.rb
CHANGED
data/lib/rouge/lexers/hylang.rb
CHANGED
@@ -0,0 +1,210 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Rouge
|
5
|
+
module Lexers
|
6
|
+
class Idris < RegexLexer
|
7
|
+
title "Idris"
|
8
|
+
desc "The Idris programming language (idris-lang.org)"
|
9
|
+
|
10
|
+
tag 'idris'
|
11
|
+
aliases 'idr'
|
12
|
+
filenames '*.idr'
|
13
|
+
mimetypes 'text/x-idris'
|
14
|
+
|
15
|
+
def self.reserved_keywords
|
16
|
+
@reserved_keywords ||= %w(
|
17
|
+
_ data class instance namespace
|
18
|
+
infix[lr]? let where of with type
|
19
|
+
do if then else case in
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.ascii
|
24
|
+
@ascii ||= %w(
|
25
|
+
NUL SOH [SE]TX EOT ENQ ACK BEL BS HT LF VT FF CR S[OI] DLE
|
26
|
+
DC[1-4] NAK SYN ETB CAN EM SUB ESC [FGRU]S SP DEL
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.prelude_functions
|
31
|
+
@prelude_functions ||= %w(
|
32
|
+
abs acos all and any asin atan atan2 break ceiling compare concat
|
33
|
+
concatMap const cos cosh curry cycle div drop dropWhile elem
|
34
|
+
encodeFloat enumFrom enumFromThen enumFromThenTo enumFromTo exp
|
35
|
+
fail filter flip floor foldl foldl1 foldr foldr1 fromInteger fst
|
36
|
+
gcd getChar getLine head id init iterate last lcm length lines log
|
37
|
+
lookup map max maxBound maximum maybe min minBound minimum mod
|
38
|
+
negate not null or pi pred print product putChar putStr putStrLn
|
39
|
+
readFile recip repeat replicate return reverse scanl scanl1 sequence
|
40
|
+
sequence_ show sin sinh snd span splitAt sqrt succ sum tail take
|
41
|
+
takeWhile tan tanh uncurry unlines unwords unzip unzip3 words
|
42
|
+
writeFile zip zip3 zipWith zipWith3
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
state :basic do
|
47
|
+
rule %r/\s+/m, Text
|
48
|
+
rule %r/{-#/, Comment::Preproc, :comment_preproc
|
49
|
+
rule %r/{-/, Comment::Multiline, :comment
|
50
|
+
rule %r/^\|\|\|.*$/, Comment::Doc
|
51
|
+
rule %r/--(?![!#\$\%&*+.\/<=>?@\^\|_~]).*?$/, Comment::Single
|
52
|
+
end
|
53
|
+
|
54
|
+
# nested commenting
|
55
|
+
state :comment do
|
56
|
+
rule %r/-}/, Comment::Multiline, :pop!
|
57
|
+
rule %r/{-/, Comment::Multiline, :comment
|
58
|
+
rule %r/[^-{}]+/, Comment::Multiline
|
59
|
+
rule %r/[-{}]/, Comment::Multiline
|
60
|
+
end
|
61
|
+
state :comment_preproc do
|
62
|
+
rule %r/-}/, Comment::Preproc, :pop!
|
63
|
+
rule %r/{-/, Comment::Preproc, :comment
|
64
|
+
rule %r/[^-{}]+/, Comment::Preproc
|
65
|
+
rule %r/[-{}]/, Comment::Preproc
|
66
|
+
end
|
67
|
+
|
68
|
+
state :directive do
|
69
|
+
rule %r/\%(default)\s+(total|partial)/, Keyword # totality
|
70
|
+
rule %r/\%(access)\s+(public|abstract|private|export)/, Keyword # export
|
71
|
+
rule %r/\%(language)\s+(.*)/, Keyword # language
|
72
|
+
rule %r/\%(provide)\s+.*\s+(with)\s+/, Keyword # type
|
73
|
+
end
|
74
|
+
|
75
|
+
state :prelude do
|
76
|
+
rule %r/\b(Type|Exists|World|IO|IntTy|FTy|File|Mode|Dec|Bool|Ordering|Either|IsJust|List|Maybe|Nat|Stream|StrM|Not|Lazy|Inf)\s/, Keyword::Type
|
77
|
+
rule %r/\b(Eq|Ord|Num|MinBound|MaxBound|Integral|Applicative|Alternative|Cast|Foldable|Functor|Monad|Traversable|Uninhabited|Semigroup|Monoid)\s/, Name::Class
|
78
|
+
rule %r/\b(?:#{Idris.prelude_functions.join('|')})[ ]+(?![=:-])/, Name::Builtin
|
79
|
+
end
|
80
|
+
|
81
|
+
state :root do
|
82
|
+
mixin :basic
|
83
|
+
mixin :directive
|
84
|
+
|
85
|
+
rule %r/\bimport\b/, Keyword::Reserved, :import
|
86
|
+
rule %r/\bmodule\b/, Keyword::Reserved, :module
|
87
|
+
rule %r/\b(?:#{Idris.reserved_keywords.join('|')})\b/, Keyword::Reserved
|
88
|
+
rule %r/\b(Just|Nothing|Left|Right|True|False|LT|LTE|EQ|GT|GTE)\b/, Keyword::Constant
|
89
|
+
# function signature
|
90
|
+
rule %r/^[\w']+\s*:/, Name::Function
|
91
|
+
# should be below as you can override names defined in Prelude
|
92
|
+
mixin :prelude
|
93
|
+
rule %r/[_a-z][\w']*/, Name
|
94
|
+
rule %r/[A-Z][\w']*/, Keyword::Type
|
95
|
+
|
96
|
+
# lambda operator
|
97
|
+
rule %r(\\(?![:!#\$\%&*+.\\/<=>?@^\|~-]+)), Name::Function
|
98
|
+
# special operators
|
99
|
+
rule %r((<-|::|->|=>|=)(?![:!#\$\%&*+.\\/<=>?@^\|~-]+)), Operator
|
100
|
+
# constructor/type operators
|
101
|
+
rule %r(:[:!#\$\%&*+.\\/<=>?@^\|~-]*), Operator
|
102
|
+
# other operators
|
103
|
+
rule %r([:!#\$\%&*+.\\/<=>?@^\|~-]+), Operator
|
104
|
+
|
105
|
+
rule %r/\d+(\.\d+)?(e[+-]?\d+)?/i, Num::Float
|
106
|
+
rule %r/0o[0-7]+/i, Num::Oct
|
107
|
+
rule %r/0x[\da-f]+/i, Num::Hex
|
108
|
+
rule %r/\d+/, Num::Integer
|
109
|
+
|
110
|
+
rule %r/'/, Str::Char, :character
|
111
|
+
rule %r/"/, Str, :string
|
112
|
+
|
113
|
+
rule %r/\[\s*\]/, Keyword::Type
|
114
|
+
rule %r/\(\s*\)/, Name::Builtin
|
115
|
+
|
116
|
+
# Quasiquotations
|
117
|
+
rule %r/(\[)([_a-z][\w']*)(\|)/ do |m|
|
118
|
+
token Operator, m[1]
|
119
|
+
token Name, m[2]
|
120
|
+
token Operator, m[3]
|
121
|
+
push :quasiquotation
|
122
|
+
end
|
123
|
+
|
124
|
+
rule %r/[\[\](),;`{}]/, Punctuation
|
125
|
+
end
|
126
|
+
|
127
|
+
state :import do
|
128
|
+
rule %r/\s+/, Text
|
129
|
+
rule %r/"/, Str, :string
|
130
|
+
# import X as Y
|
131
|
+
rule %r/([A-Z][\w.]*)(\s+)(as)(\s+)([A-Z][a-zA-Z0-9_.]*)/ do
|
132
|
+
groups(
|
133
|
+
Name::Namespace, # X
|
134
|
+
Text, Keyword, # as
|
135
|
+
Text, Name # Y
|
136
|
+
)
|
137
|
+
pop!
|
138
|
+
end
|
139
|
+
|
140
|
+
# import X (functions)
|
141
|
+
rule %r/([A-Z][\w.]*)(\s+)(\()/ do
|
142
|
+
groups(
|
143
|
+
Name::Namespace, # X
|
144
|
+
Text,
|
145
|
+
Punctuation # (
|
146
|
+
)
|
147
|
+
goto :funclist
|
148
|
+
end
|
149
|
+
|
150
|
+
rule %r/[\w.]+/, Name::Namespace, :pop!
|
151
|
+
end
|
152
|
+
|
153
|
+
state :module do
|
154
|
+
rule %r/\s+/, Text
|
155
|
+
# module X
|
156
|
+
rule %r/([A-Z][\w.]*)/, Name::Namespace, :pop!
|
157
|
+
end
|
158
|
+
|
159
|
+
state :funclist do
|
160
|
+
mixin :basic
|
161
|
+
rule %r/[A-Z]\w*/, Keyword::Type
|
162
|
+
rule %r/(_[\w\']+|[a-z][\w\']*)/, Name::Function
|
163
|
+
rule %r/,/, Punctuation
|
164
|
+
rule %r/[:!#\$\%&*+.\\\/<=>?@^\|~-]+/, Operator
|
165
|
+
rule %r/\(/, Punctuation, :funclist
|
166
|
+
rule %r/\)/, Punctuation, :pop!
|
167
|
+
end
|
168
|
+
|
169
|
+
state :character do
|
170
|
+
rule %r/\\/ do
|
171
|
+
token Str::Escape
|
172
|
+
goto :character_end
|
173
|
+
push :escape
|
174
|
+
end
|
175
|
+
|
176
|
+
rule %r/./ do
|
177
|
+
token Str::Char
|
178
|
+
goto :character_end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
state :character_end do
|
183
|
+
rule %r/'/, Str::Char, :pop!
|
184
|
+
rule %r/./, Error, :pop!
|
185
|
+
end
|
186
|
+
|
187
|
+
state :quasiquotation do
|
188
|
+
rule %r/\|\]/, Operator, :pop!
|
189
|
+
rule %r/[^\|]+/m, Text
|
190
|
+
rule %r/\|/, Text
|
191
|
+
end
|
192
|
+
|
193
|
+
state :string do
|
194
|
+
rule %r/"/, Str, :pop!
|
195
|
+
rule %r/\\/, Str::Escape, :escape
|
196
|
+
rule %r/[^\\"]+/, Str
|
197
|
+
end
|
198
|
+
|
199
|
+
state :escape do
|
200
|
+
rule %r/[abfnrtv"'&\\]/, Str::Escape, :pop!
|
201
|
+
rule %r/\^[\]\[A-Z@\^_]/, Str::Escape, :pop!
|
202
|
+
rule %r/#{Idris.ascii.join('|')}/, Str::Escape, :pop!
|
203
|
+
rule %r/o[0-7]+/i, Str::Escape, :pop!
|
204
|
+
rule %r/x[\da-fA-F]+/i, Str::Escape, :pop!
|
205
|
+
rule %r/\d+/, Str::Escape, :pop!
|
206
|
+
rule %r/\s+\\/, Str::Escape, :pop!
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
data/lib/rouge/lexers/jsx.rb
CHANGED
@@ -0,0 +1,164 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# NOTE: This is for Lean 3 (community fork).
|
5
|
+
module Rouge
|
6
|
+
module Lexers
|
7
|
+
class Lean < RegexLexer
|
8
|
+
title 'Lean'
|
9
|
+
desc 'The Lean programming language (leanprover.github.io)'
|
10
|
+
tag 'lean'
|
11
|
+
aliases 'lean'
|
12
|
+
filenames '*.lean'
|
13
|
+
|
14
|
+
def self.keywords
|
15
|
+
@keywords ||= Set.new %w(
|
16
|
+
abbreviation
|
17
|
+
add_rewrite
|
18
|
+
alias
|
19
|
+
assume
|
20
|
+
axiom
|
21
|
+
begin
|
22
|
+
by
|
23
|
+
calc
|
24
|
+
calc_refl
|
25
|
+
calc_subst
|
26
|
+
calc_trans
|
27
|
+
#check
|
28
|
+
coercion
|
29
|
+
conjecture
|
30
|
+
constant
|
31
|
+
constants
|
32
|
+
context
|
33
|
+
corollary
|
34
|
+
def
|
35
|
+
definition
|
36
|
+
end
|
37
|
+
#eval
|
38
|
+
example
|
39
|
+
export
|
40
|
+
expose
|
41
|
+
exposing
|
42
|
+
exit
|
43
|
+
extends
|
44
|
+
from
|
45
|
+
fun
|
46
|
+
have
|
47
|
+
help
|
48
|
+
hiding
|
49
|
+
hott
|
50
|
+
hypothesis
|
51
|
+
import
|
52
|
+
include
|
53
|
+
including
|
54
|
+
inductive
|
55
|
+
infix
|
56
|
+
infixl
|
57
|
+
infixr
|
58
|
+
inline
|
59
|
+
instance
|
60
|
+
irreducible
|
61
|
+
lemma
|
62
|
+
match
|
63
|
+
namespace
|
64
|
+
notation
|
65
|
+
opaque
|
66
|
+
opaque_hint
|
67
|
+
open
|
68
|
+
options
|
69
|
+
parameter
|
70
|
+
parameters
|
71
|
+
postfix
|
72
|
+
precedence
|
73
|
+
prefix
|
74
|
+
#print
|
75
|
+
private
|
76
|
+
protected
|
77
|
+
#reduce
|
78
|
+
reducible
|
79
|
+
renaming
|
80
|
+
repeat
|
81
|
+
section
|
82
|
+
set_option
|
83
|
+
show
|
84
|
+
tactic_hint
|
85
|
+
theorem
|
86
|
+
universe
|
87
|
+
universes
|
88
|
+
using
|
89
|
+
variable
|
90
|
+
variables
|
91
|
+
with
|
92
|
+
)
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.types
|
96
|
+
@types ||= %w(
|
97
|
+
Sort
|
98
|
+
Prop
|
99
|
+
Type
|
100
|
+
)
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.operators
|
104
|
+
@operators ||= %w(
|
105
|
+
!= # & && \* \+ - / @ ! ` -\. ->
|
106
|
+
\. \.\. \.\.\. :: :> ; ;; <
|
107
|
+
<- = == > _ \| \|\| ~ => <= >=
|
108
|
+
/\ \/ ∀ Π λ ↔ ∧ ∨ ≠ ≤ ≥ ⊎
|
109
|
+
¬ ⁻¹ ⬝ ▸ → ∃ ℕ ℤ ≈ × ⌞ ⌟ ≡ ⟨ ⟩
|
110
|
+
)
|
111
|
+
end
|
112
|
+
|
113
|
+
state :root do
|
114
|
+
# comments starting after some space
|
115
|
+
rule %r/\s*--+\s+.*?$/, Comment::Doc
|
116
|
+
|
117
|
+
rule %r/"/, Str, :string
|
118
|
+
rule %r/\d+/, Num::Integer
|
119
|
+
|
120
|
+
# special commands or keywords
|
121
|
+
rule(/#?\w+/) do |m|
|
122
|
+
match = m[0]
|
123
|
+
if self.class.keywords.include?(match)
|
124
|
+
token Keyword
|
125
|
+
elsif self.class.types.include?(match)
|
126
|
+
token Keyword::Type
|
127
|
+
else
|
128
|
+
token Name
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
# special unicode keywords
|
133
|
+
rule %r/[λ]/, Keyword
|
134
|
+
|
135
|
+
# ----------------
|
136
|
+
# operators rules
|
137
|
+
# ----------------
|
138
|
+
|
139
|
+
rule %r/\:=?/, Text
|
140
|
+
rule %r/\.[0-9]*/, Operator
|
141
|
+
|
142
|
+
rule %r(#{Lean.operators.join('|')}), Operator
|
143
|
+
|
144
|
+
# unmatched symbols
|
145
|
+
rule %r/[\s\(\),\[\]αβ‹›]+/, Text
|
146
|
+
|
147
|
+
# show missing matches
|
148
|
+
rule %r/./, Error
|
149
|
+
|
150
|
+
end
|
151
|
+
|
152
|
+
state :string do
|
153
|
+
rule %r/"/, Str, :pop!
|
154
|
+
rule %r/\\/, Str::Escape, :escape
|
155
|
+
rule %r/[^\\"]+/, Str
|
156
|
+
end
|
157
|
+
|
158
|
+
state :escape do
|
159
|
+
rule %r/[nrt"'\\]/, Str::Escape, :pop!
|
160
|
+
rule %r/x[\da-f]+/i, Str::Escape, :pop!
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|