rouge 3.4.1 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rouge.rb +3 -0
  3. data/lib/rouge/cli.rb +19 -2
  4. data/lib/rouge/demos/bpf +7 -0
  5. data/lib/rouge/demos/brainfuck +5 -0
  6. data/lib/rouge/demos/magik +6 -0
  7. data/lib/rouge/formatter.rb +2 -2
  8. data/lib/rouge/formatters/tex.rb +90 -0
  9. data/lib/rouge/guessers/glob_mapping.rb +1 -1
  10. data/lib/rouge/lexer.rb +22 -10
  11. data/lib/rouge/lexers/abap.rb +11 -11
  12. data/lib/rouge/lexers/actionscript.rb +34 -34
  13. data/lib/rouge/lexers/apache.rb +8 -8
  14. data/lib/rouge/lexers/apple_script.rb +15 -14
  15. data/lib/rouge/lexers/awk.rb +25 -25
  16. data/lib/rouge/lexers/biml.rb +4 -4
  17. data/lib/rouge/lexers/bpf.rb +104 -0
  18. data/lib/rouge/lexers/brainfuck.rb +53 -0
  19. data/lib/rouge/lexers/bsl.rb +12 -12
  20. data/lib/rouge/lexers/c.rb +30 -30
  21. data/lib/rouge/lexers/ceylon.rb +1 -29
  22. data/lib/rouge/lexers/cfscript.rb +26 -26
  23. data/lib/rouge/lexers/clojure.rb +14 -14
  24. data/lib/rouge/lexers/cmake.rb +14 -14
  25. data/lib/rouge/lexers/coffeescript.rb +30 -30
  26. data/lib/rouge/lexers/common_lisp.rb +36 -36
  27. data/lib/rouge/lexers/conf.rb +6 -6
  28. data/lib/rouge/lexers/coq.rb +18 -18
  29. data/lib/rouge/lexers/cpp.rb +8 -8
  30. data/lib/rouge/lexers/crystal.rb +70 -70
  31. data/lib/rouge/lexers/csharp.rb +28 -28
  32. data/lib/rouge/lexers/css.rb +23 -23
  33. data/lib/rouge/lexers/d.rb +59 -59
  34. data/lib/rouge/lexers/dart.rb +33 -33
  35. data/lib/rouge/lexers/digdag.rb +1 -1
  36. data/lib/rouge/lexers/docker.rb +10 -10
  37. data/lib/rouge/lexers/dot.rb +16 -16
  38. data/lib/rouge/lexers/eiffel.rb +20 -20
  39. data/lib/rouge/lexers/elixir.rb +29 -28
  40. data/lib/rouge/lexers/elm.rb +29 -29
  41. data/lib/rouge/lexers/erb.rb +4 -4
  42. data/lib/rouge/lexers/factor.rb +40 -40
  43. data/lib/rouge/lexers/fortran.rb +32 -32
  44. data/lib/rouge/lexers/fsharp.rb +26 -26
  45. data/lib/rouge/lexers/gherkin.rb +13 -13
  46. data/lib/rouge/lexers/glsl.rb +0 -4
  47. data/lib/rouge/lexers/go.rb +1 -1
  48. data/lib/rouge/lexers/graphql.rb +62 -62
  49. data/lib/rouge/lexers/groovy.rb +23 -25
  50. data/lib/rouge/lexers/hack.rb +1 -1
  51. data/lib/rouge/lexers/haml.rb +25 -29
  52. data/lib/rouge/lexers/handlebars.rb +18 -18
  53. data/lib/rouge/lexers/haskell.rb +66 -65
  54. data/lib/rouge/lexers/hcl.rb +25 -25
  55. data/lib/rouge/lexers/html.rb +31 -31
  56. data/lib/rouge/lexers/http.rb +4 -4
  57. data/lib/rouge/lexers/hylang.rb +14 -14
  58. data/lib/rouge/lexers/idlang.rb +32 -32
  59. data/lib/rouge/lexers/igorpro.rb +30 -30
  60. data/lib/rouge/lexers/ini.rb +12 -12
  61. data/lib/rouge/lexers/io.rb +7 -7
  62. data/lib/rouge/lexers/irb.rb +5 -5
  63. data/lib/rouge/lexers/java.rb +24 -24
  64. data/lib/rouge/lexers/javascript.rb +51 -51
  65. data/lib/rouge/lexers/jinja.rb +22 -22
  66. data/lib/rouge/lexers/json.rb +11 -10
  67. data/lib/rouge/lexers/json_doc.rb +2 -2
  68. data/lib/rouge/lexers/jsonnet.rb +18 -18
  69. data/lib/rouge/lexers/jsp.rb +28 -28
  70. data/lib/rouge/lexers/jsx.rb +16 -16
  71. data/lib/rouge/lexers/julia.rb +44 -44
  72. data/lib/rouge/lexers/kotlin.rb +3 -3
  73. data/lib/rouge/lexers/lasso.rb +50 -50
  74. data/lib/rouge/lexers/liquid.rb +53 -53
  75. data/lib/rouge/lexers/literate_coffeescript.rb +2 -2
  76. data/lib/rouge/lexers/literate_haskell.rb +5 -5
  77. data/lib/rouge/lexers/llvm.rb +23 -16
  78. data/lib/rouge/lexers/lua.rb +3 -3
  79. data/lib/rouge/lexers/m68k.rb +18 -19
  80. data/lib/rouge/lexers/magik.rb +126 -0
  81. data/lib/rouge/lexers/make.rb +22 -28
  82. data/lib/rouge/lexers/markdown.rb +37 -37
  83. data/lib/rouge/lexers/mathematica.rb +11 -11
  84. data/lib/rouge/lexers/matlab.rb +20 -20
  85. data/lib/rouge/lexers/moonscript.rb +3 -3
  86. data/lib/rouge/lexers/mosel.rb +17 -17
  87. data/lib/rouge/lexers/mxml.rb +18 -18
  88. data/lib/rouge/lexers/nasm.rb +24 -25
  89. data/lib/rouge/lexers/nginx.rb +14 -14
  90. data/lib/rouge/lexers/nim.rb +1 -1
  91. data/lib/rouge/lexers/nix.rb +42 -42
  92. data/lib/rouge/lexers/objective_c.rb +38 -38
  93. data/lib/rouge/lexers/ocaml.rb +29 -29
  94. data/lib/rouge/lexers/pascal.rb +4 -4
  95. data/lib/rouge/lexers/perl.rb +68 -68
  96. data/lib/rouge/lexers/php.rb +38 -38
  97. data/lib/rouge/lexers/plist.rb +14 -14
  98. data/lib/rouge/lexers/pony.rb +19 -19
  99. data/lib/rouge/lexers/powershell.rb +25 -25
  100. data/lib/rouge/lexers/praat.rb +75 -75
  101. data/lib/rouge/lexers/prolog.rb +26 -20
  102. data/lib/rouge/lexers/prometheus.rb +30 -30
  103. data/lib/rouge/lexers/properties.rb +12 -12
  104. data/lib/rouge/lexers/protobuf.rb +22 -22
  105. data/lib/rouge/lexers/puppet.rb +31 -31
  106. data/lib/rouge/lexers/python.rb +52 -52
  107. data/lib/rouge/lexers/q.rb +12 -12
  108. data/lib/rouge/lexers/qml.rb +12 -12
  109. data/lib/rouge/lexers/r.rb +12 -12
  110. data/lib/rouge/lexers/racket.rb +22 -22
  111. data/lib/rouge/lexers/ruby.rb +71 -69
  112. data/lib/rouge/lexers/rust.rb +30 -30
  113. data/lib/rouge/lexers/sass.rb +8 -8
  114. data/lib/rouge/lexers/sass/common.rb +40 -40
  115. data/lib/rouge/lexers/scala.rb +43 -43
  116. data/lib/rouge/lexers/scheme.rb +18 -18
  117. data/lib/rouge/lexers/scss.rb +3 -3
  118. data/lib/rouge/lexers/sed.rb +29 -29
  119. data/lib/rouge/lexers/shell.rb +61 -52
  120. data/lib/rouge/lexers/sieve.rb +8 -8
  121. data/lib/rouge/lexers/slim.rb +24 -24
  122. data/lib/rouge/lexers/smalltalk.rb +33 -33
  123. data/lib/rouge/lexers/smarty.rb +12 -12
  124. data/lib/rouge/lexers/sml.rb +67 -67
  125. data/lib/rouge/lexers/sqf.rb +1 -1
  126. data/lib/rouge/lexers/sql.rb +21 -21
  127. data/lib/rouge/lexers/supercollider.rb +19 -19
  128. data/lib/rouge/lexers/swift.rb +42 -39
  129. data/lib/rouge/lexers/tap.rb +20 -20
  130. data/lib/rouge/lexers/tcl.rb +27 -27
  131. data/lib/rouge/lexers/terraform.rb +13 -13
  132. data/lib/rouge/lexers/tex.rb +19 -19
  133. data/lib/rouge/lexers/toml.rb +18 -18
  134. data/lib/rouge/lexers/tulip.rb +36 -36
  135. data/lib/rouge/lexers/turtle.rb +35 -38
  136. data/lib/rouge/lexers/vala.rb +17 -17
  137. data/lib/rouge/lexers/vb.rb +27 -27
  138. data/lib/rouge/lexers/verilog.rb +25 -27
  139. data/lib/rouge/lexers/vhdl.rb +10 -10
  140. data/lib/rouge/lexers/viml.rb +14 -14
  141. data/lib/rouge/lexers/vue.rb +9 -9
  142. data/lib/rouge/lexers/wollok.rb +25 -25
  143. data/lib/rouge/lexers/xml.rb +17 -21
  144. data/lib/rouge/lexers/xojo.rb +15 -15
  145. data/lib/rouge/lexers/yaml.rb +61 -61
  146. data/lib/rouge/plugins/redcarpet.rb +1 -1
  147. data/lib/rouge/tex_theme_renderer.rb +128 -0
  148. data/lib/rouge/theme.rb +4 -0
  149. data/lib/rouge/themes/magritte.rb +78 -0
  150. data/lib/rouge/version.rb +1 -1
  151. metadata +11 -2
