rouge 3.25.0 → 3.28.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -0
  3. data/lib/rouge/demos/dafny +16 -0
  4. data/lib/rouge/demos/fluent +13 -0
  5. data/lib/rouge/demos/ocl +4 -0
  6. data/lib/rouge/demos/rescript +26 -0
  7. data/lib/rouge/demos/stan +13 -0
  8. data/lib/rouge/demos/stata +14 -0
  9. data/lib/rouge/formatter.rb +2 -2
  10. data/lib/rouge/lexers/c.rb +12 -2
  11. data/lib/rouge/lexers/ceylon.rb +2 -2
  12. data/lib/rouge/lexers/cmake.rb +10 -0
  13. data/lib/rouge/lexers/console.rb +1 -1
  14. data/lib/rouge/lexers/cpp.rb +7 -5
  15. data/lib/rouge/lexers/crystal.rb +14 -9
  16. data/lib/rouge/lexers/cypher.rb +8 -0
  17. data/lib/rouge/lexers/dafny.rb +128 -0
  18. data/lib/rouge/lexers/dart.rb +8 -8
  19. data/lib/rouge/lexers/eex.rb +2 -2
  20. data/lib/rouge/lexers/factor.rb +2 -2
  21. data/lib/rouge/lexers/fluent.rb +74 -0
  22. data/lib/rouge/lexers/ghc_core.rb +1 -1
  23. data/lib/rouge/lexers/hcl.rb +1 -0
  24. data/lib/rouge/lexers/jsl.rb +24 -13
  25. data/lib/rouge/lexers/jsx.rb +1 -1
  26. data/lib/rouge/lexers/kotlin.rb +3 -1
  27. data/lib/rouge/lexers/ocaml/common.rb +1 -1
  28. data/lib/rouge/lexers/ocl.rb +85 -0
  29. data/lib/rouge/lexers/python.rb +1 -1
  30. data/lib/rouge/lexers/reasonml.rb +6 -5
  31. data/lib/rouge/lexers/rescript.rb +119 -0
  32. data/lib/rouge/lexers/rust.rb +82 -18
  33. data/lib/rouge/lexers/sparql.rb +5 -4
  34. data/lib/rouge/lexers/sql.rb +7 -7
  35. data/lib/rouge/lexers/stan.rb +451 -0
  36. data/lib/rouge/lexers/stata.rb +165 -0
  37. data/lib/rouge/lexers/swift.rb +3 -3
  38. data/lib/rouge/lexers/toml.rb +8 -6
  39. data/lib/rouge/lexers/yaml.rb +1 -1
  40. data/lib/rouge/themes/base16.rb +1 -0
  41. data/lib/rouge/themes/bw.rb +1 -0
  42. data/lib/rouge/themes/colorful.rb +1 -0
  43. data/lib/rouge/themes/github.rb +1 -0
  44. data/lib/rouge/themes/gruvbox.rb +2 -0
  45. data/lib/rouge/themes/igor_pro.rb +1 -0
  46. data/lib/rouge/themes/magritte.rb +1 -0
  47. data/lib/rouge/themes/monokai.rb +1 -0
  48. data/lib/rouge/themes/pastie.rb +1 -0
  49. data/lib/rouge/themes/thankful_eyes.rb +1 -0
  50. data/lib/rouge/themes/tulip.rb +1 -0
  51. data/lib/rouge/version.rb +1 -1
  52. metadata +18 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 35d2eb9627935d1f4e510d66263bddb55773667d8a441677019a377abaf3784e
4
- data.tar.gz: 04370e4428e5f4c30a552d455bbf5655beeae8bf3ddc68db09ba0fbf76fee3e9
3
+ metadata.gz: a74c520254d1312e4a5343103e3d83b48c967025a77a01701c42820a5eb3c708
4
+ data.tar.gz: 2fb290b030a0d60910973c53398c0dd4b127d17c1b489c88105f0bddb3689f6e
5
5
  SHA512:
