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
@@ -57,47 +57,47 @@ module Rouge
57
57
 
58
58
  state :root do
59
59
  # comments
60
- rule /;.*$/, 'Comment.Single'
61
- rule /\s+/m, 'Text'
62
- rule /-?\d+\.\d+/, 'Literal.Number.Float'
63
- rule /-?\d+/, 'Literal.Number.Integer'
60
+ rule /;.*$/, Comment::Single
61
+ rule /\s+/m, Text
62
+ rule /-?\d+\.\d+/, Num::Float
63
+ rule /-?\d+/, Num::Integer
64
64
 
65
65
  # Racket infinitites
66
- rule /[+-]inf[.][f0]/, 'Literal.Number'
66
+ rule /[+-]inf[.][f0]/, Num
67
67
 
68
- rule /#b[01]+/, 'Literal.Number.Binary'
69
- rule /#o[0-7]+/, 'Literal.Number.Oct'
70
- rule /#d[0-9]+/, 'Literal.Number.Integer'
71
- rule /#x[0-9a-f]+/i, 'Literal.Number.Hex'
72
- rule /#[ei][\d.]+/, 'Literal.Number.Other'
68
+ rule /#b[01]+/, Num::Bin
69
+ rule /#o[0-7]+/, Num::Oct
70
+ rule /#d[0-9]+/, Num::Integer
71
+ rule /#x[0-9a-f]+/i, Num::Hex
72
+ rule /#[ei][\d.]+/, Num::Other
73
73
 
