Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove duplication in lexer for string endings
  • Loading branch information
adambeynon committed Dec 1, 2013
1 parent 03fda15 commit 7deaaa6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/opal/parser/lexer.rb
Expand Up @@ -220,14 +220,12 @@ def next_string_token

if check(eos_regx)
scan(/[ \t]*#{Regexp.escape(str_parse[:end])}/)
self.strterm = nil

if str_parse[:scanner]
@scanner_stack << str_parse[:scanner]
@scanner = str_parse[:scanner]
end

@lex_state = :expr_end
return :tSTRING_END
end
end
Expand All @@ -241,11 +239,9 @@ def next_string_token
self.yylval = ' '
return :tSPACE
end
self.strterm = nil

if str_parse[:balance]
if str_parse[:nesting] == 0
@lex_state = :expr_end

if str_parse[:type] == :regexp
self.yylval = scan(/\w+/)
Expand All @@ -259,11 +255,9 @@ def next_string_token
end

elsif ['"', "'"].include? str_parse[:beg]
@lex_state = :expr_end
return :tSTRING_END

elsif str_parse[:beg] == '`'
@lex_state = :expr_end
return :tSTRING_END

elsif str_parse[:beg] == '/' || str_parse[:type] == :regexp
Expand All @@ -277,7 +271,6 @@ def next_string_token
@scanner = str_parse[:scanner]
end

@lex_state = :expr_end
return :tSTRING_END
end
end
Expand Down Expand Up @@ -571,7 +564,14 @@ def yylex
c = ''

if self.strterm
return next_string_token
token = next_string_token

if token == :tSTRING_END or token == :tREGEXP_END
self.strterm = nil
@lex_state = :expr_end
end

return token
end

while true
Expand Down

0 comments on commit 7deaaa6

Please sign in to comment.