6
- metadata.gz: fc847dd05c6d47cdbcc4296b60594faf8477b1c143e8f303c84a09bfbd88345baa5dbe19e4238ef6a37c79e59809616f649679070faf17f556838ce874cb95b9
7
- data.tar.gz: 272f4948d1935e9e9c1eaae8e5230e5db42933dcf1e2130dad009d6d3e4c57fee656b4aead64d6933cadf836bd7d82287fbc8193032c1af7ebf21e53fc7fb403
6
+ metadata.gz: f499d28b76cd95fa2182d64809c4b6828c735a95c05c1b9af858ac6c1d0d17755fdafa90ae93f9d7fd27bd826fb4055cb8d3985d94b17172018ef408a397d8cf
7
+ data.tar.gz: 7fcd54cac21c2fb1b1cdc0825691ce812f42bc5d18cace205b281aaf87e7d8a75ee2dca544e92b9b193084605811f74151b00c51237850952cb22d4e4dde5db9
data/Gemfile CHANGED
@@ -8,6 +8,7 @@ gem 'rake'
8
8
 
9
9
  gem 'minitest', '>= 5.0'
10
10
  gem 'minitest-power_assert'
11
+ gem 'power_assert', '~> 1.2'
11
12
 
12
13
  gem 'parallel', '~> 1.13.0' if RUBY_VERSION < '2.2.0'
13
14
  gem 'rubocop', '~> 0.49.1'
@@ -36,5 +37,8 @@ group :development do
36
37
  else
37
38
  gem 'sinatra'
38
39
  end
40
+
41
+ # Ruby 3 no longer ships with a web server
42
+ gem 'puma' if RUBY_VERSION >= '3'
39
43
  gem 'shotgun'
40
44
  end
