rouge 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/Gemfile +2 -0
  2. data/bin/rougify +1 -1
  3. data/lib/rouge/demos/{text → plaintext} +0 -0
  4. data/lib/rouge/formatters/html.rb +13 -8
  5. data/lib/rouge/formatters/terminal256.rb +15 -11
  6. data/lib/rouge/lexer.rb +3 -1
  7. data/lib/rouge/lexers/c.rb +65 -55
  8. data/lib/rouge/lexers/clojure.rb +19 -19
  9. data/lib/rouge/lexers/coffeescript.rb +42 -42
  10. data/lib/rouge/lexers/common_lisp.rb +49 -48
  11. data/lib/rouge/lexers/conf.rb +6 -6
  12. data/lib/rouge/lexers/cpp.rb +48 -48
  13. data/lib/rouge/lexers/csharp.rb +25 -25
  14. data/lib/rouge/lexers/css.rb +32 -33
  15. data/lib/rouge/lexers/diff.rb +8 -8
  16. data/lib/rouge/lexers/elixir.rb +30 -30
  17. data/lib/rouge/lexers/erb.rb +5 -5
  18. data/lib/rouge/lexers/erlang.rb +38 -38
  19. data/lib/rouge/lexers/factor.rb +56 -56
  20. data/lib/rouge/lexers/gherkin.rb +27 -27
  21. data/lib/rouge/lexers/go.rb +21 -21
  22. data/lib/rouge/lexers/groovy.rb +32 -32
  23. data/lib/rouge/lexers/haml.rb +35 -35
  24. data/lib/rouge/lexers/handlebars.rb +27 -27
  25. data/lib/rouge/lexers/haskell.rb +78 -79
  26. data/lib/rouge/lexers/html.rb +28 -28
  27. data/lib/rouge/lexers/http.rb +13 -13
  28. data/lib/rouge/lexers/ini.rb +13 -13
  29. data/lib/rouge/lexers/io.rb +19 -19
  30. data/lib/rouge/lexers/java.rb +29 -29
  31. data/lib/rouge/lexers/javascript.rb +49 -52
  32. data/lib/rouge/lexers/literate_haskell.rb +5 -5
  33. data/lib/rouge/lexers/llvm.rb +14 -14
  34. data/lib/rouge/lexers/lua.rb +33 -33
  35. data/lib/rouge/lexers/make.rb +26 -26
  36. data/lib/rouge/lexers/markdown.rb +49 -49
  37. data/lib/rouge/lexers/nginx.rb +19 -19
  38. data/lib/rouge/lexers/perl.rb +53 -54
  39. data/lib/rouge/lexers/php.rb +42 -43
  40. data/lib/rouge/lexers/{text.rb → plain_text.rb} +3 -2
  41. data/lib/rouge/lexers/prolog.rb +19 -19
  42. data/lib/rouge/lexers/puppet.rb +40 -40
  43. data/lib/rouge/lexers/python.rb +63 -63
  44. data/lib/rouge/lexers/r.rb +15 -15
  45. data/lib/rouge/lexers/racket.rb +29 -29
  46. data/lib/rouge/lexers/ruby.rb +94 -97
  47. data/lib/rouge/lexers/rust.rb +37 -37
  48. data/lib/rouge/lexers/sass.rb +15 -15
  49. data/lib/rouge/lexers/sass/common.rb +144 -136
  50. data/lib/rouge/lexers/scheme.rb +25 -25
  51. data/lib/rouge/lexers/scss.rb +7 -7
  52. data/lib/rouge/lexers/sed.rb +39 -39
  53. data/lib/rouge/lexers/shell.rb +45 -45
  54. data/lib/rouge/lexers/smalltalk.rb +36 -36
  55. data/lib/rouge/lexers/sql.rb +27 -27
  56. data/lib/rouge/lexers/tcl.rb +34 -34
  57. data/lib/rouge/lexers/tex.rb +24 -24
  58. data/lib/rouge/lexers/toml.rb +18 -18
  59. data/lib/rouge/lexers/viml.rb +19 -19
  60. data/lib/rouge/lexers/xml.rb +16 -16
  61. data/lib/rouge/lexers/yaml.rb +78 -81
  62. data/lib/rouge/plugins/redcarpet.rb +1 -1
  63. data/lib/rouge/regex_lexer.rb +31 -14
  64. data/lib/rouge/template_lexer.rb +1 -1
  65. data/lib/rouge/theme.rb +12 -10
  66. data/lib/rouge/themes/thankful_eyes.rb +43 -43
  67. data/lib/rouge/token.rb +145 -148
  68. data/lib/rouge/version.rb +1 -1
  69. metadata +4 -4
