Skip to content

Commit 004d0c8

Browse files
committed
whitespace
1 parent 0013b64 commit 004d0c8

File tree

1 file changed

+41
-41
lines changed
  • lib/coderay/scanners

1 file changed

+41
-41
lines changed

lib/coderay/scanners/go.rb

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
module CodeRay
22
module Scanners
3-
3+
44
# Scanner for Go, copy from c
55
class Go < Scanner
6-
6+
77
register_for :go
88
file_extension 'go'
9-
9+
1010
# http://golang.org/ref/spec#Keywords
1111
KEYWORDS = [
1212
'break', 'default', 'func', 'interface', 'select',
@@ -15,7 +15,7 @@ class Go < Scanner
1515
'const', 'fallthrough', 'if', 'range', 'type',
1616
'continue', 'for', 'import', 'return', 'var',
1717
] # :nodoc:
18-
18+
1919
# http://golang.org/ref/spec#Types
2020
PREDEFINED_TYPES = [
2121
'bool',
@@ -26,59 +26,59 @@ class Go < Scanner
2626
'byte', 'rune',
2727
'uint', 'int', 'uintptr',
2828
] # :nodoc:
29-
29+
3030
PREDEFINED_CONSTANTS = [
3131
'nil', 'iota',
3232
'true', 'false',
3333
] # :nodoc:
34-
34+
3535
DIRECTIVES = [
3636
'go_no_directive', # Seems no directive concept in Go?
3737
] # :nodoc:
38-
38+
3939
IDENT_KIND = WordList.new(:ident).
4040
add(KEYWORDS, :keyword).
4141
add(PREDEFINED_TYPES, :predefined_type).
4242
add(DIRECTIVES, :directive).
4343
add(PREDEFINED_CONSTANTS, :predefined_constant) # :nodoc:
44-
44+
4545
ESCAPE = / [rbfntv\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x # :nodoc:
4646
UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x # :nodoc:
47-
48-
protected
49-
47+
48+
protected
49+
5050
def scan_tokens encoder, options
51-
51+
5252
state = :initial
5353
label_expected = true
5454
case_expected = false
5555
label_expected_before_preproc_line = nil
5656
in_preproc_line = false
57-
57+
5858
until eos?
59-
59+
6060
case state
61-
61+
6262
when :initial
63-
63+
6464
if match = scan(/ \s+ | \\\n /x)
6565
if in_preproc_line && match != "\\\n" && match.index(?\n)
6666
in_preproc_line = false
6767
label_expected = label_expected_before_preproc_line
6868
end
6969
encoder.text_token match, :space
70-
70+
7171
elsif match = scan(%r! // [^\n\\]* (?: \\. [^\n\\]* )* | /\* (?: .*? \*/ | .* ) !mx)
7272
encoder.text_token match, :comment
73-
73+
7474
elsif match = scan(/ [-+*=<>?:;,!&^|()\[\]{}~%]+ | \/=? | \.(?!\d) /x)
7575
label_expected = match =~ /[;\{\}]/
7676
if case_expected
7777
label_expected = true if match == ':'
7878
case_expected = false
7979
end
8080
encoder.text_token match, :operator
81-
81+
8282
elsif match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x)
8383
kind = IDENT_KIND[match]
8484
if kind == :ident && label_expected && !in_preproc_line && scan(/:(?!:)/)
@@ -94,7 +94,7 @@ def scan_tokens encoder, options
9494
end
9595
end
9696
encoder.text_token match, kind
97-
97+
9898
elsif match = scan(/L?"/)
9999
encoder.begin_group :string
100100
if match[0] == ?L
@@ -107,41 +107,41 @@ def scan_tokens encoder, options
107107
elsif match = scan(/ \# \s* if \s* 0 /x)
108108
match << scan_until(/ ^\# (?:elif|else|endif) .*? $ | \z /xm) unless eos?
109109
encoder.text_token match, :comment
110-
110+
111111
elsif match = scan(/#[ \t]*(\w*)/)
112112
encoder.text_token match, :preprocessor
113113
in_preproc_line = true
114114
label_expected_before_preproc_line = label_expected
115115
state = :include_expected if self[1] == 'include'
116-
116+
117117
elsif match = scan(/ L?' (?: [^\'\n\\] | \\ #{ESCAPE} )? '? /ox)
118118
label_expected = false
119119
encoder.text_token match, :char
120-
120+
121121
elsif match = scan(/\$/)
122122
encoder.text_token match, :ident
123-
123+
124124
elsif match = scan(/0[xX][0-9A-Fa-f]+/)
125125
label_expected = false
126126
encoder.text_token match, :hex
127-
127+
128128
elsif match = scan(/(?:0[0-7]+)(?![89.eEfF])/)
129129
label_expected = false
130130
encoder.text_token match, :octal
131-
131+
132132
elsif match = scan(/(?:\d+)(?![.eEfF])L?L?/)
133133
label_expected = false
134134
encoder.text_token match, :integer
135-
135+
136136
elsif match = scan(/\d[fF]?|\d*\.\d+(?:[eE][+-]?\d+)?[fF]?|\d+[eE][+-]?\d+[fF]?/)
137137
label_expected = false
138138
encoder.text_token match, :float
139-
139+
140140
else
141141
encoder.text_token getch, :error
142-
142+
143143
end
144-
144+
145145
when :string
146146
if match = scan(/[^\\\n"]+/)
147147
encoder.text_token match, :content
@@ -160,36 +160,36 @@ def scan_tokens encoder, options
160160
else
161161
raise_inspect "else case \" reached; %p not handled." % peek(1), encoder
162162
end
163-
163+
164164
when :include_expected
165165
if match = scan(/<[^>\n]+>?|"[^"\n\\]*(?:\\.[^"\n\\]*)*"?/)
166166
encoder.text_token match, :include
167167
state = :initial
168-
168+
169169
elsif match = scan(/\s+/)
170170
encoder.text_token match, :space
171171
state = :initial if match.index ?\n
172-
172+
173173
else
174174
state = :initial
175-
175+
176176
end
177-
177+
178178
else
179179
raise_inspect 'Unknown state', encoder
180-
180+
181181
end
182-
182+
183183
end
184-
184+
185185
if state == :string
186186
encoder.end_group :string
187187
end
188-
188+
189189
encoder
190190
end
191-
191+
192192
end
193-
193+
194194
end
195195
end

0 commit comments

Comments
 (0)