Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added a few new ones to the list of overridable operators in 1.9

allow method called name to be a form escape if macros enabled
reorganized flow control in callsite_symbol
  • Loading branch information...
commit abf18dc791029561696093a52704cfc3f88798a3 1 parent 9aa2068
@coatl coatl authored
Showing with 24 additions and 14 deletions.
  1. +24 −14 lib/rubylexer.rb
View
38 lib/rubylexer.rb
@@ -170,6 +170,11 @@ def initialize(filename,file,linenum=1,offset_adjust=0,options={:rubyversion=>1.
@progress_thread=nil
@rubyversion=options[:rubyversion]
@encoding=options[:encoding]||:detect
+ @method_operators=if @rubyversion>=1.9
+ /#{RUBYSYMOPERATORREX}|\A![=~]?\Z/o
+ else
+ RUBYSYMOPERATORREX
+ end
@toptable=CharHandler.new(self, :illegal_char, CHARMAPPINGS)
@@ -1732,8 +1737,9 @@ def symbol_or_op(ch)
end
when RescueSMContext
tok.as=";"
- end or
+ end or
fail ": not expected in #{@parsestack.last.class}->#{@parsestack.last.starter}"
+
#end ternary context, if any
@parsestack.last.see self,:colon
@@ -1766,7 +1772,7 @@ def symbol(notbare,couldbecallsite=!notbare)
klass=(notbare ? SymbolToken : MethNameToken)
#look for operators
- opmatches=readahead(3)[RUBYSYMOPERATORREX]
+ opmatches=readahead(3)[@method_operators]
result= opmatches ? read(opmatches.size) :
case nc=nextchar
when ?" #"
@@ -1800,27 +1806,31 @@ def symbol(notbare,couldbecallsite=!notbare)
return result
end
+ #-----------------------------------
def merge_assignment_op_in_setter_callsites?
false
end
+
#-----------------------------------
def callsite_symbol(tok_to_errify)
start= input_position
#look for operators
- opmatches=readahead(3)[RUBYSYMOPERATORREX]
- return [opmatches ? read(opmatches.size) :
- case nc=nextchar
- when ?` then read(1) #`
- when ?_,?a..?z,?A..?Z,NONASCII then
+ opmatches=readahead(3)[@method_operators]
+ return [read(opmatches.size), start] if opmatches
+ case nc=nextchar
+ when ?` #`
+ return [read(1),start]
+ when ?_,?a..?z,?A..?Z,NONASCII
context=merge_assignment_op_in_setter_callsites? ? ?: : nc
- identifier_as_string(context)
- else
- set_last_token KeywordToken.new(';')
- lexerror(tok_to_errify,"unexpected char starting callsite symbol: #{nc.chr}, tok=#{tok_to_errify.inspect}")
- nil
- end, start
- ]
+ return [identifier_as_string(context), start]
+ when ?(
+ return [nil,start] if @enable_macro
+ end
+
+ set_last_token KeywordToken.new(';')
+ lexerror(tok_to_errify,"unexpected char starting callsite symbol: #{nc.chr}, tok=#{tok_to_errify.inspect}")
+ return [nil, start]
end
#-----------------------------------
Please sign in to comment.
Something went wrong with that request. Please try again.