@@ -22,43 +22,43 @@ module Rouge
22
22
  end
23
23
 
24
24
  state :root do
25
- rule /\s+/m, 'Text'
26
- rule %r(//.*?\n), 'Comment.Single'
27
- rule %r(#.*?\n), 'Comment.Single'
28
- rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, 'Comment.Multiline'
29
- rule %r(/[+]), 'Comment.Multiline', :nested_comment
25
+ rule /\s+/m, Text
26
+ rule %r(//.*?\n), Comment::Single
27
+ rule %r(#.*?\n), Comment::Single
28
+ rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline
29
+ rule %r(/[+]), Comment::Multiline, :nested_comment
30
30
 
31
- rule /"(\\\\|\\"|[^"])*"/, 'Literal.String'
31
+ rule /"(\\\\|\\"|[^"])*"/, Str
32
32
 
33
- rule %r(:?:=), 'Keyword'
34
- rule /[()]/, 'Punctuation'
33
+ rule %r(:?:=), Keyword
34
+ rule /[()]/, Punctuation
35
35
 
36
- rule %r([-=;,*+><!/|^.%&\[\]{}]), 'Operator'
36
+ rule %r([-=;,*+><!/|^.%&\[\]{}]), Operator
37
37
 
38
- rule /[A-Z]\w*/, 'Name.Class'
38
+ rule /[A-Z]\w*/, Name::Class
39
39
 
40
40
  rule /[a-z_]\w*/ do |m|
41
41
  name = m[0]
42
42
 
43
43
  if self.class.constants.include? name
44
- token 'Keyword.Constant'
44
+ token Keyword::Constant
45
45
  elsif self.class.builtins.include? name
46
- token 'Name.Builtin'
46
+ token Name::Builtin
47
47
  else
48
- token 'Name'
48
+ token Name
49
49
  end
50
50
  end
51
51
 
52
- rule %r((\d+[.]?\d*|\d*[.]\d+)(e[+-]?[0-9]+)?)i, 'Literal.Number.Float'
53
- rule /\d+/, 'Literal.Number.Integer'
52
+ rule %r((\d+[.]?\d*|\d*[.]\d+)(e[+-]?[0-9]+)?)i, Num::Float
53
+ rule /\d+/, Num::Integer
54
54
 
55
- rule /@@?/, 'Keyword'
55
+ rule /@@?/, Keyword
56
56
  end
57
57
 
58
58
  state :nested_comment do
59
- rule %r([^/+]+)m, 'Comment.Multiline'
60
- rule %r(/[+]), 'Comment.Multiline', :nested_comment
61
- rule %r([+]/), 'Comment.Multiline', :pop!
59
+ rule %r([^/+]+)m, Comment::Multiline
60
+ rule %r(/[+]), Comment::Multiline, :nested_comment
61
+ rule %r([+]/), Comment::Multiline, :pop!
62
62
  end
63
63
  end
64
64
  end
@@ -29,45 +29,45 @@ module Rouge
29
29
  )mx do |m|
30
30
  # TODO: do this better, this shouldn't need a delegation
31
31
  delegate Java, m[1]
32
- token 'Name.Function', m[2]
33
- token 'Text', m[3]
34
- token 'Punctuation', m[4]
32
+ token Name::Function, m[2]
33
+ token Text, m[3]
34
+ token Punctuation, m[4]
35
35
  end
36
36
 
37
- rule /\s+/, 'Text'
38
- rule %r(//.*?$), 'Comment.Single'
39
- rule %r(/\*.*?\*/)m, 'Comment.Multiline'
40
- rule /@#{id}/, 'Name.Decorator'
41
- rule /(?:#{keywords.join('|')})\b/, 'Keyword'
42
- rule /(?:#{declarations.join('|')})\b/, 'Keyword.Declaration'
43
- rule /(?:#{types.join('|')})/, 'Keyword.Type'
44
- rule /package\b/, 'Keyword.Namespace'
45
- rule /(?:true|false|null)\b/, 'Keyword.Constant'
46
- rule /(?:class|interface)\b/, 'Keyword.Declaration', :class
47
- rule /import\b/, 'Keyword.Namespace', :import
48
- rule /"(\\\\|\\"|[^"])*"/, 'Literal.String'
49
- rule /'(?:\\.|[^\\]|\\u[0-9a-f]{4})'/, 'Literal.String.Char'
37
+ rule /\s+/, Text
38
+ rule %r(//.*?$), Comment::Single
39
+ rule %r(/\*.*?\*/)m, Comment::Multiline
40
+ rule /@#{id}/, Name::Decorator
41
+ rule /(?:#{keywords.join('|')})\b/, Keyword
42
+ rule /(?:#{declarations.join('|')})\b/, Keyword::Declaration
43
+ rule /(?:#{types.join('|')})/, Keyword::Type
44
+ rule /package\b/, Keyword::Namespace
45
+ rule /(?:true|false|null)\b/, Keyword::Constant
46
+ rule /(?:class|interface)\b/, Keyword::Declaration, :class
47
+ rule /import\b/, Keyword::Namespace, :import
48
+ rule /"(\\\\|\\"|[^"])*"/, Str
49
+ rule /'(?:\\.|[^\\]|\\u[0-9a-f]{4})'/, Str::Char
50
50
  rule /(\.)(#{id})/ do
51
- group 'Operator'
52
- group 'Name.Attribute'
51
+ group Operator
52
+ group Name::Attribute
53
53
  end
54
- rule /#{id}:/, 'Name.Label'
55
- rule /\$?#{id}/, 'Name'
56
- rule /[~^*!%&\[\](){}<>\|+=:;,.\/?-]/, 'Operator'
57
- rule /[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?/, 'Literal.Number.Float'
58
- rule /0x[0-9a-f]+/, 'Literal.Number.Hex'
59
- rule /[0-9]+L?/, 'Literal.Number.Integer'
60
- # rule /\n/, 'Text'
54
+ rule /#{id}:/, Name::Label
55
+ rule /\$?#{id}/, Name
56
+ rule /[~^*!%&\[\](){}<>\|+=:;,.\/?-]/, Operator
57
+ rule /[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?/, Num::Float
58
+ rule /0x[0-9a-f]+/, Num::Hex
59
+ rule /[0-9]+L?/, Num::Integer
60
+ # rule /\n/, Text
61
61
  end
62
62
 
63
63
  state :class do
64
- rule /\s+/m, 'Text'
65
- rule id, 'Name.Class', :pop!
64
+ rule /\s+/m, Text
65
+ rule id, Name::Class, :pop!
66
66
  end
67
67
 
68
68
  state :import do
69
- rule /\s+/m, 'Text'
70
- rule /[a-z0-9_.]+\*?/i, 'Name.Namespace', :pop!
69
+ rule /\s+/m, Text
70
+ rule /[a-z0-9_.]+\*?/i, Name::Namespace, :pop!
71
71
  end
72
72
  end
73
73
  end
@@ -16,10 +16,10 @@ module Rouge
16
16
  end
17
17
 
18
18
  state :comments_and_whitespace do
19
- rule /\s+/, 'Text'
20
- rule /<!--/, 'Comment' # really...?
21
- rule %r(//.*?\n), 'Comment.Single'
22
- rule %r(/\*.*?\*/), 'Comment.Multiline'
19
+ rule /\s+/, Text
20
+ rule /<!--/, Comment # really...?
21
+ rule %r(//.*?\n), Comment::Single
22
+ rule %r(/\*.*?\*/)m, Comment::Multiline
23
23
  end
24
24
 
25
25
  state :slash_starts_regex do
@@ -33,17 +33,17 @@ module Rouge
33
33
  )+
34
34
  / # closing slash
35
35
  (?:[gim]+\b|\B) # flags
36
- )x, 'Literal.String.Regex', :pop!
36
+ )x, Str::Regex, :pop!
37
37
 
38
38
  # if it's not matched by the above r.e., it's not
39
39
  # a valid expression, so we use :bad_regex to eat until the
40
40
  # end of the line.
41
- rule %r(/), 'Literal.String.Regex', :bad_regex
42
- rule //, 'Text', :pop!
41
+ rule %r(/), Str::Regex, :bad_regex
42
+ rule //, Text, :pop!
43
43
  end
44
44
 
45
45
  state :bad_regex do
46
- rule /[^\n]+/, 'Error', :pop!
46
+ rule /[^\n]+/, Error, :pop!
47
47
  end
48
48
 
49
49
  def self.keywords
@@ -84,79 +84,78 @@ module Rouge
84
84
  id = /[$a-zA-Z_][a-zA-Z0-9_]*/
85
85
 
86
86
  state :root do
87
- rule /\A\s*#!.*?\n/m, 'Comment.Preproc'
88
- rule %r((?<=\n)(?=\s|/|<!--)), 'Text', :slash_starts_regex
87
+ rule /\A\s*#!.*?\n/m, Comment::Preproc
88
+ rule %r((?<=\n)(?=\s|/|<!--)), Text, :slash_starts_regex
89
89
  mixin :comments_and_whitespace
90
90
  rule %r(\+\+ | -- | ~ | && | \|\| | \\(?=\n) | << | >>>? | ===
91
91
  | !== )x,
92
- 'Operator', :slash_starts_regex
93
- rule %r([-<>+*%&|\^/!=]=?), 'Operator', :slash_starts_regex
94
- rule /[(\[;,]/, 'Punctuation', :slash_starts_regex
95
- rule /[)\].]/, 'Punctuation'
92
+ Operator, :slash_starts_regex
93
+ rule %r([-<>+*%&|\^/!=]=?), Operator, :slash_starts_regex
94
+ rule /[(\[;,]/, Punctuation, :slash_starts_regex
95
+ rule /[)\].]/, Punctuation
96
96
 
97
97
  rule /[?]/ do
98
- token 'Punctuation'
98
+ token Punctuation
99
99
  push :ternary
100
100
  push :slash_starts_regex
101
101
  end
102
102
 
103
- rule /[{](?=\s*(#{id}|"[^\n]*?")\s*:)/, 'Punctuation', :object
103
+ rule /[{](?=\s*(#{id}|"[^\n]*?")\s*:)/m, Punctuation, :object
104
104
 
105
105
  rule /[{]/ do
106
- token 'Punctuation'
106
+ token Punctuation
107
107
  push :block
108
108
  push :slash_starts_regex
109
109
  end
110
110
 
111
111
  rule id do |m|
112
112
  if self.class.keywords.include? m[0]
113
- token 'Keyword'
113
+ token Keyword
114
114
  push :slash_starts_regex
115
115
  elsif self.class.declarations.include? m[0]
116
- token 'Keyword.Declaration'
116
+ token Keyword::Declaration
117
117
  push :slash_starts_regex
118
118
  elsif self.class.reserved.include? m[0]
119
- token 'Keyword.Reserved'
119
+ token Keyword::Reserved
120
120
  elsif self.class.constants.include? m[0]
121
- token 'Keyword.Constant'
121
+ token Keyword::Constant
122
122
  elsif self.class.builtins.include? m[0]
123
- token 'Name.Builtin'
123
+ token Name::Builtin
124
124
  else
125
- token 'Name.Other'
125
+ token Name::Other
126
126
  end
127
127
  end
128
128
 
129
- rule /[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?/, 'Literal.Number.Float'
130
- rule /0x[0-9a-fA-F]+/, 'Literal.Number.Hex'
131
- rule /[0-9]+/, 'Literal.Number.Integer'
132
- rule /"(\\\\|\\"|[^"])*"/, 'Literal.String.Double'
133
- rule /'(\\\\|\\'|[^'])*'/, 'Literal.String.Single'
129
+ rule /[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?/, Num::Float
130
+ rule /0x[0-9a-fA-F]+/, Num::Hex
131
+ rule /[0-9]+/, Num::Integer
132
+ rule /"(\\\\|\\"|[^"])*"/, Str::Double
133
+ rule /'(\\\\|\\'|[^'])*'/, Str::Single
134
134
  end
135
135
 
136
136
  # braced parts that aren't object literals
137
137
  state :block do
138
138
  rule /(#{id})(\s*)(:)/ do
139
- group 'Name.Label'; group 'Text'
140
- group 'Punctuation'
139
+ groups Name::Label, Text, Punctuation
141
140
  end
142
141
 
143
- rule /[}]/, 'Punctuation', :pop!
142
+ rule /[}]/, Punctuation, :pop!
144
143
  mixin :root
145
144
  end
146
145
 
147
146
  # object literals
148
147
  state :object do
149
- rule /[}]/, 'Punctuation', :pop!
148
+ rule /[}]/, Punctuation, :pop!
150
149
  rule /(#{id})(\s*)(:)/ do
151
- group 'Name.Attribute'; group 'Text'
152
- group 'Punctuation'
150
+ groups Name::Attribute, Text, Punctuation
153
151
  end
152
+ rule /:/, Punctuation
154
153
  mixin :root
155
154
  end
156
155
 
157
156
  # ternary expressions, where <id>: is not a label!
158
157
  state :ternary do
159
- rule /:/, 'Punctuation', :pop!
158
+ rule /:/, Punctuation, :pop!
160
159
  mixin :root
161
160
  end
162
161
  end
@@ -177,43 +176,41 @@ module Rouge
177
176
  state :root do
178
177
  mixin :whitespace
179
178
  # special case for empty objects
180
- rule /(\{)(\s*)(\})/ do
181
- group 'Punctuation'
182
- group 'Text.Whitespace'
183
- group 'Punctuation'
179
+ rule /(\{)(\s*)(\})/m do
180
+ groups Punctuation, Text::Whitespace, Punctuation
184
181
  end
185
- rule /true|false/, 'Keyword.Constant'
186
- rule /{/, 'Punctuation', :object_key
187
- rule /\[/, 'Punctuation', :array
188
- rule /-?(?:0|[1-9]\d*)\.\d+(?:e[+-]\d+)?/i, 'Literal.Number.Float'
189
- rule /-?(?:0|[1-9]\d*)(?:e[+-]\d+)?/i, 'Literal.Number.Integer'
182
+ rule /(?:true|false)\b/, Keyword::Constant
183
+ rule /{/, Punctuation, :object_key
184
+ rule /\[/, Punctuation, :array
185
+ rule /-?(?:0|[1-9]\d*)\.\d+(?:e[+-]\d+)?/i, Num::Float
186
+ rule /-?(?:0|[1-9]\d*)(?:e[+-]\d+)?/i, Num::Integer
190
187
  mixin :has_string
191
188
  end
192
189
 
193
190
  state :whitespace do
194
- rule /\s+/m, 'Text.Whitespace'
191
+ rule /\s+/m, Text::Whitespace
195
192
  end
196
193
 
197
194
  state :has_string do
198
- rule /"(\\.|[^"])*"/, 'Literal.String.Double'
195
+ rule /"(\\.|[^"])*"/, Str::Double
199
196
  end
200
197
 
201
198
  state :object_key do
202
199
  mixin :whitespace
203
- rule /:/, 'Punctuation', :object_val
204
- rule /}/, 'Error', :pop!
205
200
  mixin :has_string
201
+ rule /:/, Punctuation, :object_val
202
+ rule /}/, Error, :pop!
206
203
  end
207
204
 
208
205
  state :object_val do
209
- rule /,/, 'Punctuation', :pop!
210
- rule(/}/) { token 'Punctuation'; pop!; pop! }
206
+ rule /,/, Punctuation, :pop!
207
+ rule(/}/) { token Punctuation; pop!(2) }
211
208
  mixin :root
212
209
  end
213
210
 
214
211
  state :array do
215
- rule /\]/, 'Punctuation', :pop!
216
- rule /,/, 'Punctuation'
212
+ rule /\]/, Punctuation, :pop!
213
+ rule /,/, Punctuation
217
214
  mixin :root
218
215
  end
219
216
  end
@@ -16,18 +16,18 @@ module Rouge
16
16
  # TODO: support TeX versions as well.
17
17
  # TODO: enforce a blank line before and after code
18
18
  state :root do
19
- rule /\s*?\n(?=>)/, 'Text', :code
20
- rule /.*?\n/, 'Text'
21
- rule /.+\z/, 'Text'
19
+ rule /\s*?\n(?=>)/, Text, :code
20
+ rule /.*?\n/, Text
21
+ rule /.+\z/, Text
22
22
  end
23
23
 
24
24
  state :code do
25
25
  rule /(>)( .*?\n)/ do |m|
26
- token 'Name.Label', m[1]
26
+ token Name::Label, m[1]
27
27
  delegate haskell, m[2]
28
28
  end
29
29
 
30
- rule /\s*\n(?=\s*[^>])/, 'Text', :pop!
30
+ rule /\s*\n(?=\s*[^>])/, Text, :pop!
31
31
  end
32
32
  end
33
33
  end
@@ -15,21 +15,21 @@ module Rouge
15
15
  identifier = /([-a-zA-Z$._][-a-zA-Z$._0-9]*|#{string})/
16
16
 
17
17
  state :basic do
18
- rule /;.*?$/, 'Comment.Single'
19
- rule /\s+/, 'Text'
18
+ rule /;.*?$/, Comment::Single
19
+ rule /\s+/, Text
20
20
 
21
- rule /#{identifier}\s*:/, 'Literal.Name.Label'
21
+ rule /#{identifier}\s*:/, Name::Label
22
22
 
23
- rule /@(#{identifier}|\d+)/, 'Name.Variable.Global'
24
- rule /(%|!)#{identifier}/, 'Name.Variable'
25
- rule /(%|!)\d+/, 'Name.Variable.Anonymous'
23
+ rule /@(#{identifier}|\d+)/, Name::Variable::Global
24
+ rule /(%|!)#{identifier}/, Name::Variable
25
+ rule /(%|!)\d+/, Name::Variable
26
26
 
27
- rule /c?#{string}/, 'Literal.String'
27
+ rule /c?#{string}/, Str
28
28
 
29
- rule /0[xX][a-fA-F0-9]+/, 'Literal.Number'
30
- rule /-?\d+(?:[.]\d+)?(?:[eE][-+]?\d+(?:[.]\d+)?)?/, 'Literal.Number'
29
+ rule /0[xX][a-fA-F0-9]+/, Num
30
+ rule /-?\d+(?:[.]\d+)?(?:[eE][-+]?\d+(?:[.]\d+)?)?/, Num
31
31
 
32
- rule /[=<>{}\[\]()*.,!]|x/, 'Punctuation'
32
+ rule /[=<>{}\[\]()*.,!]|x/, Punctuation
33
33
  end
34
34
 
35
35
  builtin_types = %w(
@@ -37,8 +37,8 @@ module Rouge
37
37
  )
38
38
 
39
39
  state :types do
40
- rule /i[1-9]\d*/, 'Keyword.Type'
41
- rule /#{builtin_types.join('|')}/, 'Keyword.Type'
40
+ rule /i[1-9]\d*/, Keyword::Type
41
+ rule /#{builtin_types.join('|')}/, Keyword::Type
42
42
  end
43
43
 
44
44
  builtin_keywords = %w(
@@ -67,8 +67,8 @@ module Rouge
67
67
  )
68
68
 
69
69
  state :keywords do
70
- rule /#{builtin_instructions.join('|')}/, 'Keyword'
71
- rule /#{builtin_keywords.join('|')}/, 'Keyword'
70
+ rule /#{builtin_instructions.join('|')}/, Keyword
71
+ rule /#{builtin_keywords.join('|')}/, Keyword
72
72
  end
73
73
 
74
74
  state :root do
@@ -35,60 +35,60 @@ module Rouge
35
35
 
36
36
  state :root do
37
37
  # lua allows a file to start with a shebang
38
- rule %r(#!(.*?)$), 'Comment.Preproc'
39
- rule //, 'Text', :base
38
+ rule %r(#!(.*?)$), Comment::Preproc
39
+ rule //, Text, :base
40
40
  end
41
41
 
42
42
  state :base do
43
- rule %r(--\[(=*)\[.*?\]\1\])ms, 'Comment.Multiline'
44
- rule %r(--.*$), 'Comment.Single'
43
+ rule %r(--\[(=*)\[.*?\]\1\])ms, Comment::Multiline
44
+ rule %r(--.*$), Comment::Single
45
45
 
46
- rule %r((?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?'), 'Literal.Number.Float'
47
- rule %r((?i)\d+e[+-]?\d+), 'Literal.Number.Float'
48
- rule %r((?i)0x[0-9a-f]*), 'Literal.Number.Hex'
49
- rule %r(\d+), 'Literal.Number.Integer'
46
+ rule %r((?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?'), Num::Float
47
+ rule %r((?i)\d+e[+-]?\d+), Num::Float
48
+ rule %r((?i)0x[0-9a-f]*), Num::Hex
49
+ rule %r(\d+), Num::Integer
50
50
 
51
- rule %r(\n), 'Text'
52
- rule %r([^\S\n]), 'Text'
51
+ rule %r(\n), Text
52
+ rule %r([^\S\n]), Text
53
53
  # multiline strings
54
- rule %r(\[(=*)\[.*?\]\1\])ms, 'Literal.String'
54
+ rule %r(\[(=*)\[.*?\]\1\])ms, Str
55
55
 
56
- rule %r((==|~=|<=|>=|\.\.\.|\.\.|[=+\-*/%^<>#])), 'Operator'
57
- rule %r([\[\]\{\}\(\)\.,:;]), 'Punctuation'
58
- rule %r((and|or|not)\b), 'Operator.Word'
56
+ rule %r((==|~=|<=|>=|\.\.\.|\.\.|[=+\-*/%^<>#])), Operator
57
+ rule %r([\[\]\{\}\(\)\.,:;]), Punctuation
58
+ rule %r((and|or|not)\b), Operator::Word
59
59
 
60
- rule %r((break|do|else|elseif|end|for|if|in|repeat|return|then|until|while)\b), 'Keyword'
61
- rule %r((local)\b), 'Keyword.Declaration'
62
- rule %r((true|false|nil)\b), 'Keyword.Constant'
60
+ rule %r((break|do|else|elseif|end|for|if|in|repeat|return|then|until|while)\b), Keyword
61
+ rule %r((local)\b), Keyword::Declaration
62
+ rule %r((true|false|nil)\b), Keyword::Constant
63
63
 
64
- rule %r((function)\b), 'Keyword', :function_name
64
+ rule %r((function)\b), Keyword, :function_name
65
65
 
66
66
  rule %r([A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?) do |m|
67
67
  name = m[0]
68
68
  if self.builtins.include?(name)
69
- token 'Name.Builtin'
69
+ token Name::Builtin
70
70
  elsif name =~ /\./
71
71
  a, b = name.split('.', 2)
72
- token 'Name', a
73
- token 'Punctuation', '.'
74
- token 'Name', b
72
+ token Name, a
73
+ token Punctuation, '.'
74
+ token Name, b
75
75
  else
76
- token 'Name'
76
+ token Name
77
77
  end
78
78
  end
79
79
 
80
- rule %r('), 'Literal.String.Single', :escape_sqs
81
- rule %r("), 'Literal.String.Double', :escape_dqs
80
+ rule %r('), Str::Single, :escape_sqs
81
+ rule %r("), Str::Double, :escape_dqs
82
82
  end
83
83
 
84
84
  state :function_name do
85
- rule /\s+/, 'Text'
85
+ rule /\s+/, Text
86
86
  rule %r((?:([A-Za-z_][A-Za-z0-9_]*)(\.))?([A-Za-z_][A-Za-z0-9_]*)) do
87
- group 'Name.Class'; group 'Punctuation'; group 'Name.Function'
87
+ group Name::Class; group Punctuation; group Name::Function
88
88
  pop!
89
89
  end
90
90
  # inline function
91
- rule %r(\(), 'Punctuation', :pop!
91
+ rule %r(\(), Punctuation, :pop!
92
92
  end
93
93
 
94
94
  state :escape_sqs do
@@ -102,24 +102,24 @@ module Rouge
102
102
  end
103
103
 
104
104
  state :string_escape do
105
- rule %r(\\([abfnrtv\\"']|\d{1,3})), 'Literal.String.Escape'
105
+ rule %r(\\([abfnrtv\\"']|\d{1,3})), Str::Escape
106
106
  end
107
107
 
108
108
  state :sqs do
109
- rule %r('), 'Literal.String', :pop!
109
+ rule %r('), Str, :pop!
110
110
  mixin :string
111
111
  end
112
112
 
113
113
  state :dqs do
114
- rule %r("), 'Literal.String', :pop!
114
+ rule %r("), Str, :pop!
115
115
  mixin :string
116
116
  end
117
117
 
118
118
  # Lua is 8-bit clean, every character is valid in a string
119
119
  state :string do
120
- rule /./, 'Literal.String'
120
+ rule /./, Str
121
121
  end
122
122
 
123
123
  end
124
124
  end
125
- end
125
+ end