Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opal/opal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ff76470a85ee
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2c9eb8479353
Choose a head ref
  • 9 commits
  • 3 files changed
  • 1 contributor

Commits on Nov 17, 2013

  1. Verified

    This commit was signed with the committer’s verified signature.
    makenowjust Hiroya Fujinami
    Copy the full SHA
    ef9ebac View commit details
  2. Copy the full SHA
    aa5e1aa View commit details
  3. Copy the full SHA
    a135e75 View commit details
  4. Copy the full SHA
    f773018 View commit details
  5. Copy the full SHA
    23e9c89 View commit details
  6. Copy the full SHA
    e0ddd15 View commit details
  7. Copy the full SHA
    2a7efc0 View commit details
  8. Copy the full SHA
    e248e96 View commit details
  9. Copy the full SHA
    2c9eb84 View commit details
Showing with 132 additions and 132 deletions.
  1. +18 −18 lib/opal/parser/grammar.rb
  2. +103 −103 lib/opal/parser/grammar.y
  3. +11 −11 lib/opal/parser/lexer.rb
36 changes: 18 additions & 18 deletions lib/opal/parser/grammar.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

206 changes: 103 additions & 103 deletions lib/opal/parser/grammar.y
Original file line number Diff line number Diff line change
@@ -8,13 +8,13 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
k__FILE__ tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR tNTH_REF
tBACK_REF tSTRING_CONTENT tINTEGER tFLOAT tREGEXP_END '+@'
'-@' '-@NUM' tPOW tCMP tEQ tEQQ tNEQ tGEQ tLEQ tANDOP
tOROP tMATCH tNMATCH '.' tDOT2 tDOT3 '[]' '[]=' tLSHFT tRSHFT
'::' '::@' tOP_ASGN tASSOC tLPAREN '(' ')' tLPAREN_ARG
ARRAY_BEG tRBRACK tLBRACE tLBRACE_ARG tSTAR tSTAR2 '&@' tAMPER2
tOROP tMATCH tNMATCH tDOT tDOT2 tDOT3 '[]' '[]=' tLSHFT tRSHFT
tCOLON2 tCOLON3 tOP_ASGN tASSOC tLPAREN tLPAREN2 tRPAREN tLPAREN_ARG
ARRAY_BEG tRBRACK tLBRACE tLBRACE_ARG tSTAR tSTAR2 tAMPER tAMPER2
tTILDE tPERCENT tDIVIDE '+' '-' tLT tGT tPIPE tBANG tCARET
tLCURLY tRCURLY tBACK_REF2 tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG
tWORDS_BEG tAWORDS_BEG tSTRING_DBEG tSTRING_DVAR tSTRING_END tSTRING
tSYMBOL '\\n' tEH tCOLON ',' tSPACE ';' tLABEL tLAMBDA tLAMBEG kDO_LAMBDA
tSYMBOL tNL tEH tCOLON tCOMMA tSPACE tSEMI tLABEL tLAMBDA tLAMBEG kDO_LAMBDA
tLBRACK2 tLBRACK

prechigh
@@ -165,12 +165,12 @@ rule
result = new_op_asgn val[1].intern, val[0], val[2]
}
| primary_value tLBRACK2 aref_args tRBRACK tOP_ASGN command_call
| primary_value '.' tIDENTIFIER tOP_ASGN command_call
| primary_value tDOT tIDENTIFIER tOP_ASGN command_call
{
result = s(:op_asgn2, val[0], "#{val[2]}=".intern, val[3].intern, val[4])
}
| primary_value '.' tCONSTANT tOP_ASGN command_call
| primary_value '::' tIDENTIFIER tOP_ASGN command_call
| primary_value tDOT tCONSTANT tOP_ASGN command_call
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call
| backref tOP_ASGN command_call
| lhs tEQL mrhs
{
@@ -232,8 +232,8 @@ rule
}

block_command: block_call
| block_call '.' operation2 command_args
| block_call '::' operation2 command_args
| block_call tDOT operation2 command_args
| block_call tCOLON2 operation2 command_args

cmd_brace_block: tLBRACE_ARG opt_block_var compstmt tRCURLY

