rouge 3.28.0 → 3.29.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -1
  3. data/lib/rouge/demos/brainfuck +1 -1
  4. data/lib/rouge/demos/brightscript +1 -1
  5. data/lib/rouge/demos/bsl +1 -1
  6. data/lib/rouge/demos/cfscript +1 -1
  7. data/lib/rouge/demos/coq +1 -1
  8. data/lib/rouge/demos/csvs +1 -1
  9. data/lib/rouge/demos/datastudio +0 -1
  10. data/lib/rouge/demos/ecl +0 -1
  11. data/lib/rouge/demos/erlang +1 -1
  12. data/lib/rouge/demos/fsharp +1 -1
  13. data/lib/rouge/demos/glsl +1 -1
  14. data/lib/rouge/demos/haxe +0 -1
  15. data/lib/rouge/demos/idris +13 -0
  16. data/lib/rouge/demos/lean +8 -0
  17. data/lib/rouge/demos/nesasm +1 -1
  18. data/lib/rouge/demos/opentype_feature_file +0 -1
  19. data/lib/rouge/demos/plsql +2 -0
  20. data/lib/rouge/demos/smarty +0 -1
  21. data/lib/rouge/demos/syzlang +15 -0
  22. data/lib/rouge/demos/syzprog +8 -0
  23. data/lib/rouge/formatters/html_inline.rb +0 -1
  24. data/lib/rouge/lexer.rb +2 -2
  25. data/lib/rouge/lexers/apache/keywords.rb +1 -1
  26. data/lib/rouge/lexers/docker.rb +4 -0
  27. data/lib/rouge/lexers/eiffel.rb +0 -1
  28. data/lib/rouge/lexers/gherkin/keywords.rb +1 -1
  29. data/lib/rouge/lexers/handlebars.rb +1 -1
  30. data/lib/rouge/lexers/hylang.rb +0 -1
  31. data/lib/rouge/lexers/idris.rb +210 -0
  32. data/lib/rouge/lexers/jsx.rb +0 -1
  33. data/lib/rouge/lexers/lasso/keywords.rb +1 -1
  34. data/lib/rouge/lexers/lean.rb +164 -0
  35. data/lib/rouge/lexers/llvm/keywords.rb +1 -1
  36. data/lib/rouge/lexers/lua/keywords.rb +1 -1
  37. data/lib/rouge/lexers/mathematica/keywords.rb +1 -1
  38. data/lib/rouge/lexers/matlab/keywords.rb +1 -1
  39. data/lib/rouge/lexers/matlab.rb +3 -2
  40. data/lib/rouge/lexers/ocl.rb +0 -1
  41. data/lib/rouge/lexers/php/keywords.rb +1 -1
  42. data/lib/rouge/lexers/plsql.rb +578 -0
  43. data/lib/rouge/lexers/prometheus.rb +0 -1
  44. data/lib/rouge/lexers/python.rb +3 -1
  45. data/lib/rouge/lexers/q.rb +0 -1
  46. data/lib/rouge/lexers/sqf/keywords.rb +1 -1
  47. data/lib/rouge/lexers/supercollider.rb +0 -1
  48. data/lib/rouge/lexers/syzlang.rb +317 -0
  49. data/lib/rouge/lexers/syzprog.rb +122 -0
  50. data/lib/rouge/lexers/tap.rb +0 -1
  51. data/lib/rouge/lexers/tsx.rb +0 -1
  52. data/lib/rouge/lexers/tulip.rb +0 -1
  53. data/lib/rouge/lexers/viml/keywords.rb +1 -1
  54. data/lib/rouge/version.rb +1 -1
  55. metadata +16 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a74c520254d1312e4a5343103e3d83b48c967025a77a01701c42820a5eb3c708
4
- data.tar.gz: 2fb290b030a0d60910973c53398c0dd4b127d17c1b489c88105f0bddb3689f6e
3
+ metadata.gz: 15e78361e4f2dde8ae802ffcd36cc0b1e8e9124c2bbe0d3182a767244047a9e0
4
+ data.tar.gz: 661838ffd5b8c6ff8ac894312293aa6c46b36abed76ccc8f0932358e6478c8b1
5
5
  SHA512:
6
- metadata.gz: f499d28b76cd95fa2182d64809c4b6828c735a95c05c1b9af858ac6c1d0d17755fdafa90ae93f9d7fd27bd826fb4055cb8d3985d94b17172018ef408a397d8cf
7
- data.tar.gz: 7fcd54cac21c2fb1b1cdc0825691ce812f42bc5d18cace205b281aaf87e7d8a75ee2dca544e92b9b193084605811f74151b00c51237850952cb22d4e4dde5db9
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.49.1'
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
@@ -2,4 +2,4 @@
2
2
  This is a sample
3
3
  comment.
4
4
  ]
5
- .[>+<-]>,
5
+ .[>+<-]>,
@@ -3,4 +3,4 @@ function main(args as dynamic) as void
3
3
  'Create a scene and load /components/helloworld.xml'
4
4
  scene = screen.CreateScene("HelloWorld")
5
5
  screen.show()
6
- end function
6
+ end function
data/lib/rouge/demos/bsl CHANGED
@@ -4,4 +4,4 @@
4
4
  Сообщить("Привет мир");
5
5
  КонецПроцедуры
6
6
 
