ruby_parser
Advanced tools
+6
-0
@@ -0,1 +1,7 @@ | ||
| === 2.0.5 / 2010-09-01 | ||
| * 1 minor enhancement: | ||
| * Started merging like lexical cases to try to squeeze some optimization out | ||
| === 2.0.4 / 2009-08-18 | ||
@@ -2,0 +8,0 @@ |
+35
-57
@@ -49,2 +49,16 @@ class RubyLexer | ||
| TOKENS = { | ||
| "!" => :tBANG, | ||
| "!=" => :tNEQ, | ||
| "!~" => :tNMATCH, | ||
| "," => :tCOMMA, | ||
| ".." => :tDOT2, | ||
| "..." => :tDOT3, | ||
| "=" => :tEQL, | ||
| "==" => :tEQ, | ||
| "===" => :tEQQ, | ||
| "=>" => :tASSOC, | ||
| "=~" => :tMATCH, | ||
| } | ||
| # How the parser advances to the next token. | ||
@@ -637,3 +651,3 @@ # | ||
| loop do # START OF CASE | ||
| if src.scan(/\ |\t|\r|\f|\13/) then # white spaces, 13 = '\v | ||
| if src.scan(/[\ \t\r\f\v]/) then # \s - \n + \v | ||
| space_seen = true | ||
@@ -679,12 +693,8 @@ next | ||
| return result | ||
| elsif src.scan(/\.\.\.?|,|![=~]?/) then | ||
| self.lex_state = :expr_beg | ||
| tok = self.yacc_value = src.matched | ||
| return TOKENS[tok] | ||
| elsif src.check(/\./) then | ||
| if src.scan(/\.\.\./) then | ||
| self.lex_state = :expr_beg | ||
| self.yacc_value = "..." | ||
| return :tDOT3 | ||
| elsif src.scan(/\.\./) then | ||
| self.lex_state = :expr_beg | ||
| self.yacc_value = ".." | ||
| return :tDOT2 | ||
| elsif src.scan(/\.\d/) then | ||
| if src.scan(/\.\d/) then | ||
| rb_compile_error "no .<digit> floating literal anymore put 0 before dot" | ||
@@ -696,9 +706,6 @@ elsif src.scan(/\./) then | ||
| end | ||
| elsif src.scan(/\,/) then | ||
| self.lex_state = :expr_beg | ||
| self.yacc_value = "," | ||
| return :tCOMMA | ||
| elsif src.scan(/\(/) then | ||
| result = :tLPAREN2 | ||
| self.command_start = true | ||
| if lex_state == :expr_beg || lex_state == :expr_mid then | ||
@@ -719,35 +726,20 @@ result = :tLPAREN | ||
| elsif src.check(/\=/) then | ||
| if src.scan(/\=\=\=/) then | ||
| if src.scan(/\=\=\=|\=\=|\=~|\=>|\=(?!begin\b)/) then | ||
| self.fix_arg_lex_state | ||
| self.yacc_value = "===" | ||
| return :tEQQ | ||
| elsif src.scan(/\=\=/) then | ||
| self.fix_arg_lex_state | ||
| self.yacc_value = "==" | ||
| return :tEQ | ||
| elsif src.scan(/\=~/) then | ||
| self.fix_arg_lex_state | ||
| self.yacc_value = "=~" | ||
| return :tMATCH | ||
| elsif src.scan(/\=>/) then | ||
| self.fix_arg_lex_state | ||
| self.yacc_value = "=>" | ||
| return :tASSOC | ||
| elsif src.scan(/\=/) then | ||
| if src.was_begin_of_line and src.scan(/begin(?=\s)/) then | ||
| @comments << '=' << src.matched | ||
| tok = self.yacc_value = src.matched | ||
| return TOKENS[tok] | ||
| elsif src.was_begin_of_line and src.scan(/\=begin(?=\s)/) then | ||
| # @comments << '=' << src.matched | ||
| @comments << src.matched | ||
| unless src.scan(/.*?\n=end\s*(\n|\z)/m) then | ||
| @comments.clear | ||
| rb_compile_error("embedded document meets end of file") | ||
| end | ||
| unless src.scan(/.*?\n=end\s*(\n|\z)/m) then | ||
| @comments.clear | ||
| rb_compile_error("embedded document meets end of file") | ||
| end | ||
| @comments << src.matched | ||
| @comments << src.matched | ||
| next | ||
| else | ||
| self.fix_arg_lex_state | ||
| self.yacc_value = '=' | ||
| return :tEQL | ||
| end | ||
| next | ||
| else | ||
| raise "you shouldn't be able to get here" | ||
| end | ||
@@ -940,16 +932,2 @@ elsif src.scan(/\"(#{ESC_RE}|#(#{ESC_RE}|[^\{\#\@\$\"\\])|[^\"\\\#])*\"/o) then | ||
| end | ||
| elsif src.check(/\!/) then | ||
| if src.scan(/\!\=/) then | ||
| self.lex_state = :expr_beg | ||
| self.yacc_value = "!=" | ||
| return :tNEQ | ||
| elsif src.scan(/\!~/) then | ||
| self.lex_state = :expr_beg | ||
| self.yacc_value = "!~" | ||
| return :tNMATCH | ||
| elsif src.scan(/\!/) then | ||
| self.lex_state = :expr_beg | ||
| self.yacc_value = "!" | ||
| return :tBANG | ||
| end | ||
| elsif src.check(/\</) then | ||
@@ -956,0 +934,0 @@ if src.scan(/\<\=\>/) then |
@@ -118,3 +118,3 @@ require 'stringio' | ||
| class RubyParser < Racc::Parser | ||
| VERSION = '2.0.4' unless constants.include? "VERSION" # SIGH | ||
| VERSION = '2.0.5' unless constants.include? "VERSION" # SIGH | ||
@@ -121,0 +121,0 @@ attr_accessor :lexer, :in_def, :in_single, :file |