@@ -242,16 +242,16 @@ rule
result = new_call nil, val[0].intern, val[1]
}
| operation command_args cmd_brace_block
| primary_value '.' operation2 command_args =tLOWEST
| primary_value tDOT operation2 command_args =tLOWEST
{
result = new_call val[0], val[2].intern, val[3]
}
| primary_value '.' operation2 command_args cmd_brace_block
| primary_value '::' operation2 command_args =tLOWEST
| primary_value tDOT operation2 command_args cmd_brace_block
| primary_value tCOLON2 operation2 command_args =tLOWEST
{
result = new_call val[0], val[2].intern, val[3]
}
| primary_value '::' operation2 command_args cmd_brace_block
| primary_value tCOLON2 operation2 command_args cmd_brace_block
| kSUPER command_args
{
result = new_super val[1]
@@ -265,7 +265,7 @@ rule
{
result = val[0]
}
| tLPAREN mlhs_entry ')'
| tLPAREN mlhs_entry tRPAREN
{
result = val[1]
}
@@ -274,7 +274,7 @@ rule
{
result = val[0]
}
| tLPAREN mlhs_entry ')'
| tLPAREN mlhs_entry tRPAREN
{
result = val[1]
}
@@ -291,12 +291,12 @@ rule
{
result = val[0] << s(:splat, val[2])
}
| mlhs_head tSTAR mlhs_node ',' mlhs_post
| mlhs_head tSTAR mlhs_node tCOMMA mlhs_post
| mlhs_head tSTAR
{
result = val[0] << s(:splat)
}
| mlhs_head tSTAR ',' mlhs_post
| mlhs_head tSTAR tCOMMA mlhs_post
| tSTAR mlhs_node
{
result = s(:array, s(:splat, val[1]))
@@ -305,28 +305,28 @@ rule
{
result = s(:array, s(:splat))
}
| tSTAR ',' mlhs_post
| tSTAR tCOMMA mlhs_post

mlhs_item: mlhs_node
{
result = val[0]
}
| tLPAREN mlhs_entry ')'
| tLPAREN mlhs_entry tRPAREN
{
result = val[1]
}

mlhs_head: mlhs_item ','
mlhs_head: mlhs_item tCOMMA
{
result = s(:array, val[0])
}
| mlhs_head mlhs_item ','
| mlhs_head mlhs_item tCOMMA
{
result = val[0] << val[1]
}

mlhs_post: mlhs_item
| mlhs_post ',' mlhs_item
| mlhs_post tCOMMA mlhs_item

mlhs_node: variable
{
@@ -338,14 +338,14 @@ rule
args.type = :arglist if args.type == :array
result = s(:attrasgn, val[0], :[]=, args)
}
| primary_value '.' tIDENTIFIER
| primary_value tDOT tIDENTIFIER
{
result = new_call val[0], val[2].intern, s(:arglist)
}
| primary_value '::' tIDENTIFIER
| primary_value '.' tCONSTANT
| primary_value '::' tCONSTANT
| '::@' tCONSTANT
| primary_value tCOLON2 tIDENTIFIER
| primary_value tDOT tCONSTANT
| primary_value tCOLON2 tCONSTANT
| tCOLON3 tCONSTANT
| backref

lhs: variable
@@ -358,39 +358,39 @@ rule
args.type = :arglist if args.type == :array
result = s(:attrasgn, val[0], :[]=, args)
}
| primary_value '.' tIDENTIFIER
| primary_value tDOT tIDENTIFIER
{
result = s(:attrasgn, val[0], "#{val[2]}=".intern, s(:arglist))
}
| primary_value '::' tIDENTIFIER
| primary_value tCOLON2 tIDENTIFIER
{
result = s(:attrasgn, val[0], "#{val[2]}=".intern, s(:arglist))
}
| primary_value '.' tCONSTANT
| primary_value tDOT tCONSTANT
{
result = s(:attrasgn, val[0], "#{val[2]}=".intern, s(:arglist))
}
| primary_value '::' tCONSTANT
| primary_value tCOLON2 tCONSTANT
{
result = s(:colon2, val[0], val[2].intern)
}
| '::@' tCONSTANT
| tCOLON3 tCONSTANT
{
result = s(:colon3, val[1].intern)
}
| backref

cname: tCONSTANT

cpath: '::@' cname
cpath: tCOLON3 cname
{
result = s(:colon3, val[1].intern)
}
| cname
{
result = val[0].intern
}
| primary_value '::' cname
| primary_value tCOLON2 cname
{
result = s(:colon2, val[0], val[2].intern)
}
@@ -419,7 +419,7 @@ rule
{
result = s(:undef, val[0])
}
| undef_list ',' fitem
| undef_list tCOMMA fitem
{
result = val[0] << val[2]
}
@@ -458,14 +458,14 @@ rule
result = s(:op_asgn1, val[0], val[2], val[4].intern, val[5])
result.line = val[0].line
}
| primary_value '.' tIDENTIFIER tOP_ASGN arg
| primary_value tDOT tIDENTIFIER tOP_ASGN arg
{
result = s(:op_asgn2, val[0], "#{val[2]}=".intern, val[3].intern, val[4])
}
| primary_value '.' tCONSTANT tOP_ASGN arg
| primary_value '::' tIDENTIFIER tOP_ASGN arg
| primary_value '::' tCONSTANT tOP_ASGN arg
| '::@' tCONSTANT tOP_ASGN arg
| primary_value tDOT tCONSTANT tOP_ASGN arg
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg
| primary_value tCOLON2 tCONSTANT tOP_ASGN arg
| tCOLON3 tCONSTANT tOP_ASGN arg
| backref tOP_ASGN arg
| arg tDOT2 arg
{
@@ -622,7 +622,7 @@ rule
{
result = val[0]
}
| args ',' assocs trailer
| args tCOMMA assocs trailer
{
val[0] << s(:hash, *val[2])
result = val[0]
@@ -632,16 +632,16 @@ rule
result = s(:array, s(:hash, *val[0]))
}

paren_args: '(' none ')'
paren_args: tLPAREN2 none tRPAREN
{
result = nil
}
| '(' call_args opt_nl ')'
| tLPAREN2 call_args opt_nl tRPAREN
{
result = val[1]
}
| '(' block_call opt_nl ')'
| '(' args ',' block_call opt_nl ')'
| tLPAREN2 block_call opt_nl tRPAREN
| tLPAREN2 args tCOMMA block_call opt_nl tRPAREN

opt_paren_args: none
| paren_args
@@ -660,7 +660,7 @@ rule
result = s(:arglist, s(:hash, *val[0]))
add_block_pass result, val[1]
}
| args ',' assocs opt_block_arg
| args tCOMMA assocs opt_block_arg
{
result = val[0]
result << s(:hash, *val[2])
@@ -671,7 +671,7 @@ rule
add_block_pass result, val[0]
}