@@ -13,12 +13,12 @@ module Rouge
13
13
 
14
14
  # short and sweet
15
15
  state :root do
16
- rule /#.*?\n/, Comment
17
- rule /".*?"/, Str::Double
18
- rule /'.*?'/, Str::Single
19
- rule /[a-z]\w*/i, Name
20
- rule /\d+/, Num
21
- rule /[^\d\w#"']+/, Text
16
+ rule %r/#.*?\n/, Comment
17
+ rule %r/".*?"/, Str::Double
18
+ rule %r/'.*?'/, Str::Single
19
+ rule %r/[a-z]\w*/i, Name
20
+ rule %r/\d+/, Num
21
+ rule %r/[^\w#"']+/, Text
22
22
  end
23
23
  end
24
24
  end
@@ -90,8 +90,8 @@ module Rouge
90
90
  set_options = /(Set|Unset)(\s+)(Universe|Printing|Implicit|Strict)(\s+)(Polymorphism|All|Notations|Arguments|Universes|Implicit)(\s*)\./m
91
91
 
92
92
  state :root do
93
- rule /[(][*](?![)])/, Comment, :comment
94
- rule /\s+/m, Text::Whitespace
93
+ rule %r/[(][*](?![)])/, Comment, :comment
94
+ rule %r/\s+/m, Text::Whitespace
95
95
  rule module_type do |m|
96
96
  token Keyword , 'Module'
97
97
  token Text::Whitespace , m[1]
@@ -113,8 +113,8 @@ module Rouge
113
113
  @continue = false
114
114
  push :continue_id
115
115
  end
116
- rule /\/\\/, Operator
117
- rule /\\\//, Operator
116
+ rule %r(/\\), Operator
117
+ rule %r/\\\//, Operator
118
118
  rule operator do |m|
119
119
  match = m[0]
120
120
  if self.class.keyopts.include? match
@@ -124,31 +124,31 @@ module Rouge
124
124
  end
125
125
  end
126
126
 
127
- rule /-?\d[\d_]*(.[\d_]*)?(e[+-]?\d[\d_]*)/i, Num::Float
128
- rule /\d[\d_]*/, Num::Integer
127
+ rule %r/-?\d[\d_]*(.[\d_]*)?(e[+-]?\d[\d_]*)/i, Num::Float
128
+ rule %r/\d[\d_]*/, Num::Integer
129
129
 
130
- rule /'(?:(\\[\\"'ntbr ])|(\\[0-9]{3})|(\\x\h{2}))'/, Str::Char
131
- rule /'/, Keyword
132
- rule /"/, Str::Double, :string
133
- rule /[~?]#{id}/, Name::Variable
130
+ rule %r/'(?:(\\[\\"'ntbr ])|(\\[0-9]{3})|(\\x\h{2}))'/, Str::Char
131
+ rule %r/'/, Keyword
132
+ rule %r/"/, Str::Double, :string
133
+ rule %r/[~?]#{id}/, Name::Variable
134
134
  end
