Skip to content

Commit 36f96a7

Browse files
committed
update api to 1.0
1 parent afb822f commit 36f96a7

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

lib/coderay/scanners/bash.rb

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ def initialize(*args)
5959
@shell = false
6060
end
6161

62-
def scan_tokens tokens, options
62+
def scan_tokens encoder, options
6363

6464
until eos?
6565
kind = match = nil
6666

6767
if match = scan(/\n/)
68-
tokens << [match, :end_line]
68+
encoder.text_token(match, :end_line)
6969
next
7070
end
7171

@@ -85,17 +85,17 @@ def scan_tokens tokens, options
8585
elsif match = scan(/"/)
8686
@state = :quote
8787
@quote = match
88-
tokens.begin_group :string
89-
tokens << [match, :delimiter]
88+
encoder.begin_group :string
89+
encoder.text_token(match, :delimiter)
9090
next
9191
elsif match = scan(/`/)
9292
if @shell
93-
tokens.end_group :shell
93+
encoder.end_group :shell
9494
else
95-
tokens.begin_group :shell
95+
encoder.begin_group :shell
9696
end
9797
@shell = (not @shell)
98-
tokens << [match, :delimiter]
98+
encoder.text_token(match, :delimiter)
9999
next
100100
elsif match = scan(/'[^']*'/)
101101
kind = :string
@@ -127,8 +127,8 @@ def scan_tokens tokens, options
127127
if str.to_s.strip.empty?
128128
kind = IDENT_KIND[pre]
129129
kind = :instance_variable if kind == :ident
130-
tokens << [pre, kind]
131-
tokens << [op, :operator]
130+
encoder.text_token(pre, kind)
131+
encoder.text_token(op, :operator)
132132
next
133133
end
134134
elsif match = scan(/[A-Za-z_]+\[[A-Za-z_\d]+\]/)
@@ -141,18 +141,18 @@ def scan_tokens tokens, options
141141
kind = :instance_variable if kind == :ident
142142
elsif match = scan(/read \S+/)
143143
match =~ /read(\s+)(\S+)/
144-
tokens << ['read', :method]
145-
tokens << [$1, :space]
146-
tokens << [$2, :instance_variable]
144+
encoder.text_token('read', :method)
145+
encoder.text_token($1, :space)
146+
encoder.text_token($2, :instance_variable)
147147
next
148148
elsif match = scan(/[\!\:\[\]\{\}]/)
149149
kind = :reserved
150150
elsif match = scan(/ [A-Za-z_][A-Za-z_\d]*;? /x)
151151
match =~ /([^;]+);?/
152152
kind = IDENT_KIND[$1]
153153
if match[/([^;]+);$/]
154-
tokens << [$1, kind]
155-
tokens << [';', :delimiter]
154+
encoder.text_token($1, kind)
155+
encoder.text_token(';', :delimiter)
156156
next
157157
end
158158
elsif match = scan(/(?: = | - | \+ | \{ | \} | \( | \) | && | \|\| | ;; | ! )/ox)
@@ -169,8 +169,8 @@ def scan_tokens tokens, options
169169
if (match = scan(/\\.?/))
170170
kind = :content
171171
elsif match = scan(/#{@quote}/)
172-
tokens << [match, :delimiter]
173-
tokens.end_group :string
172+
encoder.text_token(match, :delimiter)
173+
encoder.end_group :string
174174
@quote = nil
175175
@state = :initial
176176
next
@@ -193,10 +193,10 @@ def scan_tokens tokens, options
193193
end
194194

195195
match ||= matched
196-
tokens << [match, kind]
196+
encoder.text_token(match, kind)
197197
end
198198

199-
tokens
199+
encoder
200200
end
201201

202202

0 commit comments

Comments
 (0)