Skip to content

Commit

Permalink
Fix buggy parsing of ternary statements
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Sep 24, 2013
1 parent 9aa37c3 commit d7a39ef
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/opal/lexer.rb
Expand Up @@ -271,14 +271,12 @@ def add_string_content(str_buffer, str_parse)
reg = if words
Regexp.new("[^#{Regexp.escape str_parse[:end]}\#\0\n\ \\\\]+|.")
elsif str_parse[:balance]
#puts "using tis regexp"
Regexp.new("[^#{Regexp.escape str_parse[:end]}#{Regexp.escape str_parse[:beg]}\#\0\\\\]+|.")
else
Regexp.new("[^#{Regexp.escape str_parse[:end]}\#\0\\\\]+|.")
end

scanner.scan reg
#puts scanner.matched
c = scanner.matched
end

Expand Down Expand Up @@ -667,7 +665,7 @@ def next_token
return '::', scanner.matched

elsif scanner.scan(/\:/)
if [:expr_end, :expr_endarg].include?(@lex_state) || scanner.check(/\s/)
if end? || scanner.check(/\s/)
unless scanner.check(/\w/)
@lex_state = :expr_beg
return ':', ':'
Expand Down Expand Up @@ -809,12 +807,12 @@ def next_token
return [result, result]

elsif scanner.scan(/\?/)
if [:expr_end, :expr_endarg].include?(@lex_state)
if end?
@lex_state = :expr_beg
return '?', scanner.matched
end

unless scanner.check(/\ |\t|\r/)
unless scanner.check(/\ |\t|\r|\s/)
@lex_state = :expr_end
return :STRING, scanner.scan(/./)
end
Expand Down

0 comments on commit d7a39ef

Please sign in to comment.