7
- #КонецОбласти
7
+ #КонецОбласти
@@ -15,4 +15,4 @@ component accessors="true" {
15
15
 
16
16
  return foo;
17
17
  }
18
- }
18
+ }
data/lib/rouge/demos/coq CHANGED
@@ -10,4 +10,4 @@ Section with_T.
10
10
  end.
11
11
  End with_T.
12
12
 
13
- Definition a_string := "hello \" world".
13
+ Definition a_string := "hello \" world".
data/lib/rouge/demos/csvs CHANGED
@@ -5,4 +5,4 @@ Transaction_Date: xDate
5
5
  Transaction_ID: notEmpty
6
6
  Originator_Name: notEmpty
7
7
  Originator_Address: any("yes","no")
8
- Originator_Country: notEmpty
8
+ Originator_Country: notEmpty
@@ -18,4 +18,3 @@ select * from TABLE1 where COL1 like %VAR1%; //utiliser la variable VAR1 dans un
18
18
 
19
19
  select * from TEST_TABLE; //exécution d'une requête Select pour ramener des valeurs
20
20
  Affect_LastColumns("TEST1"); //création du paramètre TEST1
21
-
data/lib/rouge/demos/ecl CHANGED
@@ -15,4 +15,3 @@ somePeople := allPeople(LastName = 'Smith');
15
15
 
16
16
  // Outputs ---
17
17
  somePeople;
18
-
@@ -4,4 +4,4 @@
4
4
 
5
5
  %% Compute rectangle and circle area.
6
6
  area({rectangle, Width, Ht}) -> Width * Ht;
7
- area({circle, R}) -> 3.14159 * R * R.
7
+ area({circle, R}) -> 3.14159 * R * R.
@@ -9,4 +9,4 @@ let rec existsLeaf test tree =
9
9
  || existsLeaf test right
10
10
 
11
11
  let hasEvenLeaf tree =
12
- existsLeaf (fun n -> n % 2 = 0) tree
12
+ existsLeaf (fun n -> n % 2 = 0) tree
data/lib/rouge/demos/glsl CHANGED
@@ -11,4 +11,4 @@ void main()
11
11
  {
12
12
  vertexColor = color;
13
13
  gl_Position = vec4(position, 0.0, 1.0);
14
- }
14
+ }
data/lib/rouge/demos/haxe CHANGED
@@ -2,4 +2,3 @@
2
2
  public static function hello(arg : String) {
3
3
  return 'Hello $arg';
4
4
  }
5
-
@@ -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
@@ -0,0 +1,8 @@
1
+ open nat
2
+
3
+ def add : nat → nat → nat
4
+ | m zero := m
5
+ | m (succ n) := succ (add m n)
6
+
7
+ -- encode definition as an axiom
8
+ axiom add_zero (n : nat) : n + 0 = n
@@ -8,4 +8,4 @@ Reset:
8
8
  lda #$3f ; $3F -> A register
9
9
  ldy #$00 ; $00 -> Y register
10
10
  sta PPU_ADDR ; write #HIGH byte first
11
- sty PPU_ADDR ; $3F00 -> PPU address
11
+ sty PPU_ADDR ; $3F00 -> PPU address
@@ -3,4 +3,3 @@ languagesystem DFLT dflt;
3
3
  feature liga {
4
4
  sub f i by f_i;
5
5
  } liga;
6
-
@@ -0,0 +1,2 @@
1
+ SELECT q'{a quoted string}' AS s, TO_CHAR(SYSDATE,'MM/DD/YYYY') AS "Current Date" FROM DUAL
2
+ WHERE 1=1;
@@ -9,4 +9,3 @@
9
9
  </ul>
10
10
 
11
11
  <div class="{if $foo}class1{else}class2{/if}">{$foo.bar.baz}</div>
12
-
@@ -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')
@@ -28,4 +28,3 @@ module Rouge
28
28
  end
29
29
  end
30
30
  end
31
-
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.name
297
- return if encoding == 'US-ASCII' || encoding == 'UTF-8' || encoding == 'ASCII-8BIT'
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(',')}. " +
@@ -21,4 +21,4 @@ module Rouge
21
21
  end
22
22
  end
23
23
  end
24
- end
24
+ end
@@ -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
@@ -63,4 +63,3 @@ module Rouge
63
63
  end
64
64
  end
65
65
  end
66
-
@@ -16,4 +16,4 @@ module Rouge
16
16
  end
17
17
  end
18
18
  end
19
- end
19
+ end
@@ -88,4 +88,4 @@ module Rouge
88
88
  end
89
89
  end
90
90
  end
91
- end
91
+ end
@@ -91,4 +91,3 @@ module Rouge
91
91
  end
92
92
  end
93
93
  end
94
-
@@ -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
@@ -89,4 +89,3 @@ module Rouge
89
89
  end
90
90
  end
91
91
  end
92
-
@@ -17,4 +17,4 @@ module Rouge
17
17
  end
18
18
  end
19
19
  end
20
- end
20
+ end
@@ -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
@@ -22,4 +22,4 @@ module Rouge
22
22
 
23
23
  end
24
24
  end
25
- end
25
+ end
@@ -25,4 +25,4 @@ module Rouge
25
25
  end
26
26
  end
27
27
  end
28
- end
28
+ end
@@ -14,4 +14,4 @@ module Rouge
14
14
  end
15
15
  end
16
16
  end
17
- end
17
+ end