call_args2: arg_value ',' args opt_block_arg
call_args2: arg_value tCOMMA args opt_block_arg
| block_arg

command_args: {
@@ -684,21 +684,21 @@ rule
}

open_args: call_args
| tLPAREN_ARG ')'
| tLPAREN_ARG tRPAREN
{
result = nil
}
| tLPAREN_ARG call_args2 ')'
| tLPAREN_ARG call_args2 tRPAREN
{
result = val[1]
}

block_arg: '&@' arg_value
block_arg: tAMPER arg_value
{
result = s(:block_pass, val[1])
}

opt_block_arg: ',' block_arg
opt_block_arg: tCOMMA block_arg
{
result = val[1]
}
@@ -715,21 +715,21 @@ rule
{
result = s(:array, s(:splat, val[1]))
}
| args ',' arg_value
| args tCOMMA arg_value
{
result = val[0] << val[2]
}
| args ',' tSTAR arg_value
| args tCOMMA tSTAR arg_value
{
result = val[0] << s(:splat, val[3])
}

mrhs: args ',' arg_value
mrhs: args tCOMMA arg_value
{
val[0] << val[2]
result = val[0]
}
| args ',' tSTAR arg_value
| args tCOMMA tSTAR arg_value
| tSTAR arg_value
{
result = s(:splat, val[1])
@@ -753,19 +753,19 @@ rule
result = s(:begin, val[2])
result.line = val[1]
}
| tLPAREN_ARG expr opt_nl ')'
| tLPAREN_ARG expr opt_nl tRPAREN
{
result = val[1]
}
| tLPAREN compstmt ')'
| tLPAREN compstmt tRPAREN
{
result = s(:paren, val[1] || s(:nil))
}
| primary_value '::' tCONSTANT
| primary_value tCOLON2 tCONSTANT
{
result = s(:colon2, val[0], val[2].intern)
}
| '::@' tCONSTANT
| tCOLON3 tCONSTANT
{
result = s(:colon3, val[1])
}
@@ -785,28 +785,28 @@ rule
{
result = s(:return)
}
| kYIELD '(' call_args ')'
| kYIELD tLPAREN2 call_args tRPAREN
{
result = new_yield val[2]
}
| kYIELD '(' ')'
| kYIELD tLPAREN2 tRPAREN
{
result = s(:yield)
}
| kYIELD
{
result = s(:yield)
}
| kDEFINED opt_nl '(' expr ')'
| kDEFINED opt_nl tLPAREN2 expr tRPAREN
{
result = s(:defined, val[3])
}
| kNOT '(' expr ')'
| kNOT tLPAREN2 expr tRPAREN
{
result = s(:not, val[2])
result.line = val[2].line
}
| kNOT '(' ')'
| kNOT tLPAREN2 tRPAREN
{
result = s(:not, s(:nil))
}
@@ -981,11 +981,11 @@ rule
result << new_iter(val[0], val[1])
}