@@ -0,0 +1,16 @@
1
+ module A {
2
+ const i: int := 56_78
3
+ }
4
+
5
+ method m(b: bool, s: string) {
6
+ var x: string;
7
+ var i: int;
8
+ if b then i := 1; else i := 2;
9
+ i := if b 1 else 2;
10
+ assert b;
11
+ assume b;
12
+ print s;
13
+ expect b;
14
+ }
15
+
16
+ function f(i: int): int { i + 1 }
@@ -0,0 +1,13 @@
1
+ # Simple things are simple.
2
+ hello-user = Hello, {$userName}!
3
+
4
+ # Complex things are possible.
5
+ shared-photos =
6
+ {$userName} {$photoCount ->
7
+ [one] added a new photo
8
+ *[other] added {$photoCount} new photos
9
+ } to {$userGender ->
10
+ [male] his stream
11
+ [female] her stream
12
+ *[other] their stream
13
+ }.
@@ -0,0 +1,4 @@
1
+ context Compagnie::toEuros() : Collection(Real)
2
+ body: self.employees->collect(each: Employee| each.salary/ 6.55957)
3
+ -- OR
4
+ body: self.employees->collect(salary) -> collect(x | x/6.55957)
@@ -0,0 +1,26 @@
1
+ module Person = {
2
+ type t = Teacher | Director | Student(string)
3
+
4
+ let greeting = person =>
5
+ switch person {
6
+ | Teacher => "Hey Professor!"
7
+ | Director => "Hello Director."
8
+ | Student("Richard") => "Still here Ricky?"
9
+ | Student(other) => "Hey, " ++ other ++ "."
10
+ }
11
+ }
12
+
13
+ module Button = {
14
+ @react.component
15
+ let make = (~count: int, ~onClick) => {
16
+ let times = switch count {
17
+ | 1 => "once"
18
+ | 2 => "twice"
19
+ | n => Belt.Int.toString(n) ++ " times"
20
+ }
21
+
22
+ let msg = "Click me " ++ times
23
+
24
+ <button onClick> {msg->React.string} </button>
25
+ }
26
+ }
@@ -0,0 +1,13 @@
1
+ data {
2
+ int<lower=0> N;
3
+ vector[N] x;
4
+ vector[N] y;
5
+ }
6
+ parameters {
7
+ real alpha;
8
+ real beta;
9
+ real<lower=0> sigma;
10
+ }
11
+ model {
12
+ y ~ normal(alpha + beta * x, sigma);
13
+ }
@@ -0,0 +1,14 @@
1
+ * Run a series of linear regressions
2
+ sysuse auto, clear
3
+ foreach v of varlist mpg weight-turn {
4
+ regress price `v', robust
5
+ }
6
+
7
+ regress price i.foreign
8
+ local num_obs = e(N)
9
+ global myglobal = 4
10
+
11
+ * Generate and manipulate variables
12
+ generate newvar1 = "string"
13
+ generate newvar2 = 34 - `num_obs'
14
+ replace newvar2 = $myglobal
@@ -42,8 +42,8 @@ module Rouge
42
42
  end
43
43
 
44
44
  # Format a token stream. Delegates to {#format}.
45
- def self.format(tokens, *a, &b)
46
- new(*a).format(tokens, &b)
45
+ def self.format(tokens, *args, **kwargs, &b)
46
+ new(*args, **kwargs).format(tokens, &b)
47
47
  end
48
48
 
49
49
  def initialize(opts={})
@@ -170,12 +170,22 @@ module Rouge
170
170
  end
171
171
 
172
172
  state :macro do
173
- # NB: pop! goes back to :bol
174
- rule %r/\n/, Comment::Preproc, :pop!
173
+ mixin :include
175
174
  rule %r([^/\n\\]+), Comment::Preproc
176
175
  rule %r/\\./m, Comment::Preproc
177
176
  mixin :inline_whitespace
178
177
  rule %r(/), Comment::Preproc
178
+ # NB: pop! goes back to :bol
179
+ rule %r/\n/, Comment::Preproc, :pop!
180
+ end
181
+
182
+ state :include do
183
+ rule %r/(include)(\s*)(<[^>]+>)([^\n]*)/ do
184
+ groups Comment::Preproc, Text, Comment::PreprocFile, Comment::Single
185
+ end
186
+ rule %r/(include)(\s*)("[^"]+")([^\n]*)/ do
187
+ groups Comment::Preproc, Text, Comment::PreprocFile, Comment::Single
188
+ end
179
189
  end
180
190
 
181
191
  state :if_0 do
@@ -51,8 +51,8 @@ module Rouge
51
51
 
52
52
  rule %r("(\\\\|\\"|[^"])*"), Literal::String
53
53
  rule %r('\\.'|'[^\\]'|'\\\{#[0-9a-fA-F]{4}\}'), Literal::String::Char
54
- rule %r(".*``.*``.*"', String::Interpol
55
- rule %r(\.)([a-z_]\w*)) do
54
+ rule %r("[^`]*``[^`]*``[^`]*"), Literal::String::Interpol
55
+ rule %r((\.)([a-z_]\w*)) do
56
56
  groups Operator, Name::Attribute
57
57
  end
58
58
  rule %r([a-zA-Z_]\w*:), Name::Label
@@ -22,6 +22,7 @@ module Rouge
22
22
  }
23
23
 
24
24
  BUILTIN_COMMANDS = Set.new %w[
25
+ add_compile_definitions
25
26
  add_compile_options
26
27
  add_custom_command
27
28
  add_custom_target
@@ -29,6 +30,7 @@ module Rouge
29
30
  add_dependencies
30
31
  add_executable
31
32
  add_library
33
+ add_link_options
32
34
  add_subdirectory
33
35
  add_test
34
36
  aux_source_directory
@@ -36,7 +38,9 @@ module Rouge
36
38
  build_command
37
39
  build_name
38
40
  cmake_host_system_information
41
+ cmake_language
39
42
  cmake_minimum_required
43
+ cmake_parse_arguments
40
44
  cmake_policy
41
45
  configure_file
42
46
  create_test_sourcelist
@@ -74,6 +78,7 @@ module Rouge
74
78
  include
75
79
  include_directories
76
80
  include_external_msproject
81
+ include_guard
77
82
  include_regular_expression
78
83
  install
79
84
  install_files
@@ -110,9 +115,14 @@ module Rouge
110
115
  subdir_depends
111
116
  subdirs
112
117
  target_compile_definitions
118
+ target_compile_features
113
119
  target_compile_options
114
120
  target_include_directories
121
+ target_link_directories
115
122
  target_link_libraries
123
+ target_link_options
124
+ target_precompile_headers
125
+ target_sources
116
126
  try_compile
117
127
  try_run
118
128
  unset
@@ -103,7 +103,7 @@ module Rouge
103
103
  end
104
104
 
105
105
  def line_regex
106
- /(\\.|[^\\])*?(\n|$)/m
106
+ /(.*?)(\n|$)/
107
107
  end
108
108
 
109
109
  def output_lexer
@@ -22,12 +22,14 @@ module Rouge
22
22
 
23
23
  def self.keywords
24
24
  @keywords ||= super + Set.new(%w(
25
- asm auto catch const_cast delete dynamic_cast explicit export friend
25
+ asm auto catch char8_t concept
26
+ consteval constexpr constinit const_cast co_await co_return co_yield
27
+ delete dynamic_cast explicit export friend
26
28
  mutable namespace new operator private protected public
27
- reinterpret_cast restrict size_of static_cast this throw throws
29
+ reinterpret_cast requires restrict size_of static_cast this throw throws
28
30
  typeid typename using virtual final override
29
31
 
30
- alignas alignof constexpr decltype noexcept static_assert
32
+ alignas alignof decltype noexcept static_assert
31
33
  thread_local try
32
34
  ))
33
35
  end
@@ -59,7 +61,7 @@ module Rouge
59
61
  prepend :statements do
60
62
  rule %r/(class|struct)\b/, Keyword, :classname
61
63
  rule %r/template\b/, Keyword, :template
62
- rule %r/\d+(\.\d+)?(?:h|(?:min)|s|(?:ms)|(?:us)|(?:ns))/, Num::Other
64
+ rule %r/#{dq}(\.#{dq})?(?:y|d|h|(?:min)|s|(?:ms)|(?:us)|(?:ns)|i|(?:if)|(?:il))\b/, Num::Other
63
65
  rule %r((#{dq}[.]#{dq}?|[.]#{dq})(e[+-]?#{dq}[lu]*)?)i, Num::Float
64
66
  rule %r(#{dq}e[+-]?#{dq}[lu]*)i, Num::Float
65
67
  rule %r/0x\h('?\h)*[lu]*/i, Num::Hex
@@ -68,7 +70,7 @@ module Rouge
68
70
  rule %r/#{dq}[lu]*/i, Num::Integer
69
71
  rule %r/\bnullptr\b/, Name::Builtin
70
72
  rule %r/(?:u8|u|U|L)?R"([a-zA-Z0-9_{}\[\]#<>%:;.?*\+\-\/\^&|~!=,"']{,16})\(.*?\)\1"/m, Str
71
- rule %r/::/, Operator
73
+ rule %r/(::|<=>)/, Operator
72
74
  end
73
75
 
74
76
  state :classname do
@@ -25,8 +25,7 @@ module Rouge
25
25
  )xi, Str::Symbol
26
26
 
27
27
  # special symbols
28
- rule %r(:(?:\*\*|[-+]@|[/\%&\|^`~]|\[\]=?|<<|>>|<=?>|<=?|===?)),
29
- Str::Symbol
28
+ rule %r(:(?:===|=?~|\[\][=?]?|\*\*=?|\/\/=?|[=^*/+-]=?|&[&*+-]?=?|\|\|?=?|![=~]?|%=?|<=>|<<?=?|>>?=?|\.\.\.?)), Str::Symbol
30
29
 
31
30
  rule %r/:'(\\\\|\\'|[^'])*'/, Str::Symbol
32
31
  rule %r/:"/, Str::Symbol, :simple_sym
@@ -36,7 +35,7 @@ module Rouge
36
35
  # %-sigiled strings
37
36
  # %(abc), %[abc], %<abc>, %.abc., %r.abc., etc
38
37
  delimiter_map = { '{' => '}', '[' => ']', '(' => ')', '<' => '>' }
39
- rule %r/%([rqswQWxiI])?([^\w\s])/ do |m|
38
+ rule %r/%([rqswQWxiI])?([^\w\s}])/ do |m|
40
39
  open = Regexp.escape(m[2])
41
40
  close = Regexp.escape(delimiter_map[m[2]] || m[2])
42
41
  interp = /[rQWxI]/ === m[1]
@@ -79,9 +78,11 @@ module Rouge
79
78
  state :strings do
80
79
  mixin :symbols
81
80
  rule %r/\b[a-z_]\w*?[?!]?:\s+/, Str::Symbol, :expr_start
82
- rule %r/'(\\\\|\\'|[^'])*'/, Str::Single
83
81
  rule %r/"/, Str::Double, :simple_string
84
82
  rule %r/(?<!\.)`/, Str::Backtick, :simple_backtick
83
+ rule %r/(')(\\u[a-fA-F0-9]{4}|\\u\{[a-fA-F0-9]{1,6}\}|\\[abefnrtv])?(\\\\|\\'|[^'])*(')/ do
84
+ groups Str::Single, Str::Escape, Str::Single, Str::Single
85
+ end
85
86
  end
86
87
 
87
88
  state :regex_flags do
@@ -154,11 +155,13 @@ module Rouge
154
155
  mixin :whitespace
155
156
  rule %r/__END__/, Comment::Preproc, :end_part
156
157
 
157
- rule %r/0_?[0-7]+(?:_[0-7]+)*/, Num::Oct
158
+ rule %r/0o[0-7]+(?:_[0-7]+)*/, Num::Oct
158
159
  rule %r/0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*/, Num::Hex
159
160
  rule %r/0b[01]+(?:_[01]+)*/, Num::Bin
160
- rule %r/\d+\.\d+(e[\+\-]?\d+)?/, Num::Float
161
- rule %r/[\d]+(?:_\d+)*/, Num::Integer
161
+ rule %r/\d+\.\d+(e[\+\-]?\d+)?(_f32)?/i, Num::Float
162
+ rule %r/\d+(e[\+\-]?\d+)/i, Num::Float
163
+ rule %r/\d+_f32/i, Num::Float
164
+ rule %r/[\d]+(?:_\d+)*(_[iu]\d+)?/, Num::Integer
162
165
 
163
166
  rule %r/@\[([^\]]+)\]/, Name::Decorator
164
167
 
@@ -183,7 +186,7 @@ module Rouge
183
186
  groups Keyword, Text, Name::Namespace
184
187
  end
185
188
 
186
- rule %r/(def\b)(\s*)/ do
189
+ rule %r/(def|macro\b)(\s*)/ do
187
190
  groups Keyword, Text
188
191
  push :funcname
189
192
  end
@@ -212,8 +215,9 @@ module Rouge
212
215
 
213
216
  rule %r/[a-zA-Z_]\w*[?!]/, Name, :expr_start
214
217
  rule %r/[a-zA-Z_]\w*/, Name, :method_call
215
- rule %r/\*\*|<<?|>>?|>=|<=|<=>|=~|={3}|!~|&&?|\|\||\./,
218
+ rule %r/\*\*|\/\/|>=|<=|<=>|<<?|>>?|=~|={3}|!~|&&?|\|\||\./,
216
219
  Operator, :expr_start
220
+ rule %r/{%|%}/, Punctuation
217
221
  rule %r/[-+\/*%=<>&!^|~]=?/, Operator, :expr_start
218
222
  rule(/[?]/) { token Punctuation; push :ternary; push :expr_start }
219
223
  rule %r<[\[({,:\\;/]>, Punctuation, :expr_start
@@ -346,6 +350,7 @@ module Rouge
346
350
  mixin :string_intp
347
351
  rule %r/\\([\\abefnrstv#"']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})/,
348
352
  Str::Escape
353
+ rule %r/\\u([a-fA-F0-9]{4}|\{[^}]+\})/, Str::Escape
349
354
  rule %r/\\./, Str::Escape
350
355
  end
351
356
 
@@ -45,6 +45,7 @@ module Rouge
45
45
  state :root do
46
46
  rule %r/[\s]+/, Text
47
47
  rule %r(//.*?$), Comment::Single
48
+ rule %r(/\*), Comment::Multiline, :multiline_comments
48
49
 
49
50
  rule %r([*+\-<>=&|~%^]), Operator
50
51
  rule %r/[{}),;\[\]]/, Str::Symbol
@@ -103,6 +104,13 @@ module Rouge
103
104
  rule %r/'(\\\\|\\'|[^'])*'/, Str::Single
104
105
  rule %r/`(\\\\|\\`|[^`])*`/, Str::Backtick
105
106
  end
107
+
108
+ state :multiline_comments do
109
+ rule %r(/[*]), Comment::Multiline, :multiline_comments
110
+ rule %r([*]/), Comment::Multiline, :pop!
111
+ rule %r([^/*]+), Comment::Multiline
112
+ rule %r([/*]), Comment::Multiline
113
+ end
106
114
  end
107
115
  end
108
116
  end
@@ -0,0 +1,128 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ class Dafny < RegexLexer
7
+ title "Dafny"
8
+ desc "The Dafny programming language (github.com/dafny-lang/dafny)"
9
+ tag "dafny"
10
+ filenames "*.dfy"
11
+ mimetypes "text/x-dafny"
12
+
13
+ keywords = %w(
14
+ abstract allocated assert assume
15
+ break by
16
+ calc case class codatatype const constructor
17
+ datatype decreases downto
18
+ else ensures exists expect export extends
19
+ false for forall fresh function
20
+ ghost greatest
21
+ if import include invariant iterator
22
+ label least lemma
23
+ match method modifies modify module
24
+ nameonly new newtype null
25
+ old opened
26
+ predicate print provides
27
+ reads refines requires return returns reveal reveals
28
+ static
29
+ then this to trait true twostate type
30
+ unchanged
31
+ var
32
+ while witness
33
+ yield yields
34
+ )
35
+
36
+ literals = %w{ true false null }
37
+
38
+ textOperators = %w{ as is in }
39
+
40
+ types = %w(bool char int real string nat
41
+ array array? object object? ORDINAL
42
+ seq set iset map imap multiset )
43
+
44
+ idstart = /[0-9a-zA-Z?]/
45
+ idchar = /[0-9a-zA-Z_'?]/
46
+ id = /#{idstart}#{idchar}*/
47
+
48
+ arrayType = /array(?:1[0-9]+|[2-9][0-9]*)\??(?!#{idchar})/
49
+ bvType = /bv(?:0|[1-9][0-9]*)(?!#{idchar})/
50
+
51
+ digit = /\d/
52
+ digits = /#{digit}+(?:_#{digit}+)*/
53
+ bin_digits = /[01]+(?:_[01]+)*/
54
+ hex_digit = /(?:[0-9a-fA-F])/
55
+ hex_digits = /#{hex_digit}+(?:_#{hex_digit}+)*/
56
+
57
+ cchar = /(?:[^\\'\n\r]|\\["'ntr\\0])/
58
+ schar = /(?:[^\\"\n\r]|\\["'ntr\\0])/
59
+ uchar = /(?:\\u#{hex_digit}{4})/
60
+
61
+ ## IMPORTANT: Rules are ordered, which allows later rules to be
62
+ ## simpler than they would otherwise be
63
+ state :root do
64
+ rule %r(/\*), Comment::Multiline, :comment
65
+ rule %r(//.*?$), Comment::Single
66
+ rule %r(\*/), Error # should not have closing comment in :root
67
+ # is an improperly nested comment
68
+
69
+ rule %r/'#{cchar}'/, Str::Char # standard or escape char
70
+ rule %r/'#{uchar}'/, Str::Char # unicode char
71
+ rule %r/'[^'\n\r]*'/, Error # bad any other enclosed char
72
+ rule %r/'[^'\n\r]*$/, Error # bad unclosed char
73
+
74
+ rule %r/"(?:#{schar}|#{uchar})*"/, Str::Double # valid string
75
+ rule %r/".*"/, Error # anything else that is closed
76
+ rule %r/".*$/, Error # bad unclosed string
77
+
78
+ rule %r/@"([^"]|"")*"/, Str::Other # valid verbatim string
79
+ rule %r/@".*/m, Error # anything else , multiline unclosed
80
+
81
+
82
+ rule %r/#{digits}\.#{digits}(?!#{idchar})/, Num::Float
83
+ rule %r/0b#{bin_digits}(?!#{idchar})/, Num::Bin
84
+ rule %r/0b#{idchar}*/, Error
85
+ rule %r/0x#{hex_digits}(?!#{idchar})/, Num::Hex
86
+ rule %r/0x#{idchar}*/, Error
87
+ rule %r/#{digits}(?!#{idchar})/, Num::Integer
88
+ rule %r/_(?!#{idchar})/, Name
89
+ rule %r/_[0-9_]+[_]?(?!#{idchar})/, Error
90
+ rule %r/[0-9_]+_(?!#{idchar})/, Error
91
+ rule %r/[0-9]#{idchar}+/, Error
92
+
93
+ rule %r/#{arrayType}/, Keyword::Type
94
+ rule %r/#{bvType}/, Keyword::Type
95
+
96
+ rule id do |m|
97
+ if types.include?(m[0])
98
+ token Keyword::Type
99
+ elsif literals.include?(m[0])
100
+ token Keyword::Constant
101
+ elsif textOperators.include?(m[0])
102
+ token Operator::Word
103
+ elsif keywords.include?(m[0])
104
+ token Keyword::Reserved
105
+ else
106
+ token Name
107
+ end
108
+ end
109
+
110
+ rule %r/\.\./, Operator
111
+ rule %r/[*!%&<>\|^+=:.\/-]/, Operator
112
+ rule %r/[\[\](){},;`]/, Punctuation
113
+
114
+ rule %r/[^\S\n]+/, Text
115
+ rule %r/\n/, Text
116
+ rule %r/./, Error # Catchall
117
+ end
118
+
119
+ state :comment do
120
+ rule %r(\*/), Comment::Multiline, :pop!
121
+ rule %r(/\*), Comment::Multiline, :comment
122
+ rule %r([^*/]+), Comment::Multiline
123
+ rule %r(.), Comment::Multiline
124
+ end
125
+
126
+ end
127
+ end
128
+ end
@@ -5,25 +5,25 @@ module Rouge
5
5
  module Lexers
6
6
  class Dart < RegexLexer
7
7
  title "Dart"
8
- desc "The Dart programming language (dartlang.com)"
8
+ desc "The Dart programming language (dart.dev)"
9
9
 
10
10
  tag 'dart'
11
11
  filenames '*.dart'
12
12
  mimetypes 'text/x-dart'
13
13
 
14
14
  keywords = %w(
15
- as assert break case catch continue default do else finally for
16
- if in is new rethrow return super switch this throw try while with
15
+ as assert await break case catch continue default do else finally for
16
+ if in is new rethrow return super switch this throw try while with yield
17
17
  )
18
18
 
19
19
  declarations = %w(
20
- abstract dynamic const external extends factory final get implements
21
- native operator set static typedef var
20
+ abstract async dynamic const covariant external extends factory final get
21
+ implements late native on operator required set static sync typedef var
22
22
  )
23
23
 
24
- types = %w(bool double Dynamic enum int num Object Set String void)
24
+ types = %w(bool Comparable double Dynamic enum Function int List Map Never Null num Object Pattern Set String Symbol Type Uri void)
25
25
 
26
- imports = %w(import export library part\s*of part source)
26
+ imports = %w(import deferred export library part\s*of part source)
27
27
 
28
28
  id = /[a-zA-Z_]\w*/
29
29
 
@@ -53,7 +53,7 @@ module Rouge
53
53
  rule %r/(?:#{declarations.join('|')})\b/, Keyword::Declaration
54
54
  rule %r/(?:#{types.join('|')})\b/, Keyword::Type
55
55
  rule %r/(?:true|false|null)\b/, Keyword::Constant
56
- rule %r/(?:class|interface)\b/, Keyword::Declaration, :class
56
+ rule %r/(?:class|interface|mixin)\b/, Keyword::Declaration, :class
57
57
  rule %r/(?:#{imports.join('|')})\b/, Keyword::Namespace, :import
58
58
  rule %r/(\.)(#{id})/ do
59
59
  groups Operator, Name::Attribute
@@ -7,9 +7,9 @@ module Rouge
7
7
  desc "Embedded Elixir"
8
8
 
9
9
  tag 'eex'
10
- aliases 'leex'
10
+ aliases 'leex', 'heex'
11
11
 
12
- filenames '*.eex', '*.leex'
12
+ filenames '*.eex', '*.leex', '*.heex'
13
13
 
14
14
  def initialize(opts={})
15
15
  @elixir_lexer = Elixir.new(opts)
@@ -243,8 +243,8 @@ module Rouge
243
243
  end
244
244
 
245
245
  # strings
246
- rule %r/"""\s+.*?\s+"""/, Str
247
- rule %r/"(\\.|[^\\])*?"/, Str
246
+ rule %r/"(?:\\\\|\\"|[^"])*"/, Str
247
+ rule %r/\S+"\s+(?:\\\\|\\"|[^"])*"/, Str
248
248
  rule %r/(CHAR:)(\s+)(\\[\\abfnrstv]*|\S)(?=\s)/, Str::Char
249
249
 
250
250
  # comments
@@ -0,0 +1,74 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ class Fluent < RegexLexer
7
+ title 'Fluent'
8
+ desc 'Fluent localization files'
9
+ tag 'fluent'
10
+ aliases 'ftl'
11
+ filenames '*.ftl'
12
+
13
+ state :root do
14
+ rule %r{( *)(\=)( *)} do
15
+ groups Text::Whitespace, Punctuation, Text::Whitespace
16
+ push :template
17
+ end
18
+
19
+ rule %r{(?:\s*\n)+}m, Text::Whitespace
20
+ rule %r{\#{1,3}(?: .*)?$}, Comment::Single
21
+ rule %r{[a-zA-Z][a-zA-Z0-9_-]*}, Name::Constant
22
+ rule %r{\-[a-zA-Z][a-zA-Z0-9_-]*}, Name::Entity
23
+ rule %r{\s*\.[a-zA-Z][a-zA-Z0-9_-]*}, Name::Attribute
24
+ rule %r{\s+(?=[^\s\.])}, Text::Whitespace, :template
25
+ end
26
+
27
+ state :template do
28
+ rule %r{\n}m, Text::Whitespace, :pop!
29
+ rule %r{[^\{\n\}\*]+}, Text
30
+ rule %r{\{}, Punctuation, :placeable
31
+ rule %r{(?=\})}, Punctuation, :pop!
32
+ end
33
+
34
+ state :placeable do
35
+ rule %r{\s+}m, Text::Whitespace
36
+ rule %r{\{}, Punctuation, :placeable
37
+ rule %r{\}}, Punctuation, :pop!
38
+ rule %r{\$[a-zA-Z][a-zA-Z0-9_-]*}, Name::Variable
39
+ rule %r{\-[a-zA-Z][a-zA-Z0-9_-]*}, Name::Entity
40
+ rule %r{\.[a-zA-Z][a-zA-Z0-9_-]*}, Name::Attribute
41
+ rule %r{[A-Z]+}, Name::Builtin
42
+ rule %r{[a-zA-Z][a-zA-Z0-9_-]*}, Name::Constant
43
+ rule %r{[\(\),\:]}, Punctuation
44
+ rule %r{->}, Punctuation
45
+ rule %r{\*}, Punctuation::Indicator
46
+ rule %r{\-?\d+\.\d+?}, Literal::Number::Float
47
+ rule %r{\-?\d+}, Literal::Number::Integer
48
+ rule %r{"}, Str::Double, :string
49
+
50
+ rule %r{(\[)(\-?\d+\.\d+)(\])} do
51
+ groups Punctuation, Literal::Number::Float, Punctuation
52
+ push :template
53
+ end
54
+
55
+ rule %r{(\[)(\-?\d+)(\])} do
56
+ groups Punctuation, Literal::Number::Integer, Punctuation
57
+ push :template
58
+ end
59
+
60
+ rule %r{(\[)([a-zA-Z][a-zA-Z0-9_-]+)(\])} do
61
+ groups Punctuation, Str::Symbol, Punctuation
62
+ push :template
63
+ end
64
+ end
65
+
66
+ state :string do
67
+ rule %r{\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{6}}, Str::Escape
68
+ rule %r{\\.}, Str::Escape
69
+ rule %r{[^\"\\]}, Str::Double
70
+ rule %r{"}, Str::Double, :pop!
71
+ end
72
+ end
73
+ end
74
+ end
@@ -17,7 +17,7 @@ module Rouge
17
17
  rule %r/^=====.*=====$/, Generic::Heading
18
18
  # timestamps
19
19
  rule %r/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ UTC$/, Comment::Single
20
- rule %r/^Result size of .+\s*.*}/, Comment::Multiline
20
+ rule %r/^Result size of .+\n.+{[^}]*}/, Comment::Multiline
21
21
  rule %r/--.*$/, Comment::Single
22
22
 
23
23
  rule %r/\[/, Comment::Special, :annotation
@@ -5,6 +5,7 @@ module Rouge
5
5
  module Lexers
6
6
  class Hcl < RegexLexer
7
7
  tag 'hcl'
8
+ filenames '*.hcl', '*.nomad'
8
9
 
9
10
  title 'Hashicorp Configuration Language'
10
11
  desc 'Hashicorp Configuration Language, used by Terraform and other Hashicorp tools'