74
- rule /"(\\\\|\\"|[^"])*"/, 'Literal.String'
75
- rule /'#{id}/i, 'Literal.String.Symbol'
74
+ rule /"(\\\\|\\"|[^"])*"/, Str
75
+ rule /'#{id}/i, Str::Symbol
76
76
  rule /#\\([()\/'"._!\$%& ?=+-]{1}|[a-z0-9]+)/i,
77
- 'Literal.String.Char'
78
- rule /#t|#f/, 'Name.Constant'
79
- rule /(?:'|#|`|,@|,|\.)/, 'Operator'
77
+ Str::Char
78
+ rule /#t|#f/, Name::Constant
79
+ rule /(?:'|#|`|,@|,|\.)/, Operator
80
80
 
81
81
  rule /(['#])(\s*)(\()/m do
82
- group 'Literal.String.Symbol'
83
- group 'Text'
84
- group 'Punctuation'
82
+ group Str::Symbol
83
+ group Text
84
+ group Punctuation
85
85
  end
86
86
 
87
- rule /\(/, 'Punctuation', :command
88
- rule /\)/, 'Punctuation'
87
+ rule /\(/, Punctuation, :command
88
+ rule /\)/, Punctuation
89
89
 
90
- rule id, 'Name.Variable'
90
+ rule id, Name::Variable
91
91
  end
92
92
 
93
93
  state :command do
94
- rule id, 'Name.Function' do |m|
94
+ rule id, Name::Function do |m|
95
95
  if self.class.keywords.include? m[0]
96
- token 'Keyword'
96
+ token Keyword
97
97
  elsif self.class.builtins.include? m[0]
98
- token 'Name.Builtin'
98
+ token Name::Builtin
99
99
  else
100
- token 'Name.Function'
100
+ token Name::Function
101
101
  end
102
102
 
103
103
  pop!
@@ -9,10 +9,10 @@ module Rouge
9
9
  mimetypes 'text/x-scss'
10
10
 
11
11
  state :root do
12
- rule /\s+/, 'Text'
13
- rule %r(//.*?\n), 'Comment.Single'
14
- rule %r(/[*].*?[*]/)m, 'Comment.Multiline'
15
- rule /@import\b/, 'Keyword', :value
12
+ rule /\s+/, Text
13
+ rule %r(//.*?\n), Comment::Single
14
+ rule %r(/[*].*?[*]/)m, Comment::Multiline
15
+ rule /@import\b/, Keyword, :value
16
16
 
17
17
  mixin :content_common
18
18
 
@@ -23,11 +23,11 @@ module Rouge
23
23
  end
24
24
 
25
25
  state :end_section do
26
- rule /\n/, 'Text'
27
- rule(/[;{}]/) { token 'Punctuation'; reset_stack }
26
+ rule /\n/, Text
27
+ rule(/[;{}]/) { token Punctuation; reset_stack }
28
28
  end
29
29
 
30
- instance_eval(&SASS_COMMON)
30
+ include SassCommon
31
31
  end
32
32
  end
33
33
  end
@@ -13,33 +13,33 @@ module Rouge
13
13
 
14
14
  class Regex < RegexLexer
15
15
  state :root do
16
- rule /\\./, 'Literal.String.Escape'
17
- rule /\[/, 'Punctuation', :brackets
18
- rule /[$^.*]/, 'Operator'
19
- rule /[()]/, 'Punctuation'
20
- rule /./, 'Literal.String.Regex'
16
+ rule /\\./, Str::Escape
17
+ rule /\[/, Punctuation, :brackets
18
+ rule /[$^.*]/, Operator
19
+ rule /[()]/, Punctuation
20
+ rule /./, Str::Regex
21
21
  end
22
22
 
23
23
  state :brackets do
24
24
  rule /\^?/ do
25
- token 'Punctuation'
26
- pop!; push :brackets_int
25
+ token Punctuation
26
+ goto :brackets_int
27
27
  end
28
28
  end
29
29
 
30
30
  state :brackets_int do
31
31
  # ranges
32
- rule /.-./, 'Name.Variable'
33
- rule /\]/, 'Punctuation', :pop!
34
- rule /./, 'Literal.String.Regex'
32
+ rule /.-./, Name::Variable
33
+ rule /\]/, Punctuation, :pop!
34
+ rule /./, Str::Regex
35
35
  end
36
36
  end
37
37
 
38
38
  class Replacement < RegexLexer
39
39
  state :root do
40
- rule /\\./m, 'Literal.String.Escape'
41
- rule /&/, 'Operator'
42
- rule /[^\\&]+/m, 'Text'
40
+ rule /\\./m, Str::Escape
41
+ rule /&/, Operator
42
+ rule /[^\\&]+/m, Text
43
43
  end
44
44
  end
45
45
 
@@ -54,10 +54,10 @@ module Rouge
54
54
  start { regex.reset!; replacement.reset! }
55
55
 
56
56
  state :whitespace do
57
- rule /\s+/m, 'Text'
58
- rule(/#.*?\n/) { token 'Comment'; reset_stack }
59
- rule(/\n/) { token 'Text'; reset_stack }
60
- rule(/;/) { token 'Punctuation'; reset_stack }
57
+ rule /\s+/m, Text
58
+ rule(/#.*?\n/) { token Comment; reset_stack }
59
+ rule(/\n/) { token Text; reset_stack }
60
+ rule(/;/) { token Punctuation; reset_stack }
61
61
  end
62
62
 
63
63
  state :root do
@@ -71,53 +71,53 @@ module Rouge
71
71
 
72
72
  # subst and transliteration
73
73
  rule /(s)(.)(#{edot}*?)(\2)(#{edot}*?)(\2)/m do |m|
74
- token 'Keyword', m[1]
75
- token 'Punctuation', m[2]
74
+ token Keyword, m[1]
75
+ token Punctuation, m[2]
76
76
  delegate regex, m[3]
77
- token 'Punctuation', m[4]
77
+ token Punctuation, m[4]
78
78
  delegate replacement, m[5]
79
- token 'Punctuation', m[6]
79
+ token Punctuation, m[6]
80
80
 
81
81
 
82
- pop!; push :flags
82
+ goto :flags
83
83
  end
84
84
 
85
85
  rule /(y)(.)(#{edot}*?)(\2)(#{edot}*?)(\2)/m do |m|
86
- token 'Keyword', m[1]
87
- token 'Punctuation', m[2]
86
+ token Keyword, m[1]
87
+ token Punctuation, m[2]
88
88
  delegate replacement, m[3]
89
- token 'Punctuation', m[4]
89
+ token Punctuation, m[4]
90
90
  delegate replacement, m[5]
91
- token 'Punctuation', m[6]
91
+ token Punctuation, m[6]
92
92
 
93
93
  pop!
94
94
  end
95
95
 
96
96
  # commands that take a text segment as an argument
97
97
  rule /([aic])(\s*)/ do
98
- group 'Keyword'; group 'Text'; pop!; push :text
98
+ group Keyword; group Text; goto :text
99
99
  end
100
100
 
101
- rule /[pd]/, 'Keyword'
101
+ rule /[pd]/, Keyword
102
102
 
103
103
  # commands that take a number argument
104
104
  rule /([qQl])(\s+)(\d+)/i do
105
- group 'Keyword'; group 'Text'; group 'Literal.Number'
105
+ group Keyword; group Text; group Num
106
106
  pop!
107
107
  end
108
108
 
109
109
  # no-argument commands
110
- rule /[={}dDgGhHlnpPqx]/, 'Keyword', :pop!
110
+ rule /[={}dDgGhHlnpPqx]/, Keyword, :pop!
111
111
 
112
112
  # commands that take a filename argument
113
113
  rule /([rRwW])(\s+)(\S+)/ do
114
- group 'Keyword'; group 'Text'; group 'Name'
114
+ group Keyword; group Text; group Name
115
115
  pop!
116
116
  end
117
117
 
118
118
  # commands that take a label argument
119
119
  rule /([:btT])(\s+)(\S+)/ do
120
- group 'Keyword'; group 'Text'; group 'Name.Label'
120
+ group Keyword; group Text; group Name::Label
121
121
  pop!
122
122
  end
123
123
  end
@@ -126,7 +126,7 @@ module Rouge
126
126
  mixin :whitespace
127
127
 
128
128
  ### address ranges ###
129
- addr_tok = 'Keyword.Namespace'
129
+ addr_tok = Keyword::Namespace
130
130
  rule /\d+/, addr_tok
131
131
  rule /[$,~+!]/, addr_tok
132
132
 
@@ -145,19 +145,19 @@ module Rouge
145
145
  end
146
146
 
147
147
  state :text do
148
- rule /[^\\\n]+/, 'Literal.String'
149
- rule /\\\n/, 'Literal.String.Escape'
150
- rule /\\/, 'Literal.String'
151
- rule /\n/, 'Text', :pop!
148
+ rule /[^\\\n]+/, Str
149
+ rule /\\\n/, Str::Escape
150
+ rule /\\/, Str
151
+ rule /\n/, Text, :pop!
152
152
  end
153
153
 
154
154
  state :flags do
155
- rule /[gp]+/, 'Keyword', :pop!
155
+ rule /[gp]+/, Keyword, :pop!
156
156
 
157
157
  # writing to a file with the subst command.
158
158
  # who'da thunk...?
159
159
  rule /([wW])(\s+)(\S+)/ do
160
- token 'Keyword'; token 'Text'; token 'Name'
160
+ token Keyword; token Text; token Name
161
161
  end
162
162
 
163
163
  rule(//) { pop! }
@@ -29,27 +29,27 @@ module Rouge
29
29
  ).join('|')
30
30
 
31
31
  state :basic do
32
- rule /#.*$/, 'Comment'
32
+ rule /#.*$/, Comment
33
33
 
34
- rule /\b(#{KEYWORDS})\s*\b/, 'Keyword'
35
- rule /\bcase\b/, 'Keyword', :case
34
+ rule /\b(#{KEYWORDS})\s*\b/, Keyword
35
+ rule /\bcase\b/, Keyword, :case
36
36
 
37
- rule /\b(#{BUILTINS})\s*\b(?!\.)/, 'Name.Builtin'
37
+ rule /\b(#{BUILTINS})\s*\b(?!\.)/, Name::Builtin
38
38
 
39
- rule /^\S*[\$%>#] +/, 'Generic.Prompt'
39
+ rule /^\S*[\$%>#] +/, Generic::Prompt
40
40
 
41
41
  rule /(\b\w+)(=)/ do |m|
42
- group 'Name.Variable'
43
- group 'Operator'
42
+ group Name::Variable
43
+ group Operator
44
44
  end
45
45
 
46
- rule /[\[\]{}()=]/, 'Operator'
47
- rule /&&|\|\|/, 'Operator'
48
- # rule /\|\|/, 'Operator'
46
+ rule /[\[\]{}()=]/, Operator
47
+ rule /&&|\|\|/, Operator
48
+ # rule /\|\|/, Operator
49
49
 
50
- rule /<<</, 'Operator' # here-string
50
+ rule /<<</, Operator # here-string
51
51
  rule /<<-?\s*(\'?)\\?(\w+)\1/ do |m|
52
- lsh = 'Literal.String.Heredoc'
52
+ lsh = Str::Heredoc
53
53
  token lsh
54
54
  heredocstr = Regexp.escape(m[2])
55
55
 
@@ -63,82 +63,82 @@ module Rouge
63
63
  state :double_quotes do
64
64
  # NB: "abc$" is literally the string abc$.
65
65
  # Here we prevent :interp from interpreting $" as a variable.
66
- rule /(?:\$#?)?"/, 'Literal.String.Double', :pop!
66
+ rule /(?:\$#?)?"/, Str::Double, :pop!
67
67
  mixin :interp
68
- rule /[^"`\\$]+/, 'Literal.String.Double'
68
+ rule /[^"`\\$]+/, Str::Double
69
69
  end
70
70
 
71
71
  state :single_quotes do
72
- rule /'/, 'Literal.String.Single', :pop!
73
- rule /[^']+/, 'Literal.String.Single'
72
+ rule /'/, Str::Single, :pop!
73
+ rule /[^']+/, Str::Single
74
74
  end
75
75
 
76
76
  state :data do
77
- rule /\s+/, 'Text'
78
- rule /\\./, 'Literal.String.Escape'
79
- rule /\$?"/, 'Literal.String.Double', :double_quotes
77
+ rule /\s+/, Text
78
+ rule /\\./, Str::Escape
79
+ rule /\$?"/, Str::Double, :double_quotes
80
80
 
81
81
  # single quotes are much easier than double quotes - we can
82
82
  # literally just scan until the next single quote.
83
83
  # POSIX: Enclosing characters in single-quotes ( '' )
84
84
  # shall preserve the literal value of each character within the
85
85
  # single-quotes. A single-quote cannot occur within single-quotes.
86
- rule /$?'/, 'Literal.String.Single', :single_quotes
86
+ rule /$?'/, Str::Single, :single_quotes
87
87
 
88
- rule /\*/, 'Keyword'
88
+ rule /\*/, Keyword
89
89
 
90
- rule /;/, 'Text'
91
- rule /[^=\*\s{}()$"\'`\\<]+/, 'Text'
92
- rule /\d+(?= |\Z)/, 'Literal.Number'
93
- rule /</, 'Text'
90
+ rule /;/, Text
91
+ rule /[^=\*\s{}()$"'`\\<]+/, Text
92
+ rule /\d+(?= |\Z)/, Num
93
+ rule /</, Text
94
94
  mixin :interp
95
95
  end
96
96
 
97
97
  state :curly do
98
- rule /}/, 'Keyword', :pop!
99
- rule /:-/, 'Keyword'
100
- rule /[a-zA-Z0-9_]+/, 'Name.Variable'
101
- rule /[^}:"'`$]+/, 'Punctuation'
98
+ rule /}/, Keyword, :pop!
99
+ rule /:-/, Keyword
100
+ rule /[a-zA-Z0-9_]+/, Name::Variable
101
+ rule /[^}:"`'$]+/, Punctuation
102
102
  mixin :root
103
103
  end
104
104
 
105
105
  state :paren do
106
- rule /\)/, 'Keyword', :pop!
106
+ rule /\)/, Keyword, :pop!
107
107
  mixin :root
108
108
  end
109
109
 
110
110
  state :math do
111
- rule /\)\)/, 'Keyword', :pop!
112
- rule %r([-+*/%^|&]|\*\*|\|\|), 'Operator'
113
- rule /\d+/, 'Literal.Number'
111
+ rule /\)\)/, Keyword, :pop!
112
+ rule %r([-+*/%^|&]|\*\*|\|\|), Operator
113
+ rule /\d+/, Num
114
114
  mixin :root
115
115
  end
116
116
 
117
117
  state :case do
118
- rule /\besac\b/, 'Keyword', :pop!
119
- rule /\|/, 'Punctuation'
120
- rule /\)/, 'Punctuation', :case_stanza
118
+ rule /\besac\b/, Keyword, :pop!
119
+ rule /\|/, Punctuation
120
+ rule /\)/, Punctuation, :case_stanza
121
121
  mixin :root
122
122
  end
123
123
 
124
124
  state :case_stanza do
125
- rule /;;/, 'Punctuation', :pop!
125
+ rule /;;/, Punctuation, :pop!
126
126
  mixin :root
127
127
  end
128
128
 
129
129
  state :backticks do
130
- rule /`/, 'Literal.String.Backtick', :pop!
130
+ rule /`/, Str::Backtick, :pop!
131
131
  mixin :root
132
132
  end
133
133
 
134
134
  state :interp do
135
- rule /\\$/, 'Literal.String.Escape' # line continuation
136
- rule /\\./, 'Literal.String.Escape'
137
- rule /\$\(\(/, 'Keyword', :math
138
- rule /\$\(/, 'Keyword', :paren
139
- rule /\${#?/, 'Keyword', :curly
140
- rule /`/, 'Literal.String.Backtick', :backticks
141
- rule /\$#?(\w+|.)/, 'Name.Variable'
135
+ rule /\\$/, Str::Escape # line continuation
136
+ rule /\\./, Str::Escape
137
+ rule /\$\(\(/, Keyword, :math
138
+ rule /\$\(/, Keyword, :paren
139
+ rule /\${#?/, Keyword, :curly
140
+ rule /`/, Str::Backtick, :backticks
141
+ rule /\$#?(\w+|.)/, Name::Variable
142
142
  end
143
143
 
144
144
  state :root do
@@ -12,101 +12,101 @@ module Rouge
12
12
 
13
13
  state :root do
14
14
  rule /(<)(\w+:)(.*?)(>)/ do
15
- group 'Punctuation'; group 'Keyword'; group 'Text'; group 'Punctuation'
15
+ group Punctuation; group Keyword; group Text; group Punctuation
16
16
  end
17
17
 
18
18
  # mixin :squeak_fileout
19
19
  mixin :whitespaces
20
20
  mixin :method_definition
21
21
  rule /([|])([\w\s]*)([|])/ do
22
- group 'Punctuation'; group 'Name.Variable'; group 'Punctuation'
22
+ group Punctuation; group Name::Variable; group Punctuation
23
23
  end
24
24
  mixin :objects
25
- rule /\^|:=|_/, 'Operator'
25
+ rule /\^|:=|_/, Operator
26
26
 
27
- rule /[)}\]]/, 'Punctuation', :after_object
28
- rule /[({\[!]/, 'Punctuation'
27
+ rule /[)}\]]/, Punctuation, :after_object
28
+ rule /[({\[!]/, Punctuation
29
29
  end
30
30
 
31
31
  state :method_definition do
32
32
  rule /([a-z]\w*:)(\s*)(\w+)/i do
33
- group 'Name.Function'; group 'Text'; group 'Name.Variable'
33
+ group Name::Function; group Text; group Name::Variable
34
34
  end
35
35
 
36
36
  rule /^(\s*)(\b[a-z]\w*\b)(\s*)$/i do
37
- group 'Text'; group 'Name.Function'; group 'Text'
37
+ group Text; group Name::Function; group Text
38
38
  end
39
39
 
40
40
  rule %r(^(\s*)(#{ops}+)(\s*)(\w+)(\s*)$) do
41
- group 'Text'; group 'Name.Function';
42
- group 'Text'; group 'Name.Variable'; group 'Text';
41
+ group Text; group Name::Function;
42
+ group Text; group Name::Variable; group Text;
43
43
  end
44
44
  end
45
45
 
46
46
  state :block_variables do
47
47
  mixin :whitespaces
48
48
  rule /(:)(\s*)(\w+)/ do
49
- group 'Operator'; group 'Text'; group 'Name.Variable'
49
+ group Operator; group Text; group Name::Variable
50
50
  end
51
51
 
52
- rule /[|]/, 'Punctuation', :pop!
52
+ rule /[|]/, Punctuation, :pop!
53
53
 
54
54
  rule(//) { pop! }
55
55
  end
56
56
 
57
57
  state :literals do
58
- rule /'(''|.)*?'/m, 'Literal.String', :after_object
59
- rule /[$]./, 'Literal.String.Char', :after_object
60
- rule /#[(]/, 'Literal.String.Symbol', :parenth
58
+ rule /'(''|.)*?'/m, Str, :after_object
59
+ rule /[$]./, Str::Char, :after_object
60
+ rule /#[(]/, Str::Symbol, :parenth
61
61
  rule /(\d+r)?-?\d+(\.\d+)?(e-?\d+)?/,
62
- 'Literal.Number', :after_object
62
+ Num, :after_object
63
63
  rule /#("[^"]*"|#{ops}+|[\w:]+)/,
64
- 'Literal.String.Symbol', :after_object
64
+ Str::Symbol, :after_object
65
65
  end
66
66
 
67
67
  state :parenth do
68
68
  rule /[)]/ do
69
- token 'Literal.String.Symbol'
70
- pop!; push :after_object
69
+ token Str::Symbol
70
+ goto :after_object
71
71
  end
72
72
 
73
73
  mixin :inner_parenth
74
74
  end
75
75
 
76
76
  state :inner_parenth do
77
- rule /#[(]/, 'Literal.String.Symbol', :inner_parenth
78
- rule /[)]/, 'Literal.String.Symbol', :pop!
77
+ rule /#[(]/, Str::Symbol, :inner_parenth
78
+ rule /[)]/, Str::Symbol, :pop!
79
79
  mixin :whitespaces
80
80
  mixin :literals
81
- rule /(#{ops}|[\w:])+/, 'Literal.String.Symbol'
81
+ rule /(#{ops}|[\w:])+/, Str::Symbol
82
82
  end
83
83
 
84
84
  state :whitespaces do
85
- rule /! !$/, 'Keyword' # squeak chunk delimiter
86
- rule /\s+/m, 'Text'
87
- rule /".*?"/m, 'Comment'
85
+ rule /! !$/, Keyword # squeak chunk delimiter
86
+ rule /\s+/m, Text
87
+ rule /".*?"/m, Comment
88
88
  end
89
89
 
90
90
  state :objects do
91
- rule /\[/, 'Punctuation', :block_variables
91
+ rule /\[/, Punctuation, :block_variables
92
92
  rule /(self|super|true|false|nil|thisContext)\b/,
93
- 'Name.Builtin.Pseudo', :after_object
94
- rule /[A-Z]\w*(?!:)\b/, 'Name.Class', :after_object
95
- rule /[a-z]\w*(?!:)\b/, 'Name.Variable', :after_object
93
+ Name::Builtin::Pseudo, :after_object
94
+ rule /[A-Z]\w*(?!:)\b/, Name::Class, :after_object
95
+ rule /[a-z]\w*(?!:)\b/, Name::Variable, :after_object
96
96
  mixin :literals
97
97
  end
98
98
 
99
99
  state :after_object do
100
100
  mixin :whitespaces
101
101
  rule /(ifTrue|ifFalse|whileTrue|whileFalse|timesRepeat):/,
102
- 'Name.Builtin', :pop!
103
- rule /new(?!:)\b/, 'Name.Builtin'
104
- rule /:=|_/, 'Operator', :pop!
105
- rule /[a-z]+\w*:/i, 'Name.Function', :pop!
106
- rule /[a-z]+\w*/i, 'Name.Function'
107
- rule /#{ops}+/, 'Name.Function', :pop!
108
- rule /[.]/, 'Punctuation', :pop!
109
- rule /;/, 'Punctuation'
102
+ Name::Builtin, :pop!
103
+ rule /new(?!:)\b/, Name::Builtin
104
+ rule /:=|_/, Operator, :pop!
105
+ rule /[a-z]+\w*:/i, Name::Function, :pop!
106
+ rule /[a-z]+\w*/i, Name::Function
107
+ rule /#{ops}+/, Name::Function, :pop!
108
+ rule /[.]/, Punctuation, :pop!
109
+ rule /;/, Punctuation
110
110
  rule(//) { pop! }
111
111
  end
112
112
  end