f_larglist: '(' block_param ')'
f_larglist: tLPAREN2 block_param tRPAREN
{
result = val[1]
}
| '(' ')'
| tLPAREN2 tRPAREN
{
result = nil
}
@@ -1025,7 +1025,7 @@ rule
{
result = s(:block, val[0])
}
| f_block_optarg ',' f_block_opt
| f_block_optarg tCOMMA f_block_opt
{
val[0] << val[2]
result = val[0]
@@ -1055,7 +1055,7 @@ rule
result = val[0]
}

opt_block_args_tail: ',' block_args_tail
opt_block_args_tail: tCOMMA block_args_tail
{
result = val[1]
}
@@ -1064,27 +1064,27 @@ opt_block_args_tail: ',' block_args_tail
nil
}

block_param: f_arg ',' f_block_optarg ',' f_rest_arg opt_block_args_tail
block_param: f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
{
result = new_block_args val[0], val[2], val[4], val[5]
}
| f_arg ',' f_block_optarg opt_block_args_tail
| f_arg tCOMMA f_block_optarg opt_block_args_tail
{
result = new_block_args val[0], val[2], nil, val[3]
}
| f_arg ',' f_rest_arg opt_block_args_tail
| f_arg tCOMMA f_rest_arg opt_block_args_tail
{
result = new_block_args val[0], nil, val[2], val[3]
}
| f_arg ','
| f_arg tCOMMA
{
result = new_block_args val[0], nil, nil, nil
}
| f_arg opt_block_args_tail
{
result = new_block_args val[0], nil, nil, val[1]
}
| f_block_optarg ',' f_rest_arg opt_block_args_tail
| f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
{
result = new_block_args nil, val[0], val[2], val[3]
}
@@ -1118,26 +1118,26 @@ opt_block_args_tail: ',' block_args_tail
val[0] << val[1]
result = val[0]
}
| block_call '.' operation2 opt_paren_args
| block_call '::' operation2 opt_paren_args
| block_call tDOT operation2 opt_paren_args
| block_call tCOLON2 operation2 opt_paren_args

method_call: operation paren_args
{
result = new_call nil, val[0].intern, val[1]
}
| primary_value '.' operation2 opt_paren_args
| primary_value tDOT operation2 opt_paren_args
{
result = new_call val[0], val[2].intern, val[3]
}
| primary_value '.' paren_args
| primary_value tDOT paren_args
{
result = new_call val[0], :call, val[2]
}
| primary_value '::' operation2 paren_args
| primary_value tCOLON2 operation2 paren_args
{
result = new_call val[0], val[2].intern, val[3]
}
| primary_value '::' operation3
| primary_value tCOLON2 operation3
{
result = new_call val[0], val[2].intern, s(:arglist)
}
@@ -1471,7 +1471,7 @@ xstring_contents: none
result = nil
}

f_arglist: '(' f_args opt_nl ')'
f_arglist: tLPAREN2 f_args opt_nl tRPAREN
{
result = val[1]
lexer.lex_state = :expr_beg
@@ -1481,23 +1481,23 @@ xstring_contents: none
result = val[0]
}

f_args: f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg
f_args: f_arg tCOMMA f_optarg tCOMMA f_rest_arg opt_f_block_arg
{
result = new_args val[0], val[2], val[4], val[5]
}
| f_arg ',' f_optarg opt_f_block_arg
| f_arg tCOMMA f_optarg opt_f_block_arg
{
result = new_args val[0], val[2], nil, val[3]
}
| f_arg ',' f_rest_arg opt_f_block_arg
| f_arg tCOMMA f_rest_arg opt_f_block_arg
{
result = new_args val[0], nil, val[2], val[3]
}
| f_arg opt_f_block_arg
{
result = new_args val[0], nil, nil, val[1]
}
| f_optarg ',' f_rest_arg opt_f_block_arg
| f_optarg tCOMMA f_rest_arg opt_f_block_arg
{
result = new_args nil, val[0], val[2], val[3]
}
@@ -1544,7 +1544,7 @@ xstring_contents: none
{
result = val[0]
}
| tLPAREN f_margs ')'
| tLPAREN f_margs tRPAREN
{
result = val[1]
}
@@ -1553,29 +1553,29 @@ xstring_contents: none
{
result = s(:lasgn, val[0])
}
| tLPAREN f_margs ')'
| tLPAREN f_margs tRPAREN

