Skip to content

Commit 614bcff

Browse files
committedNov 21, 2013
Add Lexer#pushback() instead of manually setting scanner pos
1 parent 9d970cb commit 614bcff

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed
 

Diff for: ‎lib/opal/parser/lexer.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ def check(regexp)
8787
@scanner.check regexp
8888
end
8989

90+
def pushback(n)
91+
@scanner.pos -= 1
92+
end
93+
9094
def matched
9195
@scanner.matched
9296
end
@@ -165,7 +169,7 @@ def next_string_token
165169
if scan Regexp.new(Regexp.escape(str_parse[:end]))
166170
if words && !str_parse[:done_last_space]#&& space
167171
str_parse[:done_last_space] = true
168-
scanner.pos -= 1
172+
pushback(1)
169173
return :tSPACE, ' '
170174
end
171175
self.strterm = nil
@@ -332,7 +336,7 @@ def add_string_content(str_buffer, str_parse)
332336
c = scanner.matched
333337

334338
elsif words && scan(/\s/)
335-
scanner.pos -= 1
339+
pushback(1)
336340
break
337341

338342
elsif expand && check(/#(?=[\$\@\{])/)

0 commit comments

Comments
 (0)
Please sign in to comment.