8000 lint: character class has a duplicated range · rubychan/coderay@9a085f2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9a085f2

Browse files
committed
lint: character class has a duplicated range
1 parent f688a6d commit 9a085f2

File tree

1 file changed

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

1 file changed

+26
-26
lines changed

lib/coderay/scanners/io.rb

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
module CodeRay module Scanners
2-
2+
33
#A simple scanner for a simple language: Io
4-
4+
55
class Io < Scanner
66

77
register_for :io
8-
8+
99
RESERVED_WORDS = [ 'clone','init', 'method', 'list', 'vector', 'block', 'if','ifTrue','ifFalse','ifTrueIfFalse','then', 'for','loop',
1010
'reverseForeach','foreach','map','continue','break','while','do','return',
1111
'self','sender','target','proto','parent','protos']
1212

1313
PREDEFINED_TYPES = []
1414

15-
PREDEFINED_CONSTANTS = ['Object', 'Lobby',
15+
PREDEFINED_CONSTANTS = ['Object', 'Lobby',
1616
'TRUE','true','FALSE','false','NULL','null','Null','Nil','nil','YES','NO']
1717

1818
IDENT_KIND = WordList.new(:ident).
1919
add(RESERVED_WORDS, :reserved).
2020
add(PREDEFINED_TYPES, :pre_type).
2121
add(PREDEFINED_CONSTANTS, :pre_constant)
2222

23-
ESCAPE = / [rbfnrtv\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x
23+
ESCAPE = / [rbfntv\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x
2424
UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x
2525

2626
def scan_tokens tokens, options
@@ -33,24 +33,24 @@ def scan_tokens tokens, options
3333
match = nil
3434

3535
if state == :initial
36-
36+
3737
if scan(/ \s+ | \\\n /x)
3838
kind = :space
39-
39+
4040
elsif scan(%r! // [^\n\\]* (?: \\. [^\n\\]* )* | /\* (?: .*? \*/ | .* ) !mx)
4141
kind = :comment
4242

43-
43+
4444
elsif scan(/ [-+*\/\$\@=<>?:;,!&^|()\[\]{}~%]+ | \.(?!\d) /x)
4545
kind = :operator
46-
46+
4747
elsif match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x)
4848
kind = IDENT_KIND[match]
4949
if kind == :ident and check(/:(?!:)/)
5050
match << scan(/:/)
5151
kind = :label
5252
end
53-
53+
5454
elsif match = scan(/L?"/)
5555
tokens << [:open, :string]
5656
if match[0] == ?L
@@ -59,30 +59,30 @@ def scan_tokens tokens, options
5959
end
6060
state = :string
6161
kind = :delimiter
62-
62+
6363
elsif scan(/#\s*(\w*)/)
6464
kind = :preprocessor # FIXME multiline preprocs
6565
state = :include_expected if self[1] == 'include'
66-
66+
6767
elsif scan(/ L?' (?: [^\'\n\\] | \\ #{ESCAPE} )? '? /ox)
6868
kind = :char
69-
69+
7070
elsif scan(/0[xX][0-9A-Fa-f]+/)
7171
kind = :hex
72-
72+
7373
elsif scan(/(?:0[0-7]+)(?![89.eEfF])/)
7474
kind = :oct
75-
75+
7676
elsif scan(/(?:\d+)(?![.eEfF])/)
7777
kind = :integer
78-
78+
7979
elsif scan(/\d[fF]?|\d*\.\d+(?:[eE][+-]?\d+)?[fF]?|\d+[eE][+-]?\d+[fF]?/)
8080
kind = :float
8181

8282
else
8383
getch
8484
end
85-
85+
8686
elsif state == :string
8787
if scan(/[^\\"]+/)
8888
kind = :content
@@ -99,33 +99,33 @@ def scan_tokens tokens, options
9999
else
100100
raise "else case \" reached; %p not handled." % peek(1), tokens
101101
end
102-
102+
103103
elsif state == :include_expected
104104
if scan(/<[^>\n]+>?|"[^"\n\\]*(?:\\.[^"\n\\]*)*"?/)
105105
kind = :include
106106
state = :initial
107-
107+
108108
elsif match = scan(/\s+/)
109109
kind = :space
110110
state = :initial if match.index ?\n
111-
111+
112112
else
113113
getch
114-
114+
115115
end
116-
116+
117117
else
118118
raise 'else-case reached', tokens
119-
119+
120120
end
121-
121+
122122
match ||= matched
123123
raise [match, kind], tokens if kind == :error
124124

125125
tokens << [match, kind]
126-
126+
127127
end
128-
128+
129129
tokens
130130
end
131131

0 commit comments

Comments
 (0)
0