f_marg_list: f_marg
{
result = s(:array, val[0])
}
| f_marg_list ',' f_marg
| f_marg_list tCOMMA f_marg
{
val[0] << val[2]
result = val[0]
}

f_margs: f_marg_list
| f_marg_list ',' tSTAR f_norm_arg
| f_marg_list ',' tSTAR
| f_marg_list tCOMMA tSTAR f_norm_arg
| f_marg_list tCOMMA tSTAR
| tSTAR f_norm_arg
| tSTAR

f_arg: f_arg_item
{
result = [val[0]]
}
| f_arg ',' f_arg_item
| f_arg tCOMMA f_arg_item
{
val[0] << val[2]
result = val[0]
@@ -1590,7 +1590,7 @@ xstring_contents: none
{
result = s(:block, val[0])
}
| f_optarg ',' f_opt
| f_optarg tCOMMA f_opt
{
result = val[0]
val[0] << val[2]
@@ -1609,14 +1609,14 @@ xstring_contents: none
}

blkarg_mark: tAMPER2
| '&@'
| tAMPER

f_block_arg: blkarg_mark tIDENTIFIER
{
result = "&#{val[1]}".intern
}

opt_f_block_arg: ',' f_block_arg
opt_f_block_arg: tCOMMA f_block_arg
{
result = val[1]
}
@@ -1629,7 +1629,7 @@ xstring_contents: none
{
result = val[0]
}
| '(' expr opt_nl ')'
| tLPAREN2 expr opt_nl tRPAREN
{
result = val[1]
}
@@ -1651,7 +1651,7 @@ xstring_contents: none
{
result = val[0]
}
| assocs ',' assoc
| assocs tCOMMA assoc
{
result = val[0].push *val[2]
}
@@ -1678,24 +1678,24 @@ xstring_contents: none
| tFID
| op

dot_or_colon: '.'
| '::'
dot_or_colon: tDOT
| tCOLON2

opt_terms: # none
| terms

opt_nl: # none
| '\\n'
| tNL

trailer: # none
| '\\n'
| ','
| tNL
| tCOMMA

term: ';'
| '\\n'
term: tSEMI
| tNL

terms: term
| terms ';'
| terms tSEMI

none: # none

22 changes: 11 additions & 11 deletions lib/opal/parser/lexer.rb
Original file line number Diff line number Diff line change
@@ -509,11 +509,11 @@ def yylex

cmd_start = true
@lex_state = :expr_beg
return '\\n', '\\n'
return :tNL, '\\n'

elsif scan(/\;/)
@lex_state = :expr_beg
return ';', ';'
return :tSEMI, ';'

elsif scan(/\*/)
if scan(/\*/)
@@ -669,9 +669,9 @@ def yylex

if spcarg?
#puts "warning: `&' interpreted as argument prefix"
result = '&@'
result = :tAMPER
elsif beg?
result = '&@'
result = :tAMPER
else
#puts "warn_balanced: & argument prefix"
result = :tAMPER2
@@ -781,7 +781,7 @@ def yylex
elsif @space_seen && [:expr_arg, :expr_cmdarg].include?(@lex_state)
result = :tLPAREN_ARG
else
result = '('
result = :tLPAREN2
end

@lex_state = :expr_beg
@@ -794,7 +794,7 @@ def yylex
cond_lexpop
cmdarg_lexpop
@lex_state = :expr_end
return ')', scanner.matched
return :tRPAREN, scanner.matched

elsif scan(/\[/)
result = scanner.matched
@@ -843,19 +843,19 @@ def yylex

elsif scan(/\./)
@lex_state = :expr_dot unless @lex_state == :expr_fname
return '.', scanner.matched
return :tDOT, scanner.matched

elsif scan(/\:\:/)
if [:expr_beg, :expr_mid, :expr_class].include? @lex_state
@lex_state = :expr_beg
return '::@', scanner.matched
return :tCOLON3, scanner.matched
elsif @space_seen && @lex_state == :expr_arg
@lex_state = :expr_beg
return '::@', scanner.matched
return :tCOLON3, scanner.matched
end

@lex_state = :expr_dot
return '::', scanner.matched
return :tCOLON2, scanner.matched

elsif scan(/\:/)
if end? || check(/\s/)
@@ -1050,7 +1050,7 @@ def yylex

elsif scan(/\,/)
@lex_state = :expr_beg
return ',', scanner.matched
return :tCOMMA, scanner.matched

elsif scan(/\{/)
if @start_of_lambda