rouge 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/bin/rougify +1 -1
- data/lib/rouge/demos/{text → plaintext} +0 -0
- data/lib/rouge/formatters/html.rb +13 -8
- data/lib/rouge/formatters/terminal256.rb +15 -11
- data/lib/rouge/lexer.rb +3 -1
- data/lib/rouge/lexers/c.rb +65 -55
- data/lib/rouge/lexers/clojure.rb +19 -19
- data/lib/rouge/lexers/coffeescript.rb +42 -42
- data/lib/rouge/lexers/common_lisp.rb +49 -48
- data/lib/rouge/lexers/conf.rb +6 -6
- data/lib/rouge/lexers/cpp.rb +48 -48
- data/lib/rouge/lexers/csharp.rb +25 -25
- data/lib/rouge/lexers/css.rb +32 -33
- data/lib/rouge/lexers/diff.rb +8 -8
- data/lib/rouge/lexers/elixir.rb +30 -30
- data/lib/rouge/lexers/erb.rb +5 -5
- data/lib/rouge/lexers/erlang.rb +38 -38
- data/lib/rouge/lexers/factor.rb +56 -56
- data/lib/rouge/lexers/gherkin.rb +27 -27
- data/lib/rouge/lexers/go.rb +21 -21
- data/lib/rouge/lexers/groovy.rb +32 -32
- data/lib/rouge/lexers/haml.rb +35 -35
- data/lib/rouge/lexers/handlebars.rb +27 -27
- data/lib/rouge/lexers/haskell.rb +78 -79
- data/lib/rouge/lexers/html.rb +28 -28
- data/lib/rouge/lexers/http.rb +13 -13
- data/lib/rouge/lexers/ini.rb +13 -13
- data/lib/rouge/lexers/io.rb +19 -19
- data/lib/rouge/lexers/java.rb +29 -29
- data/lib/rouge/lexers/javascript.rb +49 -52
- data/lib/rouge/lexers/literate_haskell.rb +5 -5
- data/lib/rouge/lexers/llvm.rb +14 -14
- data/lib/rouge/lexers/lua.rb +33 -33
- data/lib/rouge/lexers/make.rb +26 -26
- data/lib/rouge/lexers/markdown.rb +49 -49
- data/lib/rouge/lexers/nginx.rb +19 -19
- data/lib/rouge/lexers/perl.rb +53 -54
- data/lib/rouge/lexers/php.rb +42 -43
- data/lib/rouge/lexers/{text.rb → plain_text.rb} +3 -2
- data/lib/rouge/lexers/prolog.rb +19 -19
- data/lib/rouge/lexers/puppet.rb +40 -40
- data/lib/rouge/lexers/python.rb +63 -63
- data/lib/rouge/lexers/r.rb +15 -15
- data/lib/rouge/lexers/racket.rb +29 -29
- data/lib/rouge/lexers/ruby.rb +94 -97
- data/lib/rouge/lexers/rust.rb +37 -37
- data/lib/rouge/lexers/sass.rb +15 -15
- data/lib/rouge/lexers/sass/common.rb +144 -136
- data/lib/rouge/lexers/scheme.rb +25 -25
- data/lib/rouge/lexers/scss.rb +7 -7
- data/lib/rouge/lexers/sed.rb +39 -39
- data/lib/rouge/lexers/shell.rb +45 -45
- data/lib/rouge/lexers/smalltalk.rb +36 -36
- data/lib/rouge/lexers/sql.rb +27 -27
- data/lib/rouge/lexers/tcl.rb +34 -34
- data/lib/rouge/lexers/tex.rb +24 -24
- data/lib/rouge/lexers/toml.rb +18 -18
- data/lib/rouge/lexers/viml.rb +19 -19
- data/lib/rouge/lexers/xml.rb +16 -16
- data/lib/rouge/lexers/yaml.rb +78 -81
- data/lib/rouge/plugins/redcarpet.rb +1 -1
- data/lib/rouge/regex_lexer.rb +31 -14
- data/lib/rouge/template_lexer.rb +1 -1
- data/lib/rouge/theme.rb +12 -10
- data/lib/rouge/themes/thankful_eyes.rb +43 -43
- data/lib/rouge/token.rb +145 -148
- data/lib/rouge/version.rb +1 -1
- metadata +4 -4
data/lib/rouge/lexers/scheme.rb
CHANGED
@@ -57,47 +57,47 @@ module Rouge
|
|
57
57
|
|
58
58
|
state :root do
|
59
59
|
# comments
|
60
|
-
rule /;.*$/,
|
61
|
-
rule /\s+/m,
|
62
|
-
rule /-?\d+\.\d+/,
|
63
|
-
rule /-?\d+/,
|
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]/,
|
66
|
+
rule /[+-]inf[.][f0]/, Num
|
67
67
|
|
68
|
-
rule /#b[01]+/,
|
69
|
-
rule /#o[0-7]+/,
|
70
|
-
rule /#d[0-9]+/,
|
71
|
-
rule /#x[0-9a-f]+/i,
|
72
|
-
rule /#[ei][\d.]+/,
|
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 /"(\\\\|\\"|[^"])*"/,
|
75
|
-
rule /'#{id}/i,
|
74
|
+
rule /"(\\\\|\\"|[^"])*"/, Str
|
75
|
+
rule /'#{id}/i, Str::Symbol
|
76
76
|
rule /#\\([()\/'"._!\$%& ?=+-]{1}|[a-z0-9]+)/i,
|
77
|
-
|
78
|
-
rule /#t|#f/,
|
79
|
-
rule /(?:'|#|`|,@|,|\.)/,
|
77
|
+
Str::Char
|
78
|
+
rule /#t|#f/, Name::Constant
|
79
|
+
rule /(?:'|#|`|,@|,|\.)/, Operator
|
80
80
|
|
81
81
|
rule /(['#])(\s*)(\()/m do
|
82
|
-
group
|
83
|
-
group
|
84
|
-
group
|
82
|
+
group Str::Symbol
|
83
|
+
group Text
|
84
|
+
group Punctuation
|
85
85
|
end
|
86
86
|
|
87
|
-
rule /\(/,
|
88
|
-
rule /\)/,
|
87
|
+
rule /\(/, Punctuation, :command
|
88
|
+
rule /\)/, Punctuation
|
89
89
|
|
90
|
-
rule id,
|
90
|
+
rule id, Name::Variable
|
91
91
|
end
|
92
92
|
|
93
93
|
state :command do
|
94
|
-
rule id,
|
94
|
+
rule id, Name::Function do |m|
|
95
95
|
if self.class.keywords.include? m[0]
|
96
|
-
token
|
96
|
+
token Keyword
|
97
97
|
elsif self.class.builtins.include? m[0]
|
98
|
-
token
|
98
|
+
token Name::Builtin
|
99
99
|
else
|
100
|
-
token
|
100
|
+
token Name::Function
|
101
101
|
end
|
102
102
|
|
103
103
|
pop!
|
data/lib/rouge/lexers/scss.rb
CHANGED
@@ -9,10 +9,10 @@ module Rouge
|
|
9
9
|
mimetypes 'text/x-scss'
|
10
10
|
|
11
11
|
state :root do
|
12
|
-
rule /\s+/,
|
13
|
-
rule %r(//.*?\n),
|
14
|
-
rule %r(/[*].*?[*]/)m,
|
15
|
-
rule /@import\b/,
|
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/,
|
27
|
-
rule(/[;{}]/) { token
|
26
|
+
rule /\n/, Text
|
27
|
+
rule(/[;{}]/) { token Punctuation; reset_stack }
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
include SassCommon
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
data/lib/rouge/lexers/sed.rb
CHANGED
@@ -13,33 +13,33 @@ module Rouge
|
|
13
13
|
|
14
14
|
class Regex < RegexLexer
|
15
15
|
state :root do
|
16
|
-
rule /\\./,
|
17
|
-
rule /\[/,
|
18
|
-
rule /[$^.*]/,
|
19
|
-
rule /[()]/,
|
20
|
-
rule /./,
|
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
|
26
|
-
|
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 /.-./,
|
33
|
-
rule /\]/,
|
34
|
-
rule /./,
|
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,
|
41
|
-
rule /&/,
|
42
|
-
rule /[^\\&]+/m,
|
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,
|
58
|
-
rule(/#.*?\n/) { token
|
59
|
-
rule(/\n/) { token
|
60
|
-
rule(/;/) { token
|
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
|
75
|
-
token
|
74
|
+
token Keyword, m[1]
|
75
|
+
token Punctuation, m[2]
|
76
76
|
delegate regex, m[3]
|
77
|
-
token
|
77
|
+
token Punctuation, m[4]
|
78
78
|
delegate replacement, m[5]
|
79
|
-
token
|
79
|
+
token Punctuation, m[6]
|
80
80
|
|
81
81
|
|
82
|
-
|
82
|
+
goto :flags
|
83
83
|
end
|
84
84
|
|
85
85
|
rule /(y)(.)(#{edot}*?)(\2)(#{edot}*?)(\2)/m do |m|
|
86
|
-
token
|
87
|
-
token
|
86
|
+
token Keyword, m[1]
|
87
|
+
token Punctuation, m[2]
|
88
88
|
delegate replacement, m[3]
|
89
|
-
token
|
89
|
+
token Punctuation, m[4]
|
90
90
|
delegate replacement, m[5]
|
91
|
-
token
|
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
|
98
|
+
group Keyword; group Text; goto :text
|
99
99
|
end
|
100
100
|
|
101
|
-
rule /[pd]/,
|
101
|
+
rule /[pd]/, Keyword
|
102
102
|
|
103
103
|
# commands that take a number argument
|
104
104
|
rule /([qQl])(\s+)(\d+)/i do
|
105
|
-
group
|
105
|
+
group Keyword; group Text; group Num
|
106
106
|
pop!
|
107
107
|
end
|
108
108
|
|
109
109
|
# no-argument commands
|
110
|
-
rule /[={}dDgGhHlnpPqx]/,
|
110
|
+
rule /[={}dDgGhHlnpPqx]/, Keyword, :pop!
|
111
111
|
|
112
112
|
# commands that take a filename argument
|
113
113
|
rule /([rRwW])(\s+)(\S+)/ do
|
114
|
-
group
|
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
|
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 =
|
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]+/,
|
149
|
-
rule /\\\n/,
|
150
|
-
rule /\\/,
|
151
|
-
rule /\n/,
|
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]+/,
|
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
|
160
|
+
token Keyword; token Text; token Name
|
161
161
|
end
|
162
162
|
|
163
163
|
rule(//) { pop! }
|
data/lib/rouge/lexers/shell.rb
CHANGED
@@ -29,27 +29,27 @@ module Rouge
|
|
29
29
|
).join('|')
|
30
30
|
|
31
31
|
state :basic do
|
32
|
-
rule /#.*$/,
|
32
|
+
rule /#.*$/, Comment
|
33
33
|
|
34
|
-
rule /\b(#{KEYWORDS})\s*\b/,
|
35
|
-
rule /\bcase\b/,
|
34
|
+
rule /\b(#{KEYWORDS})\s*\b/, Keyword
|
35
|
+
rule /\bcase\b/, Keyword, :case
|
36
36
|
|
37
|
-
rule /\b(#{BUILTINS})\s*\b(?!\.)/,
|
37
|
+
rule /\b(#{BUILTINS})\s*\b(?!\.)/, Name::Builtin
|
38
38
|
|
39
|
-
rule /^\S*[\$%>#] +/,
|
39
|
+
rule /^\S*[\$%>#] +/, Generic::Prompt
|
40
40
|
|
41
41
|
rule /(\b\w+)(=)/ do |m|
|
42
|
-
group
|
43
|
-
group
|
42
|
+
group Name::Variable
|
43
|
+
group Operator
|
44
44
|
end
|
45
45
|
|
46
|
-
rule /[\[\]{}()=]/,
|
47
|
-
rule /&&|\|\|/,
|
48
|
-
# rule /\|\|/,
|
46
|
+
rule /[\[\]{}()=]/, Operator
|
47
|
+
rule /&&|\|\|/, Operator
|
48
|
+
# rule /\|\|/, Operator
|
49
49
|
|
50
|
-
rule /<<</,
|
50
|
+
rule /<<</, Operator # here-string
|
51
51
|
rule /<<-?\s*(\'?)\\?(\w+)\1/ do |m|
|
52
|
-
lsh =
|
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 /(?:\$#?)?"/,
|
66
|
+
rule /(?:\$#?)?"/, Str::Double, :pop!
|
67
67
|
mixin :interp
|
68
|
-
rule /[^"`\\$]+/,
|
68
|
+
rule /[^"`\\$]+/, Str::Double
|
69
69
|
end
|
70
70
|
|
71
71
|
state :single_quotes do
|
72
|
-
rule /'/,
|
73
|
-
rule /[^']+/,
|
72
|
+
rule /'/, Str::Single, :pop!
|
73
|
+
rule /[^']+/, Str::Single
|
74
74
|
end
|
75
75
|
|
76
76
|
state :data do
|
77
|
-
rule /\s+/,
|
78
|
-
rule /\\./,
|
79
|
-
rule /\$?"/,
|
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 /$?'/,
|
86
|
+
rule /$?'/, Str::Single, :single_quotes
|
87
87
|
|
88
|
-
rule /\*/,
|
88
|
+
rule /\*/, Keyword
|
89
89
|
|
90
|
-
rule /;/,
|
91
|
-
rule /[^=\*\s{}()$"
|
92
|
-
rule /\d+(?= |\Z)/,
|
93
|
-
rule /</,
|
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 /}/,
|
99
|
-
rule /:-/,
|
100
|
-
rule /[a-zA-Z0-9_]+/,
|
101
|
-
rule /[^}:"'
|
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 /\)/,
|
106
|
+
rule /\)/, Keyword, :pop!
|
107
107
|
mixin :root
|
108
108
|
end
|
109
109
|
|
110
110
|
state :math do
|
111
|
-
rule /\)\)/,
|
112
|
-
rule %r([-+*/%^|&]|\*\*|\|\|),
|
113
|
-
rule /\d+/,
|
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/,
|
119
|
-
rule /\|/,
|
120
|
-
rule /\)/,
|
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 /;;/,
|
125
|
+
rule /;;/, Punctuation, :pop!
|
126
126
|
mixin :root
|
127
127
|
end
|
128
128
|
|
129
129
|
state :backticks do
|
130
|
-
rule /`/,
|
130
|
+
rule /`/, Str::Backtick, :pop!
|
131
131
|
mixin :root
|
132
132
|
end
|
133
133
|
|
134
134
|
state :interp do
|
135
|
-
rule /\\$/,
|
136
|
-
rule /\\./,
|
137
|
-
rule /\$\(\(/,
|
138
|
-
rule /\$\(/,
|
139
|
-
rule /\${#?/,
|
140
|
-
rule /`/,
|
141
|
-
rule /\$#?(\w+|.)/,
|
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
|
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
|
22
|
+
group Punctuation; group Name::Variable; group Punctuation
|
23
23
|
end
|
24
24
|
mixin :objects
|
25
|
-
rule /\^|:=|_/,
|
25
|
+
rule /\^|:=|_/, Operator
|
26
26
|
|
27
|
-
rule /[)}\]]/,
|
28
|
-
rule /[({\[!]/,
|
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
|
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
|
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
|
42
|
-
group
|
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
|
49
|
+
group Operator; group Text; group Name::Variable
|
50
50
|
end
|
51
51
|
|
52
|
-
rule /[|]/,
|
52
|
+
rule /[|]/, Punctuation, :pop!
|
53
53
|
|
54
54
|
rule(//) { pop! }
|
55
55
|
end
|
56
56
|
|
57
57
|
state :literals do
|
58
|
-
rule /'(''|.)*?'/m,
|
59
|
-
rule /[$]./,
|
60
|
-
rule /#[(]/,
|
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
|
-
|
62
|
+
Num, :after_object
|
63
63
|
rule /#("[^"]*"|#{ops}+|[\w:]+)/,
|
64
|
-
|
64
|
+
Str::Symbol, :after_object
|
65
65
|
end
|
66
66
|
|
67
67
|
state :parenth do
|
68
68
|
rule /[)]/ do
|
69
|
-
token
|
70
|
-
|
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 /#[(]/,
|
78
|
-
rule /[)]/,
|
77
|
+
rule /#[(]/, Str::Symbol, :inner_parenth
|
78
|
+
rule /[)]/, Str::Symbol, :pop!
|
79
79
|
mixin :whitespaces
|
80
80
|
mixin :literals
|
81
|
-
rule /(#{ops}|[\w:])+/,
|
81
|
+
rule /(#{ops}|[\w:])+/, Str::Symbol
|
82
82
|
end
|
83
83
|
|
84
84
|
state :whitespaces do
|
85
|
-
rule /! !$/,
|
86
|
-
rule /\s+/m,
|
87
|
-
rule /".*?"/m,
|
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 /\[/,
|
91
|
+
rule /\[/, Punctuation, :block_variables
|
92
92
|
rule /(self|super|true|false|nil|thisContext)\b/,
|
93
|
-
|
94
|
-
rule /[A-Z]\w*(?!:)\b/,
|
95
|
-
rule /[a-z]\w*(?!:)\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
|
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
|
-
|
103
|
-
rule /new(?!:)\b/,
|
104
|
-
rule /:=|_/,
|
105
|
-
rule /[a-z]+\w*:/i,
|
106
|
-
rule /[a-z]+\w*/i,
|
107
|
-
rule /#{ops}+/,
|
108
|
-
rule /[.]/,
|
109
|
-
rule /;/,
|
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
|