Skip to content

Commit

Permalink
Add Lexer#pushback() instead of manually setting scanner pos
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Nov 21, 2013
1 parent 9d970cb commit 614bcff
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/opal/parser/lexer.rb
Expand Up @@ -87,6 +87,10 @@ def check(regexp)
@scanner.check regexp
end

def pushback(n)
@scanner.pos -= 1
end

def matched
@scanner.matched
end
Expand Down Expand Up @@ -165,7 +169,7 @@ def next_string_token
if scan Regexp.new(Regexp.escape(str_parse[:end]))
if words && !str_parse[:done_last_space]#&& space
str_parse[:done_last_space] = true
scanner.pos -= 1
pushback(1)
return :tSPACE, ' '
end
self.strterm = nil
Expand Down Expand Up @@ -332,7 +336,7 @@ def add_string_content(str_buffer, str_parse)
c = scanner.matched

elsif words && scan(/\s/)
scanner.pos -= 1
pushback(1)
break

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

0 comments on commit 614bcff

Please sign in to comment.