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
@@ -11,34 +11,6 @@ module Rouge
11
11
  title "Ceylon"
12
12
  desc 'Say more, more clearly.'
13
13
 
14
- keywords = %w(
15
- break case catch continue else finally for in
16
- if return switch this throw try while is exists dynamic
17
- nonempty then outer assert let
18
- )
19
-
20
- keywords_declaration = %w(
21
- abstracts extends satisfies super given of out assign
22
- )
23
-
24
- keywords_type = %w(
25
- function value void new
26
- )
27
-
28
- keywords_namespace = %w(
29
- assembly module package
30
- )
31
-
32
- keywords_constant = %w(
33
- true false null
34
- )
35
-
36
- annotations = %w(
37
- shared abstract formal default actual variable deprecated small
38
- late literal doc by see throws optional license tagged final native
39
- annotation sealed
40
- )
41
-
42
14
  state :whitespace do
43
15
  rule %r([^\S\n]+), Text
44
16
  rule %r(//.*?\n), Comment::Single
@@ -86,7 +58,7 @@ module Rouge
86
58
  rule %r([a-zA-Z_]\w*:), Name::Label
87
59
  rule %r((\\I[a-z]|[A-Z])\w*), Name::Decorator
88
60
  rule %r([a-zA-Z_]\w*), Name
89
- rule %r([~^*!%&\[\](){}<>|+=:;,./?-`]), Operator
61
+ rule %r([~^*!%&\[\](){}<>|+=:;,./?`-]), Operator
90
62
  rule %r(\d{1,3}(_\d{3})+\.\d{1,3}(_\d{3})+[kMGTPmunpf]?), Literal::Number::Float
91
63
  rule %r(\d{1,3}(_\d{3})+\.[0-9]+([eE][+-]?[0-9]+)?[kMGTPmunpf]?),
92
64
  Literal::Number::Float
@@ -37,30 +37,30 @@ module Rouge
37
37
 
38
38
  state :root do
39
39
  mixin :comments_and_whitespace
40
- rule /(?:#{operators.join('|')}|does not contain|greater than(?: or equal to)?|less than(?: or equal to)?)\b/i, Operator, :expr_start
40
+ rule %r/(?:#{operators.join('|')}|does not contain|greater than(?: or equal to)?|less than(?: or equal to)?)\b/i, Operator, :expr_start
41
41
  rule %r([-<>+*%&|\^/!=]=?), Operator, :expr_start
42
42
 
43
- rule /[(\[,]/, Punctuation, :expr_start
44
- rule /;/, Punctuation, :statement
45
- rule /[)\].]/, Punctuation
43
+ rule %r/[(\[,]/, Punctuation, :expr_start
44
+ rule %r/;/, Punctuation, :statement
45
+ rule %r/[)\].]/, Punctuation
46
46
 
47
- rule /[?]/ do
47
+ rule %r/[?]/ do
48
48
  token Punctuation
49
49
  push :ternary
50
50
  push :expr_start
51
51
  end
52
52
 
53
- rule /[{}]/, Punctuation, :statement
53
+ rule %r/[{}]/, Punctuation, :statement
54
54
 
55
- rule /(?:#{constants.join('|')})\b/, Name::Constant
56
- rule /(?:true|false|null)\b/, Keyword::Constant
57
- rule /import\b/, Keyword::Namespace, :import
58
- rule /(#{dotted_id})(\s*)(:)(\s*)/ do
55
+ rule %r/(?:#{constants.join('|')})\b/, Name::Constant
56
+ rule %r/(?:true|false|null)\b/, Keyword::Constant
57
+ rule %r/import\b/, Keyword::Namespace, :import
58
+ rule %r/(#{dotted_id})(\s*)(:)(\s*)/ do
59
59
  groups Name, Text, Punctuation, Text
60
60
  push :expr_start
61
61
  end
62
62
 
63
- rule /([A-Za-z_$][\w.]*)(\s*)(\()/ do |m|
63
+ rule %r/([A-Za-z_$][\w.]*)(\s*)(\()/ do |m|
64
64
  if self.class.keywords.include? m[1]
65
65
  token Keyword, m[1]
66
66
  token Text, m[2]
@@ -87,17 +87,17 @@ module Rouge
87
87
  end
88
88
  end
89
89
 
90
- rule /[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?/, Num::Float
91
- rule /0x[0-9a-fA-F]+/, Num::Hex
92
- rule /[0-9]+/, Num::Integer
93
- rule /"(\\\\|\\"|[^"])*"/, Str::Double
94
- rule /'(\\\\|\\'|[^'])*'/, Str::Single
90
+ rule %r/[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?/, Num::Float
91
+ rule %r/0x[0-9a-fA-F]+/, Num::Hex
92
+ rule %r/[0-9]+/, Num::Integer
93
+ rule %r/"(\\\\|\\"|[^"])*"/, Str::Double
94
+ rule %r/'(\\\\|\\'|[^'])*'/, Str::Single
95
95
 
96
96
  end
97
97
 
98
98
  # same as java, broken out
99
99
  state :comments_and_whitespace do
100
- rule /\s+/, Text
100
+ rule %r/\s+/, Text
101
101
  rule %r(//.*?$), Comment::Single
102
102
  rule %r(/\*.*?\*/)m, Comment::Multiline
103
103
  end
@@ -105,14 +105,14 @@ module Rouge
105
105
  state :expr_start do
106
106
  mixin :comments_and_whitespace
107
107
 
108
- rule /[{]/, Punctuation, :object
108
+ rule %r/[{]/, Punctuation, :object
109
109
 
110
- rule //, Text, :pop!
110
+ rule %r//, Text, :pop!
111
111
  end
112
112
 
113
113
  state :statement do
114
114
 
115
- rule /[{}]/, Punctuation
115
+ rule %r/[{}]/, Punctuation
116
116
 
117
117
  mixin :expr_start
118
118
  end
@@ -120,23 +120,23 @@ module Rouge
120
120
  # object literals
121
121
  state :object do
122
122
  mixin :comments_and_whitespace
123
- rule /[}]/ do
123
+ rule %r/[}]/ do
124
124
  token Punctuation
125
125
  push :expr_start
126
126
  end
127
127
 
128
- rule /(#{dotted_id})(\s*)(:)/ do
128
+ rule %r/(#{dotted_id})(\s*)(:)/ do
129
129
  groups Name::Other, Text, Punctuation
130
130
  push :expr_start
131
131
  end
132
132
 
133
- rule /:/, Punctuation
133
+ rule %r/:/, Punctuation
134
134
  mixin :root
135
135
  end
136
136
 
137
137
  # ternary expressions, where <dotted_id>: is not a label!
138
138
  state :ternary do
139
- rule /:/ do
139
+ rule %r/:/ do
140
140
  token Punctuation
141
141
  goto :expr_start
142
142
  end
@@ -145,8 +145,8 @@ module Rouge
145
145
  end
146
146
 
147
147
  state :import do
148
- rule /\s+/m, Text
149
- rule /[a-z0-9_.]+\*?/i, Name::Namespace, :pop!
148
+ rule %r/\s+/m, Text
149
+ rule %r/[a-z0-9_.]+\*?/i, Name::Namespace, :pop!
150
150
  end
151
151
 
152
152
  end
@@ -74,22 +74,22 @@ module Rouge
74
74
  end
75
75
 
76
76
  state :root do
77
- rule /;.*?$/, Comment::Single
78
- rule /\s+/m, Text::Whitespace
77
+ rule %r/;.*?$/, Comment::Single
78
+ rule %r/\s+/m, Text::Whitespace
79
79
 
80
- rule /-?\d+\.\d+/, Num::Float
81
- rule /-?\d+/, Num::Integer
82
- rule /0x-?[0-9a-fA-F]+/, Num::Hex
80
+ rule %r/-?\d+\.\d+/, Num::Float
81
+ rule %r/-?\d+/, Num::Integer
82
+ rule %r/0x-?[0-9a-fA-F]+/, Num::Hex
83
83
 
84
- rule /"(\\.|[^"])*"/, Str
85
- rule /'#{keyword}/, Str::Symbol
86
- rule /::?#{keyword}/, Name::Constant
87
- rule /\\(.|[a-z]+)/i, Str::Char
84
+ rule %r/"(\\.|[^"])*"/, Str
85
+ rule %r/'#{keyword}/, Str::Symbol
86
+ rule %r/::?#{keyword}/, Name::Constant
87
+ rule %r/\\(.|[a-z]+)/i, Str::Char
88
88
 
89
89
 
90
- rule /~@|[`\'#^~&@]/, Operator
90
+ rule %r/~@|[`\'#^~&@]/, Operator
91
91
 
92
- rule /(\()(\s*)(#{identifier})/m do |m|
92
+ rule %r/(\()(\s*)(#{identifier})/m do |m|
93
93
  token Punctuation, m[1]
94
94
  token Text::Whitespace, m[2]
95
95
  token(name_token(m[3]) || Name::Function, m[3])
@@ -100,13 +100,13 @@ module Rouge
100
100
  end
101
101
 
102
102
  # vectors
103
- rule /[\[\]]/, Punctuation
103
+ rule %r/[\[\]]/, Punctuation
104
104
 
105
105
  # maps
106
- rule /[{}]/, Punctuation
106
+ rule %r/[{}]/, Punctuation
107
107
 
108
108
  # parentheses
109
- rule /[()]/, Punctuation
109
+ rule %r/[()]/, Punctuation
110
110
  end
111
111
  end
112
112
  end
@@ -125,23 +125,23 @@ module Rouge
125
125
  ]
126
126
 
127
127
  state :default do
128
- rule /\r\n?|\n/ do
128
+ rule %r/\r\n?|\n/ do
129
129
  token STATES_MAP[state.name.to_sym]
130
130
  end
131
- rule /./ do
131
+ rule %r/./ do
132
132
  token STATES_MAP[state.name.to_sym]
133
133
  end
134
134
  end
135
135
 
136
136
  state :variable_interpolation do
137
- rule /\$\{/ do
137
+ rule %r/\$\{/ do
138
138
  token Str::Interpol
139
139
  push :variable_reference
140
140
  end
141
141
  end
142
142
 
143
143
  state :bracket_close do
144
- rule /\]=*\]/ do |m|
144
+ rule %r/\]=*\]/ do |m|
145
145
  token STATES_MAP[state.name.to_sym]
146
146
  goto :root if m[0].length == @bracket_len
147
147
  end
@@ -150,27 +150,27 @@ module Rouge
150
150
  state :root do
151
151
  mixin :variable_interpolation
152
152
 
153
- rule /#{SPACE}/, Text
154
- rule /[()]/, Punctuation
153
+ rule %r/#{SPACE}/, Text
154
+ rule %r/[()]/, Punctuation
155
155
 
156
- rule /##{BRACKET_OPEN}/ do |m|
156
+ rule %r/##{BRACKET_OPEN}/ do |m|
157
157
  token Comment::Multiline
158
158
  @bracket_len = m[0].length - 1 # decount '#'
159
159
  goto :bracket_comment
160
160
  end
161
- rule /#{BRACKET_OPEN}/ do |m|
161
+ rule %r/#{BRACKET_OPEN}/ do |m|
162
162
  token Str::Double
163
163
  @bracket_len = m[0].length
164
164
  goto :bracket_string
165
165
  end
166
166
 
167
- rule /"/, Str::Double, :quoted_argument
167
+ rule %r/"/, Str::Double, :quoted_argument
168
168
 
169
- rule /([A-Za-z_][A-Za-z0-9_]*)(#{SPACE}*)(\()/ do |m|
169
+ rule %r/([A-Za-z_][A-Za-z0-9_]*)(#{SPACE}*)(\()/ do |m|
170
170
  groups BUILTIN_COMMANDS.include?(m[1]) ? Name::Builtin : Name::Function, Text, Punctuation
171
171
  end
172
172
 
173
- rule /#.*/, Comment::Single
173
+ rule %r/#.*/, Comment::Single
174
174
 
175
175
  mixin :default
176
176
  end
@@ -189,7 +189,7 @@ module Rouge
189
189
  state :variable_reference do
190
190
  mixin :variable_interpolation
191
191
 
192
- rule /}/, Str::Interpol, :pop!
192
+ rule %r/}/, Str::Interpol, :pop!
193
193
 
194
194
  mixin :default
195
195
  end
@@ -197,8 +197,8 @@ module Rouge
197
197
  state :quoted_argument do
198
198
  mixin :variable_interpolation
199
199
 
200
- rule /"/, Str::Double, :root
201
- rule /\\[()#" \\$@^trn;]/, Str::Escape
200
+ rule %r/"/, Str::Double, :root
201
+ rule %r/\\[()#" \\$@^trn;]/, Str::Escape
202
202
 
203
203
  mixin :default
204
204
  end
@@ -50,9 +50,9 @@ module Rouge
50
50
  id = /[$a-zA-Z_][a-zA-Z0-9_]*/
51
51
 
52
52
  state :comments_and_whitespace do
53
- rule /\s+/m, Text
54
- rule /###[^#].*?###/m, Comment::Multiline
55
- rule /#.*$/, Comment::Single
53
+ rule %r/\s+/m, Text
54
+ rule %r/###[^#].*?###/m, Comment::Multiline
55
+ rule %r/#.*$/, Comment::Single
56
56
  end
57
57
 
58
58
  state :multiline_regex do
@@ -89,21 +89,21 @@ module Rouge
89
89
  [?]|:|=|[|][|]|\\(?=\n)|(<<|>>>?|==?|!=?|[-<>+*`%&|^/])=?
90
90
  )x, Operator, :slash_starts_regex
91
91
 
92
- rule /[-=]>/, Name::Function
92
+ rule %r/[-=]>/, Name::Function
93
93
 
94
- rule /(@)([ \t]*)(#{id})/ do
94
+ rule %r/(@)([ \t]*)(#{id})/ do
95
95
  groups Name::Variable::Instance, Text, Name::Attribute
96
96
  push :slash_starts_regex
97
97
  end
98
98
 
99
- rule /([.])([ \t]*)(#{id})/ do
99
+ rule %r/([.])([ \t]*)(#{id})/ do
100
100
  groups Punctuation, Text, Name::Attribute
101
101
  push :slash_starts_regex
102
102
  end
103
103
 
104
- rule /#{id}(?=\s*:)/, Name::Attribute, :slash_starts_regex
104
+ rule %r/#{id}(?=\s*:)/, Name::Attribute, :slash_starts_regex
105
105
 
106
- rule /#{id}/ do |m|
106
+ rule %r/#{id}/ do |m|
107
107
  if self.class.keywords.include? m[0]
108
108
  token Keyword
109
109
  elsif self.class.constants.include? m[0]
@@ -117,65 +117,65 @@ module Rouge
117
117
  push :slash_starts_regex
118
118
  end
119
119
 
120
- rule /[{(\[;,]/, Punctuation, :slash_starts_regex
121
- rule /[})\].]/, Punctuation
120
+ rule %r/[{(\[;,]/, Punctuation, :slash_starts_regex
121
+ rule %r/[})\].]/, Punctuation
122
122
 
123
- rule /\d+[.]\d+([eE]\d+)?[fd]?/, Num::Float
124
- rule /0x[0-9a-fA-F]+/, Num::Hex
125
- rule /\d+/, Num::Integer
126
- rule /"""/, Str, :tdqs
127
- rule /'''/, Str, :tsqs
128
- rule /"/, Str, :dqs
129
- rule /'/, Str, :sqs
123
+ rule %r/\d+[.]\d+([eE]\d+)?[fd]?/, Num::Float
124
+ rule %r/0x[0-9a-fA-F]+/, Num::Hex
125
+ rule %r/\d+/, Num::Integer
126
+ rule %r/"""/, Str, :tdqs
127
+ rule %r/'''/, Str, :tsqs
128
+ rule %r/"/, Str, :dqs
129
+ rule %r/'/, Str, :sqs
130
130
  end
131
131
 
132
132
  state :strings do
133
133
  # all coffeescript strings are multi-line
134
- rule /[^#\\'"]+/m, Str
134
+ rule %r/[^#\\'"]+/m, Str
135
135
 
136
- rule /\\./, Str::Escape
137
- rule /#/, Str
136
+ rule %r/\\./, Str::Escape
137
+ rule %r/#/, Str
138
138
  end
139
139
 
140
140
  state :double_strings do
141
- rule /'/, Str
141
+ rule %r/'/, Str
142
142
  mixin :has_interpolation
143
143
  mixin :strings
144
144
  end
145
145
 
146
146
  state :single_strings do
147
- rule /"/, Str
147
+ rule %r/"/, Str
148
148
  mixin :strings
149
149
  end
150
150
 
151
151
  state :interpolation do
152
- rule /}/, Str::Interpol, :pop!
152
+ rule %r/}/, Str::Interpol, :pop!
153
153
  mixin :root
154
154
  end
155
155
 
156
156
  state :has_interpolation do
157
- rule /[#][{]/, Str::Interpol, :interpolation
157
+ rule %r/[#][{]/, Str::Interpol, :interpolation
158
158
  end
159
159
 
160
160
  state :dqs do
161
- rule /"/, Str, :pop!
161
+ rule %r/"/, Str, :pop!
162
162
  mixin :double_strings
163
163
  end
164
164
 
165
165
  state :tdqs do
166
- rule /"""/, Str, :pop!
167
- rule /"/, Str
166
+ rule %r/"""/, Str, :pop!
167
+ rule %r/"/, Str
168
168
  mixin :double_strings
169
169
  end
170
170
 
171
171
  state :sqs do
172
- rule /'/, Str, :pop!
172
+ rule %r/'/, Str, :pop!
173
173
  mixin :single_strings
174
174
  end
175
175
 
176
176
  state :tsqs do
177
- rule /'''/, Str, :pop!
178
- rule /'/, Str
177
+ rule %r/'''/, Str, :pop!
178
+ rule %r/'/, Str
179
179
  mixin :single_strings
180
180
  end
181
181
  end
@@ -215,19 +215,19 @@ module Rouge
215
215
  symbol = /(\|[^\|]+\||#{nonmacro}#{constituent}*)/
216
216
 
217
217
  state :root do
218
- rule /\s+/m, Text
219
- rule /;.*$/, Comment::Single
220
- rule /#\|/, Comment::Multiline, :multiline_comment
218
+ rule %r/\s+/m, Text
219
+ rule %r/;.*$/, Comment::Single
220
+ rule %r/#\|/, Comment::Multiline, :multiline_comment
221
221
 
222
222
  # encoding comment
223
- rule /#\d*Y.*$/, Comment::Special
224
- rule /"(\\.|[^"\\])*"/, Str
223
+ rule %r/#\d*Y.*$/, Comment::Special
224
+ rule %r/"(\\.|[^"\\])*"/, Str
225
225
 
226
- rule /[:']#{symbol}/, Str::Symbol
227
- rule /['`]/, Operator
226
+ rule %r/[:']#{symbol}/, Str::Symbol
227
+ rule %r/['`]/, Operator
228
228
 
229
229
  # numbers
230
- rule /[-+]?\d+\.?#{terminated}/, Num::Integer
230
+ rule %r/[-+]?\d+\.?#{terminated}/, Num::Integer
231
231
  rule %r([-+]?\d+/\d+#{terminated}), Num::Integer
232
232
  rule %r(
233
233
  [-+]?
@@ -237,65 +237,65 @@ module Rouge
237
237
  )x, Num::Float
238
238
 
239
239
  # sharpsign strings and characters
240
- rule /#\\.#{terminated}/, Str::Char
241
- rule /#\\#{symbol}/, Str::Char
240
+ rule %r/#\\.#{terminated}/, Str::Char
241
+ rule %r/#\\#{symbol}/, Str::Char
242
242
 
243
- rule /#\(/, Operator, :root
243
+ rule %r/#\(/, Operator, :root
244
244
 
245
245
  # bitstring
246
- rule /#\d*\*[01]*/, Other
246
+ rule %r/#\d*\*[01]*/, Other
247
247
 
248
248
  # uninterned symbol
249
- rule /#:#{symbol}/, Str::Symbol
249
+ rule %r/#:#{symbol}/, Str::Symbol
250
250
 
251
251
  # read-time and load-time evaluation
252
- rule /#[.,]/, Operator
252
+ rule %r/#[.,]/, Operator
253
253
 
254
254
  # function shorthand
255
- rule /#'/, Name::Function
255
+ rule %r/#'/, Name::Function
256
256
 
257
257
  # binary rational
258
- rule /#b[+-]?[01]+(\/[01]+)?/i, Num
258
+ rule %r/#b[+-]?[01]+(\/[01]+)?/i, Num
259
259
 
260
260
  # octal rational
261
- rule /#o[+-]?[0-7]+(\/[0-7]+)?/i, Num::Oct
261
+ rule %r/#o[+-]?[0-7]+(\/[0-7]+)?/i, Num::Oct
262
262
 
263
263
  # hex rational
264
- rule /#x[+-]?[0-9a-f]+(\/[0-9a-f]+)?/i, Num
264
+ rule %r/#x[+-]?[0-9a-f]+(\/[0-9a-f]+)?/i, Num
265
265
 
266
266
  # complex
267
- rule /(#c)(\()/i do
267
+ rule %r/(#c)(\()/i do
268
268
  groups Num, Punctuation
269
269
  push :root
270
270
  end
271
271
 
272
272
  # arrays and structures
273
- rule /(#(?:\d+a|s))(\()/i do
273
+ rule %r/(#(?:\d+a|s))(\()/i do
274
274
  groups Str::Other, Punctuation
275
275
  push :root
276
276
  end
277
277
 
278
278
  # path
279
- rule /#p?"(\\.|[^"])*"/i, Str::Symbol
279
+ rule %r/#p?"(\\.|[^"])*"/i, Str::Symbol
280
280
 
281
281
  # reference
282
- rule /#\d+[=#]/, Operator
282
+ rule %r/#\d+[=#]/, Operator
283
283
 
284
284
  # read-time comment
285
- rule /#+nil#{terminated}\s*\(/, Comment, :commented_form
285
+ rule %r/#+nil#{terminated}\s*\(/, Comment, :commented_form
286
286
 
287
287
  # read-time conditional
288
- rule /#[+-]/, Operator
288
+ rule %r/#[+-]/, Operator
289
289
 
290
290
  # special operators that should have been parsed already
291
- rule /(,@|,|\.)/, Operator
291
+ rule %r/(,@|,|\.)/, Operator
292
292
 
293
293
  # special constants
294
- rule /(t|nil)#{terminated}/, Name::Constant
294
+ rule %r/(t|nil)#{terminated}/, Name::Constant
295
295
 
296
296
  # functions and variables
297
297
  # note that these get filtered through in stream_tokens
298
- rule /\*#{symbol}\*/, Name::Variable::Global
298
+ rule %r/\*#{symbol}\*/, Name::Variable::Global
299
299
  rule symbol do |m|
300
300
  sym = m[0]
301
301
 
@@ -318,8 +318,8 @@ module Rouge
318
318
  end
319
319
  end
320
320
 
321
- rule /\(/, Punctuation, :root
322
- rule /\)/, Punctuation do
321
+ rule %r/\(/, Punctuation, :root
322
+ rule %r/\)/, Punctuation do
323
323
  if stack.size == 1
324
324
  token Error
325
325
  else
@@ -330,16 +330,16 @@ module Rouge
330
330
  end
331
331
 
332
332
  state :multiline_comment do
333
- rule /#\|/, Comment::Multiline, :multiline_comment
334
- rule /\|#/, Comment::Multiline, :pop!
335
- rule /[^\|#]+/, Comment::Multiline
336
- rule /[\|#]/, Comment::Multiline
333
+ rule %r/#\|/, Comment::Multiline, :multiline_comment
334
+ rule %r/\|#/, Comment::Multiline, :pop!
335
+ rule %r/[^\|#]+/, Comment::Multiline
336
+ rule %r/[\|#]/, Comment::Multiline
337
337
  end
338
338
 
339
339
  state :commented_form do
340
- rule /\(/, Comment, :commented_form
341
- rule /\)/, Comment, :pop!
342
- rule /[^()]+/, Comment
340
+ rule %r/\(/, Comment, :commented_form
341
+ rule %r/\)/, Comment, :pop!
342
+ rule %r/[^()]+/, Comment
343
343
  end
344
344
  end
345
345
  end