rouge 3.26.0 → 3.30.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -1
- data/lib/rouge/cli.rb +23 -20
- 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/dafny +16 -0
- 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/fluent +13 -0
- 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/isabelle +16 -0
- data/lib/rouge/demos/lean +8 -0
- data/lib/rouge/demos/meson +10 -0
- data/lib/rouge/demos/nesasm +1 -1
- data/lib/rouge/demos/nial +35 -0
- 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/stan +13 -0
- data/lib/rouge/demos/stata +14 -0
- data/lib/rouge/demos/syzlang +15 -0
- data/lib/rouge/demos/syzprog +8 -0
- data/lib/rouge/formatter.rb +2 -2
- data/lib/rouge/formatters/html_inline.rb +0 -1
- data/lib/rouge/guessers/disambiguation.rb +7 -0
- data/lib/rouge/lexer.rb +2 -2
- data/lib/rouge/lexers/apache/keywords.rb +1 -1
- data/lib/rouge/lexers/apple_script.rb +1 -1
- data/lib/rouge/lexers/c.rb +12 -2
- data/lib/rouge/lexers/ceylon.rb +2 -2
- data/lib/rouge/lexers/console.rb +1 -1
- data/lib/rouge/lexers/cpp.rb +8 -5
- data/lib/rouge/lexers/cypher.rb +8 -0
- data/lib/rouge/lexers/dafny.rb +128 -0
- data/lib/rouge/lexers/dart.rb +10 -9
- data/lib/rouge/lexers/docker.rb +4 -0
- data/lib/rouge/lexers/eex.rb +2 -2
- data/lib/rouge/lexers/eiffel.rb +0 -1
- data/lib/rouge/lexers/factor.rb +2 -2
- data/lib/rouge/lexers/fluent.rb +74 -0
- data/lib/rouge/lexers/ghc_core.rb +1 -1
- data/lib/rouge/lexers/gherkin/keywords.rb +1 -1
- data/lib/rouge/lexers/groovy.rb +1 -1
- data/lib/rouge/lexers/handlebars.rb +1 -1
- data/lib/rouge/lexers/hcl.rb +1 -0
- data/lib/rouge/lexers/hylang.rb +0 -1
- data/lib/rouge/lexers/idris.rb +210 -0
- data/lib/rouge/lexers/isabelle.rb +251 -0
- data/lib/rouge/lexers/javascript.rb +1 -1
- data/lib/rouge/lexers/jsl.rb +6 -7
- data/lib/rouge/lexers/jsx.rb +1 -2
- data/lib/rouge/lexers/kotlin.rb +3 -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/meson.rb +159 -0
- data/lib/rouge/lexers/nial.rb +166 -0
- data/lib/rouge/lexers/ocl.rb +0 -1
- data/lib/rouge/lexers/pascal.rb +2 -1
- data/lib/rouge/lexers/php/keywords.rb +1 -1
- data/lib/rouge/lexers/php.rb +7 -5
- 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/rust.rb +82 -19
- data/lib/rouge/lexers/sparql.rb +5 -4
- data/lib/rouge/lexers/sqf/keywords.rb +1 -1
- data/lib/rouge/lexers/sql.rb +7 -7
- data/lib/rouge/lexers/stan.rb +451 -0
- data/lib/rouge/lexers/stata.rb +165 -0
- data/lib/rouge/lexers/supercollider.rb +0 -1
- data/lib/rouge/lexers/swift.rb +3 -3
- 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/toml.rb +16 -9
- 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/lexers/yaml.rb +1 -1
- data/lib/rouge/version.rb +1 -1
- metadata +30 -6
@@ -0,0 +1,251 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
# Lexer adapted from https://github.com/pygments/pygments/blob/ad55974ce83b85dbb333ab57764415ab84169461/pygments/lexers/theorem.py
|
4
|
+
|
5
|
+
module Rouge
|
6
|
+
module Lexers
|
7
|
+
class Isabelle < RegexLexer
|
8
|
+
title "Isabelle"
|
9
|
+
desc 'Isabelle theories (isabelle.in.tum.de)'
|
10
|
+
tag 'isabelle'
|
11
|
+
aliases 'isa', 'Isabelle'
|
12
|
+
filenames '*.thy'
|
13
|
+
mimetypes 'text/x-isabelle'
|
14
|
+
|
15
|
+
def self.keyword_minor
|
16
|
+
@keyword_minor ||= Set.new %w(
|
17
|
+
and assumes attach avoids binder checking
|
18
|
+
class_instance class_relation code_module congs
|
19
|
+
constant constrains datatypes defines file fixes
|
20
|
+
for functions hints identifier if imports in
|
21
|
+
includes infix infixl infixr is keywords lazy
|
22
|
+
module_name monos morphisms no_discs_sels notes
|
23
|
+
obtains open output overloaded parametric permissive
|
24
|
+
pervasive rep_compat shows structure type_class
|
25
|
+
type_constructor unchecked unsafe where
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.keyword_diag
|
30
|
+
@keyword_diag ||= Set.new %w(
|
31
|
+
ML_command ML_val class_deps code_deps code_thms
|
32
|
+
display_drafts find_consts find_theorems find_unused_assms
|
33
|
+
full_prf help locale_deps nitpick pr prf
|
34
|
+
print_abbrevs print_antiquotations print_attributes
|
35
|
+
print_binds print_bnfs print_bundles
|
36
|
+
print_case_translations print_cases print_claset
|
37
|
+
print_classes print_codeproc print_codesetup
|
38
|
+
print_coercions print_commands print_context
|
39
|
+
print_defn_rules print_dependencies print_facts
|
40
|
+
print_induct_rules print_inductives print_interps
|
41
|
+
print_locale print_locales print_methods print_options
|
42
|
+
print_orders print_quot_maps print_quotconsts
|
43
|
+
print_quotients print_quotientsQ3 print_quotmapsQ3
|
44
|
+
print_rules print_simpset print_state print_statement
|
45
|
+
print_syntax print_theorems print_theory print_trans_rules
|
46
|
+
prop pwd quickcheck refute sledgehammer smt_status
|
47
|
+
solve_direct spark_status term thm thm_deps thy_deps
|
48
|
+
try try0 typ unused_thms value values welcome
|
49
|
+
print_ML_antiquotations print_term_bindings values_prolog
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.keyword_thy
|
54
|
+
@keyword_thy ||= Set.new %w(theory begin end)
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.keyword_section
|
58
|
+
@keyword_section ||= Set.new %w(header chapter)
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.keyword_subsection
|
62
|
+
@keyword_subsection ||= Set.new %w(section subsection subsubsection sect subsect subsubsect)
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.keyword_theory_decl
|
66
|
+
@keyword_theory_decl ||= Set.new %w(
|
67
|
+
ML ML_file abbreviation adhoc_overloading arities
|
68
|
+
atom_decl attribute_setup axiomatization bundle
|
69
|
+
case_of_simps class classes classrel codatatype
|
70
|
+
code_abort code_class code_const code_datatype
|
71
|
+
code_identifier code_include code_instance code_modulename
|
72
|
+
code_monad code_printing code_reflect code_reserved
|
73
|
+
code_type coinductive coinductive_set consts context
|
74
|
+
datatype datatype_new datatype_new_compat declaration
|
75
|
+
declare default_sort defer_recdef definition defs
|
76
|
+
domain domain_isomorphism domaindef equivariance
|
77
|
+
export_code extract extract_type fixrec fun
|
78
|
+
fun_cases hide_class hide_const hide_fact hide_type
|
79
|
+
import_const_map import_file import_tptp import_type_map
|
80
|
+
inductive inductive_set instantiation judgment lemmas
|
81
|
+
lifting_forget lifting_update local_setup locale
|
82
|
+
method_setup nitpick_params no_adhoc_overloading
|
83
|
+
no_notation no_syntax no_translations no_type_notation
|
84
|
+
nominal_datatype nonterminal notation notepad oracle
|
85
|
+
overloading parse_ast_translation parse_translation
|
86
|
+
partial_function primcorec primrec primrec_new
|
87
|
+
print_ast_translation print_translation quickcheck_generator
|
88
|
+
quickcheck_params realizability realizers recdef record
|
89
|
+
refute_params setup setup_lifting simproc_setup
|
90
|
+
simps_of_case sledgehammer_params spark_end spark_open
|
91
|
+
spark_open_siv spark_open_vcg spark_proof_functions
|
92
|
+
spark_types statespace syntax syntax_declaration text
|
93
|
+
text_raw theorems translations type_notation
|
94
|
+
type_synonym typed_print_translation typedecl hoarestate
|
95
|
+
install_C_file install_C_types wpc_setup c_defs c_types
|
96
|
+
memsafe SML_export SML_file SML_import approximate
|
97
|
+
bnf_axiomatization cartouche datatype_compat
|
98
|
+
free_constructors functor nominal_function
|
99
|
+
nominal_termination permanent_interpretation
|
100
|
+
binds defining smt2_status term_cartouche
|
101
|
+
boogie_file text_cartouche
|
102
|
+
)
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.keyword_theory_script
|
106
|
+
@keyword_theory_script ||= Set.new %w(inductive_cases inductive_simps)
|
107
|
+
end
|
108
|
+
|
109
|
+
def self.keyword_theory_goal
|
110
|
+
@keyword_theory_goal ||= Set.new %w(
|
111
|
+
ax_specification bnf code_pred corollary cpodef
|
112
|
+
crunch crunch_ignore
|
113
|
+
enriched_type function instance interpretation lemma
|
114
|
+
lift_definition nominal_inductive nominal_inductive2
|
115
|
+
nominal_primrec pcpodef primcorecursive
|
116
|
+
quotient_definition quotient_type recdef_tc rep_datatype
|
117
|
+
schematic_corollary schematic_lemma schematic_theorem
|
118
|
+
spark_vc specification subclass sublocale termination
|
119
|
+
theorem typedef wrap_free_constructors
|
120
|
+
)
|
121
|
+
end
|
122
|
+
|
123
|
+
def self.keyword_qed
|
124
|
+
@keyword_qed ||= Set.new %w(by done qed)
|
125
|
+
end
|
126
|
+
|
127
|
+
def self.keyword_abandon_proof
|
128
|
+
@keyword_abandon_proof ||= Set.new %w(sorry oops)
|
129
|
+
end
|
130
|
+
|
131
|
+
def self.keyword_proof_goal
|
132
|
+
@keyword_proof_goal ||= Set.new %w(have hence interpret)
|
133
|
+
end
|
134
|
+
|
135
|
+
def self.keyword_proof_block
|
136
|
+
@keyword_proof_block ||= Set.new %w(next proof)
|
137
|
+
end
|
138
|
+
|
139
|
+
def self.keyword_proof_chain
|
140
|
+
@keyword_proof_chain ||= Set.new %w(finally from then ultimately with)
|
141
|
+
end
|
142
|
+
|
143
|
+
def self.keyword_proof_decl
|
144
|
+
@keyword_proof_decl ||= Set.new %w(
|
145
|
+
ML_prf also include including let moreover note
|
146
|
+
txt txt_raw unfolding using write
|
147
|
+
)
|
148
|
+
end
|
149
|
+
|
150
|
+
def self.keyword_proof_asm
|
151
|
+
@keyword_proof_asm ||= Set.new %w(assume case def fix presume)
|
152
|
+
end
|
153
|
+
|
154
|
+
def self.keyword_proof_asm_goal
|
155
|
+
@keyword_proof_asm_goal ||= Set.new %w(guess obtain show thus)
|
156
|
+
end
|
157
|
+
|
158
|
+
def self.keyword_proof_script
|
159
|
+
@keyword_proof_script ||= Set.new %w(apply apply_end apply_trace back defer prefer)
|
160
|
+
end
|
161
|
+
|
162
|
+
state :root do
|
163
|
+
rule %r/\s+/, Text::Whitespace
|
164
|
+
rule %r/\(\*/, Comment, :comment
|
165
|
+
rule %r/\{\*|‹/, Text, :text
|
166
|
+
|
167
|
+
rule %r/::|\[|\]|-|[:()_=,|+!?]/, Operator
|
168
|
+
rule %r/[{}.]|\.\./, Operator::Word
|
169
|
+
|
170
|
+
def word(keywords)
|
171
|
+
return %r/\b(#{keywords.join('|')})\b/
|
172
|
+
end
|
173
|
+
|
174
|
+
rule %r/[a-zA-Z]\w*/ do |m|
|
175
|
+
sym = m[0]
|
176
|
+
|
177
|
+
if self.class.keyword_minor.include?(sym) ||
|
178
|
+
self.class.keyword_proof_script.include?(sym)
|
179
|
+
token Keyword::Pseudo
|
180
|
+
elsif self.class.keyword_diag.include?(sym)
|
181
|
+
token Keyword::Type
|
182
|
+
elsif self.class.keyword_thy.include?(sym) ||
|
183
|
+
self.class.keyword_theory_decl.include?(sym) ||
|
184
|
+
self.class.keyword_qed.include?(sym) ||
|
185
|
+
self.class.keyword_proof_goal.include?(sym) ||
|
186
|
+
self.class.keyword_proof_block.include?(sym) ||
|
187
|
+
self.class.keyword_proof_decl.include?(sym) ||
|
188
|
+
self.class.keyword_proof_chain.include?(sym) ||
|
189
|
+
self.class.keyword_proof_asm.include?(sym) ||
|
190
|
+
self.class.keyword_proof_asm_goal.include?(sym)
|
191
|
+
token Keyword
|
192
|
+
elsif self.class.keyword_section.include?(sym)
|
193
|
+
token Generic::Heading
|
194
|
+
elsif self.class.keyword_subsection.include?(sym)
|
195
|
+
token Generic::Subheading
|
196
|
+
elsif self.class.keyword_theory_goal.include?(sym) ||
|
197
|
+
self.class.keyword_theory_script.include?(sym)
|
198
|
+
token Keyword::Namespace
|
199
|
+
elsif self.class.keyword_abandon_proof.include?(sym)
|
200
|
+
token Generic::Error
|
201
|
+
else
|
202
|
+
token Name
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
rule %r/\\<\w*>/, Str::Symbol
|
207
|
+
|
208
|
+
rule %r/'[^\W\d][.\w']*/, Name::Variable
|
209
|
+
|
210
|
+
rule %r/0[xX][\da-fA-F][\da-fA-F_]*/, Num::Hex
|
211
|
+
rule %r/0[oO][0-7][0-7_]*/, Num::Oct
|
212
|
+
rule %r/0[bB][01][01_]*/, Num::Bin
|
213
|
+
|
214
|
+
rule %r/"/, Str, :string
|
215
|
+
rule %r/`/, Str::Other, :fact
|
216
|
+
# Everything except for (most) operators whitespaces may be name
|
217
|
+
rule %r/[^\s:|\[\]\-()=,+!?{}._][^\s:|\[\]\-()=,+!?{}]*/, Name
|
218
|
+
end
|
219
|
+
|
220
|
+
state :comment do
|
221
|
+
rule %r/[^(*)]+/, Comment
|
222
|
+
rule %r/\(\*/, Comment, :comment
|
223
|
+
rule %r/\*\)/, Comment, :pop!
|
224
|
+
rule %r/[(*)]/, Comment
|
225
|
+
end
|
226
|
+
|
227
|
+
state :text do
|
228
|
+
rule %r/[^{*}‹›]+/, Text
|
229
|
+
rule %r/\{\*|‹/, Text, :text
|
230
|
+
rule %r/\*\}|›/, Text, :pop!
|
231
|
+
rule %r/[{*}]/, Text
|
232
|
+
end
|
233
|
+
|
234
|
+
state :string do
|
235
|
+
rule %r/[^"\\]+/, Str
|
236
|
+
rule %r/\\<\w*>/, Str::Symbol
|
237
|
+
rule %r/\\"/, Str
|
238
|
+
rule %r/\\/, Str
|
239
|
+
rule %r/"/, Str, :pop!
|
240
|
+
end
|
241
|
+
|
242
|
+
state :fact do
|
243
|
+
rule %r/[^`\\]+/, Str::Other
|
244
|
+
rule %r/\\<\w*>/, Str::Symbol
|
245
|
+
rule %r/\\`/, Str::Other
|
246
|
+
rule %r/\\/, Str::Other
|
247
|
+
rule %r/`/, Str::Other, :pop!
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
@@ -149,7 +149,7 @@ module Rouge
|
|
149
149
|
rule %r/\A\s*#!.*?\n/m, Comment::Preproc, :statement
|
150
150
|
rule %r((?<=\n)(?=\s|/|<!--)), Text, :expr_start
|
151
151
|
mixin :comments_and_whitespace
|
152
|
-
rule %r(\+\+ | -- | ~ | && | \|\| | \\(?=\n) | << | >>>? | ===
|
152
|
+
rule %r(\+\+ | -- | ~ | \?\?=? | && | \|\| | \\(?=\n) | << | >>>? | ===
|
153
153
|
| !== )x,
|
154
154
|
Operator, :expr_start
|
155
155
|
rule %r([-<>+*%&|\^/!=]=?), Operator, :expr_start
|
data/lib/rouge/lexers/jsl.rb
CHANGED
@@ -14,24 +14,23 @@ module Rouge
|
|
14
14
|
rule %r/\s+/m, Text::Whitespace
|
15
15
|
|
16
16
|
rule %r(//.*?$), Comment::Single
|
17
|
-
rule %r'/[*]
|
17
|
+
rule %r'/[*].*?', Comment::Multiline, :comment # multiline block comment
|
18
18
|
|
19
19
|
# messages
|
20
20
|
rule %r/<</, Operator, :message
|
21
21
|
|
22
22
|
# covers built-in and custom functions
|
23
|
-
rule %r/([a-z_][\w\s'%.\\]*)(\()/i do |m|
|
24
|
-
groups Keyword, Punctuation
|
23
|
+
rule %r/(::|:)?([a-z_][\w\s'%.\\]*)(\()/i do |m|
|
24
|
+
groups Punctuation, Keyword, Punctuation
|
25
25
|
end
|
26
26
|
|
27
27
|
rule %r/\d{2}(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d{2}(\d{2})?(:\d{2}:\d{2}(:\d{2}(\.\d*)?)?)?/i, Literal::Date
|
28
28
|
|
29
29
|
rule %r/-?(?:[0-9]+(?:[.][0-9]+)?|[.][0-9]*)(?:e[+-]?[0-9]+)?i?/i, Num
|
30
30
|
|
31
|
-
rule %r
|
32
|
-
|
33
|
-
|
34
|
-
rule %r/"(?:\\!"|[^"])*?"n/m, Name::Variable
|
31
|
+
rule %r/(::|:)?([a-z_][\w\s'%.\\]*|"(?:\\!"|[^"])*?"n)/i do |m|
|
32
|
+
groups Punctuation, Name::Variable
|
33
|
+
end
|
35
34
|
|
36
35
|
rule %r/(")(\\\[)(.*?)(\]\\)(")/m do
|
37
36
|
groups Str::Double, Str::Escape, Str::Double, Str::Escape, Str::Double # escaped string
|
data/lib/rouge/lexers/jsx.rb
CHANGED
data/lib/rouge/lexers/kotlin.rb
CHANGED
@@ -116,12 +116,14 @@ module Rouge
|
|
116
116
|
rule class_name, Name::Class
|
117
117
|
rule %r'(<)', Punctuation, :generic_parameters
|
118
118
|
rule %r'(reified|out|in)', Keyword
|
119
|
-
rule %r'([
|
119
|
+
rule %r'([,:.?])', Punctuation
|
120
120
|
rule %r'(\s+)', Text
|
121
121
|
rule %r'(>)', Punctuation, :pop!
|
122
122
|
end
|
123
123
|
|
124
124
|
state :property do
|
125
|
+
rule %r'(<)', Punctuation, :generic_parameters
|
126
|
+
rule %r'(\s+)', Text
|
125
127
|
rule name, Name::Property, :pop!
|
126
128
|
end
|
127
129
|
|
@@ -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
|