135
135
 
136
136
  state :comment do
137
- rule /[^(*)]+/, Comment
137
+ rule %r/[^(*)]+/, Comment
138
138
  rule(/[(][*]/) { token Comment; push }
139
- rule /[*][)]/, Comment, :pop!
140
- rule /[(*)]/, Comment
139
+ rule %r/[*][)]/, Comment, :pop!
140
+ rule %r/[(*)]/, Comment
141
141
  end
142
142
 
143
143
  state :string do
144
- rule /(?:\\")+|[^"]/, Str::Double
144
+ rule %r/(?:\\")+|[^"]/, Str::Double
145
145
  mixin :escape_sequence
146
- rule /\\\n/, Str::Double
147
- rule /"/, Str::Double, :pop!
146
+ rule %r/\\\n/, Str::Double
147
+ rule %r/"/, Str::Double, :pop!
148
148
  end
149
149
 
150
150
  state :escape_sequence do
151
- rule /\\[\\"'ntbr]/, Str::Escape
151
+ rule %r/\\[\\"'ntbr]/, Str::Escape
152
152
  end
153
153
 
154
154
  state :continue_id do
@@ -171,7 +171,7 @@ module Rouge
171
171
  @continue = false
172
172
  pop!
173
173
  end
174
- rule // do
174
+ rule %r// do
175
175
  if @continue
176
176
  token Name::Constant , @name
177
177
  else
@@ -49,7 +49,7 @@ module Rouge
49
49
 
50
50
  prepend :root do
51
51
  # Offload C++ extensions, http://offload.codeplay.com/
52
- rule /(?:__offload|__blockingoffload|__outer)\b/, Keyword::Pseudo
52
+ rule %r/(?:__offload|__blockingoffload|__outer)\b/, Keyword::Pseudo
53
53
  end
54
54
 
55
55
  # digits with optional inner quotes
@@ -57,21 +57,21 @@ module Rouge
57
57
  dq = /\d('?\d)*/
58
58
 
59
59
  prepend :statements do
60
- rule /class\b/, Keyword, :classname
60
+ rule %r/class\b/, Keyword, :classname
61
61
  rule %r((#{dq}[.]#{dq}?|[.]#{dq})(e[+-]?#{dq}[lu]*)?)i, Num::Float
62
62
  rule %r(#{dq}e[+-]?#{dq}[lu]*)i, Num::Float
63
- rule /0x\h('?\h)*[lu]*/i, Num::Hex
64
- rule /0[0-7]('?[0-7])*[lu]*/i, Num::Oct
65
- rule /#{dq}[lu]*/i, Num::Integer
66
- rule /\bnullptr\b/, Name::Builtin
67
- rule /(?:u8|u|U|L)?R"([a-zA-Z0-9_{}\[\]#<>%:;.?*\+\-\/\^&|~!=,"']{,16})\(.*?\)\1"/m, Str
63
+ rule %r/0x\h('?\h)*[lu]*/i, Num::Hex
64
+ rule %r/0[0-7]('?[0-7])*[lu]*/i, Num::Oct
65
+ rule %r/#{dq}[lu]*/i, Num::Integer
66
+ rule %r/\bnullptr\b/, Name::Builtin
67
+ rule %r/(?:u8|u|U|L)?R"([a-zA-Z0-9_{}\[\]#<>%:;.?*\+\-\/\^&|~!=,"']{,16})\(.*?\)\1"/m, Str
68
68
  end
69
69
 
70
70
  state :classname do
71
71
  rule id, Name::Class, :pop!
72
72
 
73
73
  # template specification
74
- rule /\s*(?=>)/m, Text, :pop!
74
+ rule %r/\s*(?=>)/m, Text, :pop!
75
75
  mixin :whitespace
76
76
  end
77
77
  end
@@ -28,15 +28,15 @@ module Rouge
28
28
  rule %r(:(?:\*\*|[-+]@|[/\%&\|^`~]|\[\]=?|<<|>>|<=?>|<=?|===?)),
29
29
  Str::Symbol
30
30
 
31
- rule /:'(\\\\|\\'|[^'])*'/, Str::Symbol
32
- rule /:"/, Str::Symbol, :simple_sym
31
+ rule %r/:'(\\\\|\\'|[^'])*'/, Str::Symbol
32
+ rule %r/:"/, Str::Symbol, :simple_sym
33
33
  end
34
34
 
35
35
  state :sigil_strings do
36
36
  # %-sigiled strings
37
37
  # %(abc), %[abc], %<abc>, %.abc., %r.abc., etc
38
38
  delimiter_map = { '{' => '}', '[' => ']', '(' => ')', '<' => '>' }
39
- rule /%([rqswQWxiI])?([^\w\s])/ do |m|
39
+ rule %r/%([rqswQWxiI])?([^\w\s])/ do |m|
40
40
  open = Regexp.escape(m[2])
41
41
  close = Regexp.escape(delimiter_map[m[2]] || m[2])
42
42
  interp = /[rQWxI]/ === m[1]
@@ -54,38 +54,38 @@ module Rouge
54
54
  token toktype
55
55
 
56
56
  push do
57
- rule /\\[##{open}#{close}\\]/, Str::Escape
57
+ rule %r/\\[##{open}#{close}\\]/, Str::Escape
58
58
  # nesting rules only with asymmetric delimiters
59
59
  if open != close
60
- rule /#{open}/ do
60
+ rule %r/#{open}/ do
61
61
  token toktype
62
62
  push
63
63
  end
64
64
  end
65
- rule /#{close}/, toktype, :pop!
65
+ rule %r/#{close}/, toktype, :pop!
66
66
 
67
67
  if interp
68
68
  mixin :string_intp_escaped
69
- rule /#/, toktype
69
+ rule %r/#/, toktype
70
70
  else
71
- rule /[\\#]/, toktype
71
+ rule %r/[\\#]/, toktype
72
72
  end
73
73
 
74
- rule /[^##{open}#{close}\\]+/m, toktype
74
+ rule %r/[^##{open}#{close}\\]+/m, toktype
75
75
  end
76
76
  end
77
77
  end
78
78
 
79
79
  state :strings do
80
80
  mixin :symbols
81
- rule /\b[a-z_]\w*?[?!]?:\s+/, Str::Symbol, :expr_start
82
- rule /'(\\\\|\\'|[^'])*'/, Str::Single
83
- rule /"/, Str::Double, :simple_string
84
- rule /(?<!\.)`/, Str::Backtick, :simple_backtick
81
+ rule %r/\b[a-z_]\w*?[?!]?:\s+/, Str::Symbol, :expr_start
82
+ rule %r/'(\\\\|\\'|[^'])*'/, Str::Single
83
+ rule %r/"/, Str::Double, :simple_string
84
+ rule %r/(?<!\.)`/, Str::Backtick, :simple_backtick
85
85
  end
86
86
 
87
87
  state :regex_flags do
88
- rule /[mixounse]*/, Str::Regex, :pop!
88
+ rule %r/[mixounse]*/, Str::Regex, :pop!
89
89
  end
90
90
 
91
91
  # double-quoted string and symbol
@@ -94,9 +94,9 @@ module Rouge
94
94
  [:backtick, Str::Backtick, '`']].each do |name, tok, fin|
95
95
  state :"simple_#{name}" do
96
96
  mixin :string_intp_escaped
97
- rule /[^\\#{fin}#]+/m, tok
98
- rule /[\\#]/, tok
99
- rule /#{fin}/, tok, :pop!
97
+ rule %r/[^\\#{fin}#]+/m, tok
98
+ rule %r/[\\#]/, tok
99
+ rule %r/#{fin}/, tok, :pop!
100
100
  end
101
101
  end
102
102
 
@@ -140,40 +140,40 @@ module Rouge
140
140
 
141
141
  state :whitespace do
142
142
  mixin :inline_whitespace
143
- rule /\n\s*/m, Text, :expr_start
144
- rule /#.*$/, Comment::Single
143
+ rule %r/\n\s*/m, Text, :expr_start
144
+ rule %r/#.*$/, Comment::Single
145
145
 
146
146
  rule %r(=begin\b.*?\n=end\b)m, Comment::Multiline
147
147
  end
148
148
 
149
149
  state :inline_whitespace do
150
- rule /[ \t\r]+/, Text
150
+ rule %r/[ \t\r]+/, Text
151
151
  end
152
152
 
153
153
  state :root do
154
154
  mixin :whitespace
155
- rule /__END__/, Comment::Preproc, :end_part
155
+ rule %r/__END__/, Comment::Preproc, :end_part
156
156
 
157
- rule /0_?[0-7]+(?:_[0-7]+)*/, Num::Oct
158
- rule /0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*/, Num::Hex
159
- rule /0b[01]+(?:_[01]+)*/, Num::Bin
160
- rule /\d+\.\d+(e[\+\-]?\d+)?/, Num::Float
161
- rule /[\d]+(?:_\d+)*/, Num::Integer
157
+ rule %r/0_?[0-7]+(?:_[0-7]+)*/, Num::Oct
158
+ rule %r/0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*/, Num::Hex
159
+ rule %r/0b[01]+(?:_[01]+)*/, Num::Bin
160
+ rule %r/\d+\.\d+(e[\+\-]?\d+)?/, Num::Float
161
+ rule %r/[\d]+(?:_\d+)*/, Num::Integer
162
162
 
163
- rule /@\[([^\]]+)\]/, Name::Decorator
163
+ rule %r/@\[([^\]]+)\]/, Name::Decorator
164
164
 
165
165
  # names
166
- rule /@@[a-z_]\w*/i, Name::Variable::Class
167
- rule /@[a-z_]\w*/i, Name::Variable::Instance
168
- rule /\$\w+/, Name::Variable::Global
166
+ rule %r/@@[a-z_]\w*/i, Name::Variable::Class
167
+ rule %r/@[a-z_]\w*/i, Name::Variable::Instance
168
+ rule %r/\$\w+/, Name::Variable::Global
169
169
  rule %r(\$[!@&`'+~=/\\,;.<>_*\$?:"]), Name::Variable::Global
170
- rule /\$-[0adFiIlpvw]/, Name::Variable::Global
171
- rule /::/, Operator
170
+ rule %r/\$-[0adFiIlpvw]/, Name::Variable::Global
171
+ rule %r/::/, Operator
172
172
 
173
173
  mixin :strings
174
174
 
175
- rule /(?:#{keywords.join('|')})\b/, Keyword, :expr_start
176
- rule /(?:#{keywords_pseudo.join('|')})\b/, Keyword::Pseudo, :expr_start
175
+ rule %r/(?:#{keywords.join('|')})\b/, Keyword, :expr_start
176
+ rule %r/(?:#{keywords_pseudo.join('|')})\b/, Keyword::Pseudo, :expr_start
177
177
 
178
178
  rule %r(
179
179
  (module)
@@ -183,52 +183,52 @@ module Rouge
183
183
  groups Keyword, Text, Name::Namespace
184
184
  end
185
185
 
186
- rule /(def\b)(\s*)/ do
186
+ rule %r/(def\b)(\s*)/ do
187
187
  groups Keyword, Text
188
188
  push :funcname
189
189
  end
190
190
 
191
- rule /(class\b)(\s*)/ do
191
+ rule %r/(class\b)(\s*)/ do
192
192
  groups Keyword, Text
193
193
  push :classname
194
194
  end
195
195
 
196
- rule /(?:#{builtins_q.join('|')})[?]/, Name::Builtin, :expr_start
197
- rule /(?:#{builtins_b.join('|')})!/, Name::Builtin, :expr_start
198
- rule /(?<!\.)(?:#{builtins_g.join('|')})\b/,
196
+ rule %r/(?:#{builtins_q.join('|')})[?]/, Name::Builtin, :expr_start
197
+ rule %r/(?:#{builtins_b.join('|')})!/, Name::Builtin, :expr_start
198
+ rule %r/(?<!\.)(?:#{builtins_g.join('|')})\b/,
199
199
  Name::Builtin, :method_call
200
200
 
201
201
  mixin :has_heredocs
202
202
 
203
203
  # `..` and `...` for ranges must have higher priority than `.`
204
204
  # Otherwise, they will be parsed as :method_call
205
- rule /\.{2,3}/, Operator, :expr_start
205
+ rule %r/\.{2,3}/, Operator, :expr_start
206
206
 
207
- rule /[A-Z][a-zA-Z0-9_]*/, Name::Constant, :method_call
208
- rule /(\.|::)(\s*)([a-z_]\w*[!?]?|[*%&^`~+-\/\[<>=])/ do
207
+ rule %r/[A-Z][a-zA-Z0-9_]*/, Name::Constant, :method_call
208
+ rule %r/(\.|::)(\s*)([a-z_]\w*[!?]?|[*%&^`~+-\/\[<>=])/ do
209
209
  groups Punctuation, Text, Name::Function
210
210
  push :method_call
211
211
  end
212
212
 
213
- rule /[a-zA-Z_]\w*[?!]/, Name, :expr_start
214
- rule /[a-zA-Z_]\w*/, Name, :method_call
215
- rule /\*\*|<<?|>>?|>=|<=|<=>|=~|={3}|!~|&&?|\|\||\./,
213
+ rule %r/[a-zA-Z_]\w*[?!]/, Name, :expr_start
214
+ rule %r/[a-zA-Z_]\w*/, Name, :method_call
215
+ rule %r/\*\*|<<?|>>?|>=|<=|<=>|=~|={3}|!~|&&?|\|\||\./,
216
216
  Operator, :expr_start
217
- rule /[-+\/*%=<>&!^|~]=?/, Operator, :expr_start
217
+ rule %r/[-+\/*%=<>&!^|~]=?/, Operator, :expr_start
218
218
  rule(/[?]/) { token Punctuation; push :ternary; push :expr_start }
219
219
  rule %r<[\[({,:\\;/]>, Punctuation, :expr_start
220
220
  rule %r<[\])}]>, Punctuation
221
221
  end
222
222
 
223
223
  state :has_heredocs do
224
- rule /(?<!\w)(<<[-~]?)(["`']?)([a-zA-Z_]\w*)(\2)/ do |m|
224
+ rule %r/(?<!\w)(<<[-~]?)(["`']?)([a-zA-Z_]\w*)(\2)/ do |m|
225
225
  token Operator, m[1]
226
226
  token Name::Constant, "#{m[2]}#{m[3]}#{m[4]}"
227
227
  @heredoc_queue << [['<<-', '<<~'].include?(m[1]), m[3]]
228
228
  push :heredoc_queue unless state? :heredoc_queue
229
229
  end
230
230
 
231
- rule /(<<[-~]?)(["'])(\2)/ do |m|
231
+ rule %r/(<<[-~]?)(["'])(\2)/ do |m|
232
232
  token Operator, m[1]
233
233
  token Name::Constant, "#{m[2]}#{m[3]}#{m[4]}"
234
234
  @heredoc_queue << [['<<-', '<<~'].include?(m[1]), '']
@@ -237,7 +237,7 @@ module Rouge
237
237
  end
238
238
 
239
239
  state :heredoc_queue do
240
- rule /(?=\n)/ do
240
+ rule %r/(?=\n)/ do
241
241
  goto :resolve_heredocs
242
242
  end
243
243
 
@@ -247,13 +247,13 @@ module Rouge
247
247
  state :resolve_heredocs do
248
248
  mixin :string_intp_escaped
249
249
 
250
- rule /\n/, Str::Heredoc, :test_heredoc
251
- rule /[#\\\n]/, Str::Heredoc
252
- rule /[^#\\\n]+/, Str::Heredoc
250
+ rule %r/\n/, Str::Heredoc, :test_heredoc
251
+ rule %r/[#\\\n]/, Str::Heredoc
252
+ rule %r/[^#\\\n]+/, Str::Heredoc
253
253
  end
254
254
 
255
255
  state :test_heredoc do
256
- rule /[^#\\\n]*$/ do |m|
256
+ rule %r/[^#\\\n]*$/ do |m|
257
257
  tolerant, heredoc_name = @heredoc_queue.first
258
258
  check = tolerant ? m[0].strip : m[0].rstrip
259
259
 
@@ -275,12 +275,12 @@ module Rouge
275
275
  end
276
276
 
277
277
  state :funcname do
278
- rule /\s+/, Text
279
- rule /\(/, Punctuation, :defexpr
278
+ rule %r/\s+/, Text
279
+ rule %r/\(/, Punctuation, :defexpr
280
280
  rule %r(
281
- (?:([a-zA-Z_][\w_]*)(\.))?
281
+ (?:([a-zA-Z_]\w*)(\.))?
282
282
  (
283
- [a-zA-Z_][\w_]*[!?]? |
283
+ [a-zA-Z_]\w*[!?]? |
284
284
  \*\*? | [-+]@? | [/%&\|^`~] | \[\]=? |
285
285
  <<? | >>? | <=>? | >= | ===?
286
286
  )
@@ -294,20 +294,20 @@ module Rouge
294
294
  end
295
295
 
296
296
  state :classname do
297
- rule /\s+/, Text
298
- rule /\(/ do
297
+ rule %r/\s+/, Text
298
+ rule %r/\(/ do
299
299
  token Punctuation
300
300
  push :defexpr
301
301
  push :expr_start
302
302
  end
303
303
 
304
304
  # class << expr
305
- rule /<</ do
305
+ rule %r/<</ do
306
306
  token Operator
307
307
  goto :expr_start
308
308
  end
309
309
 
310
- rule /[A-Z_]\w*/, Name::Class, :pop!
310
+ rule %r/[A-Z_]\w*/, Name::Class, :pop!
311
311
 
312
312
  rule(//) { pop! }
313
313
  end
@@ -319,11 +319,11 @@ module Rouge
319
319
  end
320
320
 
321
321
  state :defexpr do
322
- rule /(\))(\.|::)?/ do
322
+ rule %r/(\))(\.|::)?/ do
323
323
  groups Punctuation, Operator
324
324
  pop!
325
325
  end
326
- rule /\(/ do
326
+ rule %r/\(/ do
327
327
  token Punctuation
328
328
  push :defexpr
329
329
  push :expr_start
@@ -333,20 +333,20 @@ module Rouge
333
333
  end
334
334
 
335
335
  state :in_interp do
336
- rule /}/, Str::Interpol, :pop!
336
+ rule %r/}/, Str::Interpol, :pop!
337
337
  mixin :root
338
338
  end
339
339
 
340
340
  state :string_intp do
341
- rule /[#][{]/, Str::Interpol, :in_interp
342
- rule /#(@@?|\$)[a-z_]\w*/i, Str::Interpol
341
+ rule %r/[#][{]/, Str::Interpol, :in_interp
342
+ rule %r/#(@@?|\$)[a-z_]\w*/i, Str::Interpol
343
343
  end
344
344
 
345
345
  state :string_intp_escaped do
346
346
  mixin :string_intp
347
- rule /\\([\\abefnrstv#"']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})/,
347
+ rule %r/\\([\\abefnrstv#"']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})/,
348
348
  Str::Escape
349
- rule /\\./, Str::Escape
349
+ rule %r/\\./, Str::Escape
350
350
  end
351
351
 
352
352
  state :method_call do
@@ -399,7 +399,7 @@ module Rouge
399
399
 
400
400
  # special case for using a single space. Ruby demands that
401
401
  # these be in a single line, otherwise it would make no sense.
402
- rule /(\s*)(%[rqswQWxiI]? \S* )/ do
402
+ rule %r/(\s*)(%[rqswQWxiI]? \S* )/ do
403
403
  groups Text, Str::Other
404
404
  pop!
405
405
  end
@@ -423,7 +423,7 @@ module Rouge
423
423
 
424
424
  state :end_part do
425
425
  # eat up the rest of the stream as Comment::Preproc
426
- rule /.+/m, Comment::Preproc, :pop!
426
+ rule %r/.+/m, Comment::Preproc, :pop!
427
427
  end
428
428
  end
429
429
  end