parser 2.4.0.0 → 2.4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,14 +8,14 @@ module Parser
8
8
  %w(
9
9
  true false nil int float str dstr
10
10
  sym dsym xstr regopt regexp array splat
11
- array pair kwsplat hash irange erange self
11
+ pair kwsplat hash irange erange self
12
12
  lvar ivar cvar gvar const defined? lvasgn
13
- ivasgn cvasgn gvasgn casgn mlhs masgn op_asgn
13
+ ivasgn cvasgn gvasgn casgn mlhs masgn
14
14
  op_asgn and_asgn ensure rescue arg_expr
15
- or_asgn and_asgn or_asgn back_ref nth_ref
15
+ or_asgn back_ref nth_ref
16
16
  match_with_lvasgn match_current_line
17
17
  module class sclass def defs undef alias args
18
- cbase arg optarg restarg blockarg block_pass args def kwarg kwoptarg
18
+ cbase arg optarg restarg blockarg block_pass kwarg kwoptarg
19
19
  kwrestarg send csend super zsuper yield block
20
20
  and not or if when case while until while_post
21
21
  until_post for break next redo return resbody
@@ -7,7 +7,7 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
7
7
  kUNTIL_MOD kRESCUE_MOD kALIAS kDEFINED klBEGIN klEND k__LINE__
8
8
  k__FILE__ tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR tNTH_REF
9
9
  tBACK_REF tSTRING_CONTENT tINTEGER tFLOAT tUPLUS
10
- tUMINUS tUMINUS_NUM tPOW tCMP tEQ tEQQ tNEQ tGEQ tLEQ tANDOP
10
+ tUMINUS tUNARY_NUM tPOW tCMP tEQ tEQQ tNEQ tGEQ tLEQ tANDOP
11
11
  tOROP tMATCH tNMATCH tDOT tDOT2 tDOT3 tAREF tASET tLSHFT tRSHFT
12
12
  tCOLON2 tCOLON3 tOP_ASGN tASSOC tLPAREN tLPAREN2 tRPAREN tLPAREN_ARG
13
13
  tLBRACK tLBRACK2 tRBRACK tLBRACE tLBRACE_ARG tSTAR tSTAR2 tAMPER tAMPER2
@@ -19,7 +19,7 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
19
19
  prechigh
20
20
  right tBANG tTILDE tUPLUS
21
21
  right tPOW
22
- right tUMINUS_NUM tUMINUS
22
+ right tUNARY_NUM tUMINUS
23
23
  left tSTAR2 tDIVIDE tPERCENT
24
24
  left tPLUS tMINUS
25
25
  left tLSHFT tRSHFT
@@ -615,14 +615,14 @@ rule
615
615
  {
616
616
  result = @builder.binary_op(val[0], val[1], val[2])
617
617
  }
618
- | tUMINUS_NUM tINTEGER tPOW arg
618
+ | tUNARY_NUM tINTEGER tPOW arg
619
619
  {
620
620
  result = @builder.unary_op(val[0],
621
621
  @builder.binary_op(
622
622
  @builder.integer(val[1]),
623
623
  val[2], val[3]))
624
624
  }
625
- | tUMINUS_NUM tFLOAT tPOW arg
625
+ | tUNARY_NUM tFLOAT tPOW arg
626
626
  {
627
627
  result = @builder.unary_op(val[0],
628
628
  @builder.binary_op(
@@ -1617,15 +1617,25 @@ xstring_contents: # nothing
1617
1617
  {
1618
1618
  result = @builder.float(val[0])
1619
1619
  }
1620
- | tUMINUS_NUM tINTEGER =tLOWEST
1620
+ | tUNARY_NUM tINTEGER =tLOWEST
1621
1621
  {
1622
- result = @builder.negate(val[0],
1623
- @builder.integer(val[1]))
1622
+ num = @builder.integer(val[1])
1623
+ if @builder.respond_to? :negate
1624
+ # AST builder interface compatibility
1625
+ result = @builder.negate(val[0], num)
1626
+ else
1627
+ result = @builder.unary_num(val[0], num)
1628
+ end
1624
1629
  }
1625
- | tUMINUS_NUM tFLOAT =tLOWEST
1630
+ | tUNARY_NUM tFLOAT =tLOWEST
1626
1631
  {
1627
- result = @builder.negate(val[0],
1628
- @builder.float(val[1]))
1632
+ num = @builder.float(val[1])
1633
+ if @builder.respond_to? :negate
1634
+ # AST builder interface compatibility
1635
+ result = @builder.negate(val[0], num)
1636
+ else
1637
+ result = @builder.unary_num(val[0], num)
1638
+ end
1629
1639
  }
1630
1640
 
1631
1641
  variable: tIDENTIFIER
@@ -7,7 +7,7 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
7
7
  kUNTIL_MOD kRESCUE_MOD kALIAS kDEFINED klBEGIN klEND k__LINE__
8
8
  k__FILE__ k__ENCODING__ tIDENTIFIER tFID tGVAR tIVAR tCONSTANT
9
9
  tLABEL tCVAR tNTH_REF tBACK_REF tSTRING_CONTENT tINTEGER tFLOAT
10
- tUPLUS tUMINUS tUMINUS_NUM tPOW tCMP tEQ tEQQ tNEQ
10
+ tUPLUS tUMINUS tUNARY_NUM tPOW tCMP tEQ tEQQ tNEQ
11
11
  tGEQ tLEQ tANDOP tOROP tMATCH tNMATCH tDOT tDOT2 tDOT3 tAREF
12
12
  tASET tLSHFT tRSHFT tCOLON2 tCOLON3 tOP_ASGN tASSOC tLPAREN
13
13
  tLPAREN2 tRPAREN tLPAREN_ARG tLBRACK tLBRACK2 tRBRACK tLBRACE
@@ -21,7 +21,7 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
21
21
  prechigh
22
22
  right tBANG tTILDE tUPLUS
23
23
  right tPOW
24
- right tUMINUS_NUM tUMINUS
24
+ right tUNARY_NUM tUMINUS
25
25
  left tSTAR2 tDIVIDE tPERCENT
26
26
  left tPLUS tMINUS
27
27
  left tLSHFT tRSHFT
@@ -684,14 +684,14 @@ rule
684
684
  {
685
685
  result = @builder.binary_op(val[0], val[1], val[2])
686
686
  }
687
- | tUMINUS_NUM tINTEGER tPOW arg
687
+ | tUNARY_NUM tINTEGER tPOW arg
688
688
  {
689
689
  result = @builder.unary_op(val[0],
690
690
  @builder.binary_op(
691
691
  @builder.integer(val[1]),
692
692
  val[2], val[3]))
693
693
  }
694
- | tUMINUS_NUM tFLOAT tPOW arg
694
+ | tUNARY_NUM tFLOAT tPOW arg
695
695
  {
696
696
  result = @builder.unary_op(val[0],
697
697
  @builder.binary_op(
@@ -1766,15 +1766,25 @@ regexp_contents: # nothing
1766
1766
  {
1767
1767
  result = @builder.float(val[0])
1768
1768
  }
1769
- | tUMINUS_NUM tINTEGER =tLOWEST
1769
+ | tUNARY_NUM tINTEGER =tLOWEST
1770
1770
  {
1771
- result = @builder.negate(val[0],
1772
- @builder.integer(val[1]))
1771
+ num = @builder.integer(val[1])
1772
+ if @builder.respond_to? :negate
1773
+ # AST builder interface compatibility
1774
+ result = @builder.negate(val[0], num)
1775
+ else
1776
+ result = @builder.unary_num(val[0], num)
1777
+ end
1773
1778
  }
1774
- | tUMINUS_NUM tFLOAT =tLOWEST
1779
+ | tUNARY_NUM tFLOAT =tLOWEST
1775
1780
  {
1776
- result = @builder.negate(val[0],
1777
- @builder.float(val[1]))
1781
+ num = @builder.float(val[1])
1782
+ if @builder.respond_to? :negate
1783
+ # AST builder interface compatibility
1784
+ result = @builder.negate(val[0], num)
1785
+ else
1786
+ result = @builder.unary_num(val[0], num)
1787
+ end
1778
1788
  }
1779
1789
 
1780
1790
  user_variable: tIDENTIFIER
@@ -7,7 +7,7 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
7
7
  kUNTIL_MOD kRESCUE_MOD kALIAS kDEFINED klBEGIN klEND k__LINE__
8
8
  k__FILE__ k__ENCODING__ tIDENTIFIER tFID tGVAR tIVAR tCONSTANT
9
9
  tLABEL tCVAR tNTH_REF tBACK_REF tSTRING_CONTENT tINTEGER tFLOAT
10
- tUPLUS tUMINUS tUMINUS_NUM tPOW tCMP tEQ tEQQ tNEQ
10
+ tUPLUS tUMINUS tUNARY_NUM tPOW tCMP tEQ tEQQ tNEQ
11
11
  tGEQ tLEQ tANDOP tOROP tMATCH tNMATCH tDOT tDOT2 tDOT3 tAREF
12
12
  tASET tLSHFT tRSHFT tCOLON2 tCOLON3 tOP_ASGN tASSOC tLPAREN
13
13
  tLPAREN2 tRPAREN tLPAREN_ARG tLBRACK tLBRACK2 tRBRACK tLBRACE
@@ -21,7 +21,7 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
21
21
  prechigh
22
22
  right tBANG tTILDE tUPLUS
23
23
  right tPOW
24
- right tUMINUS_NUM tUMINUS
24
+ right tUNARY_NUM tUMINUS
25
25
  left tSTAR2 tDIVIDE tPERCENT
26
26
  left tPLUS tMINUS
27
27
  left tLSHFT tRSHFT
@@ -697,14 +697,14 @@ rule
697
697
  {
698
698
  result = @builder.binary_op(val[0], val[1], val[2])
699
699
  }
700
- | tUMINUS_NUM tINTEGER tPOW arg
700
+ | tUNARY_NUM tINTEGER tPOW arg
701
701
  {
702
702
  result = @builder.unary_op(val[0],
703
703
  @builder.binary_op(
704
704
  @builder.integer(val[1]),
705
705
  val[2], val[3]))
706
706
  }
707
- | tUMINUS_NUM tFLOAT tPOW arg
707
+ | tUNARY_NUM tFLOAT tPOW arg
708
708
  {
709
709
  result = @builder.unary_op(val[0],
710
710
  @builder.binary_op(
@@ -1861,15 +1861,25 @@ regexp_contents: # nothing
1861
1861
  {
1862
1862
  result = @builder.float(val[0])
1863
1863
  }
1864
- | tUMINUS_NUM tINTEGER =tLOWEST
1864
+ | tUNARY_NUM tINTEGER =tLOWEST
1865
1865
  {
1866
- result = @builder.negate(val[0],
1867
- @builder.integer(val[1]))
1866
+ num = @builder.integer(val[1])
1867
+ if @builder.respond_to? :negate
1868
+ # AST builder interface compatibility
1869
+ result = @builder.negate(val[0], num)
1870
+ else
1871
+ result = @builder.unary_num(val[0], num)
1872
+ end
1868
1873
  }
1869
- | tUMINUS_NUM tFLOAT =tLOWEST
1874
+ | tUNARY_NUM tFLOAT =tLOWEST
1870
1875
  {
1871
- result = @builder.negate(val[0],
1872
- @builder.float(val[1]))
1876
+ num = @builder.float(val[1])
1877
+ if @builder.respond_to? :negate
1878
+ # AST builder interface compatibility
1879
+ result = @builder.negate(val[0], num)
1880
+ else
1881
+ result = @builder.unary_num(val[0], num)
1882
+ end
1873
1883
  }
1874
1884
 
1875
1885
  user_variable: tIDENTIFIER
@@ -7,7 +7,7 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
7
7
  kUNTIL_MOD kRESCUE_MOD kALIAS kDEFINED klBEGIN klEND k__LINE__
8
8
  k__FILE__ k__ENCODING__ tIDENTIFIER tFID tGVAR tIVAR tCONSTANT
9
9
  tLABEL tCVAR tNTH_REF tBACK_REF tSTRING_CONTENT tINTEGER tFLOAT
10
- tUPLUS tUMINUS tUMINUS_NUM tPOW tCMP tEQ tEQQ tNEQ
10
+ tUPLUS tUMINUS tUNARY_NUM tPOW tCMP tEQ tEQQ tNEQ
11
11
  tGEQ tLEQ tANDOP tOROP tMATCH tNMATCH tDOT tDOT2 tDOT3 tAREF
12
12
  tASET tLSHFT tRSHFT tCOLON2 tCOLON3 tOP_ASGN tASSOC tLPAREN
13
13
  tLPAREN2 tRPAREN tLPAREN_ARG tLBRACK tLBRACK2 tRBRACK tLBRACE
@@ -22,7 +22,7 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
22
22
  prechigh
23
23
  right tBANG tTILDE tUPLUS
24
24
  right tPOW
25
- right tUMINUS_NUM tUMINUS
25
+ right tUNARY_NUM tUMINUS
26
26
  left tSTAR2 tDIVIDE tPERCENT
27
27
  left tPLUS tMINUS
28
28
  left tLSHFT tRSHFT
@@ -689,7 +689,7 @@ rule
689
689
  {
690
690
  result = @builder.binary_op(val[0], val[1], val[2])
691
691
  }
692
- | tUMINUS_NUM simple_numeric tPOW arg
692
+ | tUNARY_NUM simple_numeric tPOW arg
693
693
  {
694
694
  result = @builder.unary_op(val[0],
695
695
  @builder.binary_op(
@@ -1845,9 +1845,14 @@ regexp_contents: # nothing
1845
1845
  {
1846
1846
  result = val[0]
1847
1847
  }
1848
- | tUMINUS_NUM simple_numeric =tLOWEST
1848
+ | tUNARY_NUM simple_numeric =tLOWEST
1849
1849
  {
1850
- result = @builder.negate(val[0], val[1])
1850
+ if @builder.respond_to? :negate
1851
+ # AST builder interface compatibility
1852
+ result = @builder.negate(val[0], val[1])
1853
+ else
1854
+ result = @builder.unary_num(val[0], val[1])
1855
+ end
1851
1856
  }
1852
1857
 
1853
1858
  simple_numeric: tINTEGER
@@ -7,7 +7,7 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
7
7
  kUNTIL_MOD kRESCUE_MOD kALIAS kDEFINED klBEGIN klEND k__LINE__
8
8
  k__FILE__ k__ENCODING__ tIDENTIFIER tFID tGVAR tIVAR tCONSTANT
9
9
  tLABEL tCVAR tNTH_REF tBACK_REF tSTRING_CONTENT tINTEGER tFLOAT
10
- tUPLUS tUMINUS tUMINUS_NUM tPOW tCMP tEQ tEQQ tNEQ
10
+ tUPLUS tUMINUS tUNARY_NUM tPOW tCMP tEQ tEQQ tNEQ
11
11
  tGEQ tLEQ tANDOP tOROP tMATCH tNMATCH tDOT tDOT2 tDOT3 tAREF
12
12
  tASET tLSHFT tRSHFT tCOLON2 tCOLON3 tOP_ASGN tASSOC tLPAREN
13
13
  tLPAREN2 tRPAREN tLPAREN_ARG tLBRACK tLBRACK2 tRBRACK tLBRACE
@@ -22,7 +22,7 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
22
22
  prechigh
23
23
  right tBANG tTILDE tUPLUS
24
24
  right tPOW
25
- right tUMINUS_NUM tUMINUS
25
+ right tUNARY_NUM tUMINUS
26
26
  left tSTAR2 tDIVIDE tPERCENT
27
27
  left tPLUS tMINUS
28
28
  left tLSHFT tRSHFT
@@ -689,7 +689,7 @@ rule
689
689
  {
690
690
  result = @builder.binary_op(val[0], val[1], val[2])
691
691
  }
692
- | tUMINUS_NUM simple_numeric tPOW arg
692
+ | tUNARY_NUM simple_numeric tPOW arg
693
693
  {
694
694
  result = @builder.unary_op(val[0],
695
695
  @builder.binary_op(
@@ -1844,9 +1844,14 @@ regexp_contents: # nothing
1844
1844
  {
1845
1845
  result = val[0]
1846
1846
  }
1847
- | tUMINUS_NUM simple_numeric =tLOWEST
1847
+ | tUNARY_NUM simple_numeric =tLOWEST
1848
1848
  {
1849
- result = @builder.negate(val[0], val[1])
1849
+ if @builder.respond_to? :negate
1850
+ # AST builder interface compatibility
1851
+ result = @builder.negate(val[0], val[1])
1852
+ else
1853
+ result = @builder.unary_num(val[0], val[1])
1854
+ end
1850
1855
  }
1851
1856
 
1852
1857
  simple_numeric: tINTEGER
@@ -7,7 +7,7 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
7
7
  kUNTIL_MOD kRESCUE_MOD kALIAS kDEFINED klBEGIN klEND k__LINE__
8
8
  k__FILE__ k__ENCODING__ tIDENTIFIER tFID tGVAR tIVAR tCONSTANT
9
9
  tLABEL tCVAR tNTH_REF tBACK_REF tSTRING_CONTENT tINTEGER tFLOAT
10
- tUPLUS tUMINUS tUMINUS_NUM tPOW tCMP tEQ tEQQ tNEQ
10
+ tUPLUS tUMINUS tUNARY_NUM tPOW tCMP tEQ tEQQ tNEQ
11
11
  tGEQ tLEQ tANDOP tOROP tMATCH tNMATCH tDOT tDOT2 tDOT3 tAREF
12
12
  tASET tLSHFT tRSHFT tCOLON2 tCOLON3 tOP_ASGN tASSOC tLPAREN
13
13
  tLPAREN2 tRPAREN tLPAREN_ARG tLBRACK tLBRACK2 tRBRACK tLBRACE
@@ -22,7 +22,7 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
22
22
  prechigh
23
23
  right tBANG tTILDE tUPLUS
24
24
  right tPOW
25
- right tUMINUS_NUM tUMINUS
25
+ right tUNARY_NUM tUMINUS
26
26
  left tSTAR2 tDIVIDE tPERCENT
27
27
  left tPLUS tMINUS
28
28
  left tLSHFT tRSHFT
@@ -689,7 +689,7 @@ rule
689
689
  {
690
690
  result = @builder.binary_op(val[0], val[1], val[2])
691
691
  }
692
- | tUMINUS_NUM simple_numeric tPOW arg
692
+ | tUNARY_NUM simple_numeric tPOW arg
693
693
  {
694
694
  result = @builder.unary_op(val[0],
695
695
  @builder.binary_op(
@@ -1847,9 +1847,14 @@ regexp_contents: # nothing
1847
1847
  {
1848
1848
  result = val[0]
1849
1849
  }
1850
- | tUMINUS_NUM simple_numeric =tLOWEST
1850
+ | tUNARY_NUM simple_numeric =tLOWEST
1851
1851
  {
1852
- result = @builder.negate(val[0], val[1])
1852
+ if @builder.respond_to? :negate
1853
+ # AST builder interface compatibility
1854
+ result = @builder.negate(val[0], val[1])
1855
+ else
1856
+ result = @builder.unary_num(val[0], val[1])
1857
+ end
1853
1858
  }
1854
1859
 
1855
1860
  simple_numeric: tINTEGER
@@ -7,7 +7,7 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
7
7
  kUNTIL_MOD kRESCUE_MOD kALIAS kDEFINED klBEGIN klEND k__LINE__
8
8
  k__FILE__ k__ENCODING__ tIDENTIFIER tFID tGVAR tIVAR tCONSTANT
9
9
  tLABEL tCVAR tNTH_REF tBACK_REF tSTRING_CONTENT tINTEGER tFLOAT
10
- tUPLUS tUMINUS tUMINUS_NUM tPOW tCMP tEQ tEQQ tNEQ
10
+ tUPLUS tUMINUS tUNARY_NUM tPOW tCMP tEQ tEQQ tNEQ
11
11
  tGEQ tLEQ tANDOP tOROP tMATCH tNMATCH tDOT tDOT2 tDOT3 tAREF
12
12
  tASET tLSHFT tRSHFT tCOLON2 tCOLON3 tOP_ASGN tASSOC tLPAREN
13
13
  tLPAREN2 tRPAREN tLPAREN_ARG tLBRACK tLBRACK2 tRBRACK tLBRACE
@@ -22,7 +22,7 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
22
22
  prechigh
23
23
  right tBANG tTILDE tUPLUS
24
24
  right tPOW
25
- right tUMINUS_NUM tUMINUS
25
+ right tUNARY_NUM tUMINUS
26
26
  left tSTAR2 tDIVIDE tPERCENT
27
27
  left tPLUS tMINUS
28
28
  left tLSHFT tRSHFT
@@ -670,7 +670,7 @@ rule
670
670
  {
671
671
  result = @builder.binary_op(val[0], val[1], val[2])
672
672
  }
673
- | tUMINUS_NUM simple_numeric tPOW arg
673
+ | tUNARY_NUM simple_numeric tPOW arg
674
674
  {
675
675
  result = @builder.unary_op(val[0],
676
676
  @builder.binary_op(
@@ -1854,9 +1854,14 @@ regexp_contents: # nothing
1854
1854
  {
1855
1855
  result = val[0]
1856
1856
  }
1857
- | tUMINUS_NUM simple_numeric =tLOWEST
1857
+ | tUNARY_NUM simple_numeric =tLOWEST
1858
1858
  {
1859
- result = @builder.negate(val[0], val[1])
1859
+ if @builder.respond_to? :negate
1860
+ # AST builder interface compatibility
1861
+ result = @builder.negate(val[0], val[1])
1862
+ else
1863
+ result = @builder.unary_num(val[0], val[1])
1864
+ end
1860
1865
  }
1861
1866
 
1862
1867
  simple_numeric: tINTEGER
@@ -0,0 +1,2362 @@
1
+ class Parser::Ruby25
2
+
3
+ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
4
+ kTHEN kELSIF kELSE kCASE kWHEN kWHILE kUNTIL kFOR kBREAK kNEXT
5
+ kREDO kRETRY kIN kDO kDO_COND kDO_BLOCK kDO_LAMBDA kRETURN kYIELD kSUPER
6
+ kSELF kNIL kTRUE kFALSE kAND kOR kNOT kIF_MOD kUNLESS_MOD kWHILE_MOD
7
+ kUNTIL_MOD kRESCUE_MOD kALIAS kDEFINED klBEGIN klEND k__LINE__
8
+ k__FILE__ k__ENCODING__ tIDENTIFIER tFID tGVAR tIVAR tCONSTANT
9
+ tLABEL tCVAR tNTH_REF tBACK_REF tSTRING_CONTENT tINTEGER tFLOAT
10
+ tUPLUS tUMINUS tUNARY_NUM tPOW tCMP tEQ tEQQ tNEQ
11
+ tGEQ tLEQ tANDOP tOROP tMATCH tNMATCH tDOT tDOT2 tDOT3 tAREF
12
+ tASET tLSHFT tRSHFT tCOLON2 tCOLON3 tOP_ASGN tASSOC tLPAREN
13
+ tLPAREN2 tRPAREN tLPAREN_ARG tLBRACK tLBRACK2 tRBRACK tLBRACE
14
+ tLBRACE_ARG tSTAR tSTAR2 tAMPER tAMPER2 tTILDE tPERCENT tDIVIDE
15
+ tDSTAR tPLUS tMINUS tLT tGT tPIPE tBANG tCARET tLCURLY tRCURLY
16
+ tBACK_REF2 tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG tREGEXP_OPT
17
+ tWORDS_BEG tQWORDS_BEG tSYMBOLS_BEG tQSYMBOLS_BEG tSTRING_DBEG
18
+ tSTRING_DVAR tSTRING_END tSTRING_DEND tSTRING tSYMBOL
19
+ tNL tEH tCOLON tCOMMA tSPACE tSEMI tLAMBDA tLAMBEG tCHARACTER
20
+ tRATIONAL tIMAGINARY tLABEL_END tANDDOT
21
+
22
+ prechigh
23
+ right tBANG tTILDE tUPLUS
24
+ right tPOW
25
+ right tUNARY_NUM tUMINUS
26
+ left tSTAR2 tDIVIDE tPERCENT
27
+ left tPLUS tMINUS
28
+ left tLSHFT tRSHFT
29
+ left tAMPER2
30
+ left tPIPE tCARET
31
+ left tGT tGEQ tLT tLEQ
32
+ nonassoc tCMP tEQ tEQQ tNEQ tMATCH tNMATCH
33
+ left tANDOP
34
+ left tOROP
35
+ nonassoc tDOT2 tDOT3
36
+ right tEH tCOLON
37
+ left kRESCUE_MOD
38
+ right tEQL tOP_ASGN
39
+ nonassoc kDEFINED
40
+ right kNOT
41
+ left kOR kAND
42
+ nonassoc kIF_MOD kUNLESS_MOD kWHILE_MOD kUNTIL_MOD
43
+ nonassoc tLBRACE_ARG
44
+ nonassoc tLOWEST
45
+ preclow
46
+
47
+ rule
48
+
49
+ program: top_compstmt
50
+
51
+ top_compstmt: top_stmts opt_terms
52
+ {
53
+ result = @builder.compstmt(val[0])
54
+ }
55
+
56
+ top_stmts: # nothing
57
+ {
58
+ result = []
59
+ }
60
+ | top_stmt
61
+ {
62
+ result = [ val[0] ]
63
+ }
64
+ | top_stmts terms top_stmt
65
+ {
66
+ result = val[0] << val[2]
67
+ }
68
+ | error top_stmt
69
+ {
70
+ result = [ val[1] ]
71
+ }
72
+
73
+ top_stmt: stmt
74
+ | klBEGIN tLCURLY top_compstmt tRCURLY
75
+ {
76
+ result = @builder.preexe(val[0], val[1], val[2], val[3])
77
+ }
78
+
79
+ bodystmt: compstmt opt_rescue opt_else opt_ensure
80
+ {
81
+ rescue_bodies = val[1]
82
+ else_t, else_ = val[2]
83
+ ensure_t, ensure_ = val[3]
84
+
85
+ if rescue_bodies.empty? && !else_.nil?
86
+ diagnostic :warning, :useless_else, nil, else_t
87
+ end
88
+
89
+ result = @builder.begin_body(val[0],
90
+ rescue_bodies,
91
+ else_t, else_,
92
+ ensure_t, ensure_)
93
+ }
94
+
95
+ compstmt: stmts opt_terms
96
+ {
97
+ result = @builder.compstmt(val[0])
98
+ }
99
+
100
+ stmts: # nothing
101
+ {
102
+ result = []
103
+ }
104
+ | stmt_or_begin
105
+ {
106
+ result = [ val[0] ]
107
+ }
108
+ | stmts terms stmt_or_begin
109
+ {
110
+ result = val[0] << val[2]
111
+ }
112
+ | error stmt
113
+ {
114
+ result = [ val[1] ]
115
+ }
116
+
117
+ stmt_or_begin: stmt
118
+ | klBEGIN tLCURLY top_compstmt tRCURLY
119
+ {
120
+ diagnostic :error, :begin_in_method, nil, val[0]
121
+ }
122
+
123
+ stmt: kALIAS fitem
124
+ {
125
+ @lexer.state = :expr_fname
126
+ }
127
+ fitem
128
+ {
129
+ result = @builder.alias(val[0], val[1], val[3])
130
+ }
131
+ | kALIAS tGVAR tGVAR
132
+ {
133
+ result = @builder.alias(val[0],
134
+ @builder.gvar(val[1]),
135
+ @builder.gvar(val[2]))
136
+ }
137
+ | kALIAS tGVAR tBACK_REF
138
+ {
139
+ result = @builder.alias(val[0],
140
+ @builder.gvar(val[1]),
141
+ @builder.back_ref(val[2]))
142
+ }
143
+ | kALIAS tGVAR tNTH_REF
144
+ {
145
+ diagnostic :error, :nth_ref_alias, nil, val[2]
146
+ }
147
+ | kUNDEF undef_list
148
+ {
149
+ result = @builder.undef_method(val[0], val[1])
150
+ }
151
+ | stmt kIF_MOD expr_value
152
+ {
153
+ result = @builder.condition_mod(val[0], nil,
154
+ val[1], val[2])
155
+ }
156
+ | stmt kUNLESS_MOD expr_value
157
+ {
158
+ result = @builder.condition_mod(nil, val[0],
159
+ val[1], val[2])
160
+ }
161
+ | stmt kWHILE_MOD expr_value
162
+ {
163
+ result = @builder.loop_mod(:while, val[0], val[1], val[2])
164
+ }
165
+ | stmt kUNTIL_MOD expr_value
166
+ {
167
+ result = @builder.loop_mod(:until, val[0], val[1], val[2])
168
+ }
169
+ | stmt kRESCUE_MOD stmt
170
+ {
171
+ rescue_body = @builder.rescue_body(val[1],
172
+ nil, nil, nil,
173
+ nil, val[2])
174
+
175
+ result = @builder.begin_body(val[0], [ rescue_body ])
176
+ }
177
+ | klEND tLCURLY compstmt tRCURLY
178
+ {
179
+ result = @builder.postexe(val[0], val[1], val[2], val[3])
180
+ }
181
+ | command_asgn
182
+ | mlhs tEQL command_call
183
+ {
184
+ result = @builder.multi_assign(val[0], val[1], val[2])
185
+ }
186
+ | lhs tEQL mrhs
187
+ {
188
+ result = @builder.assign(val[0], val[1],
189
+ @builder.array(nil, val[2], nil))
190
+ }
191
+ | mlhs tEQL mrhs_arg
192
+ {
193
+ result = @builder.multi_assign(val[0], val[1], val[2])
194
+ }
195
+ | expr
196
+
197
+ command_asgn: lhs tEQL command_rhs
198
+ {
199
+ result = @builder.assign(val[0], val[1], val[2])
200
+ }
201
+ | var_lhs tOP_ASGN command_rhs
202
+ {
203
+ result = @builder.op_assign(val[0], val[1], val[2])
204
+ }
205
+ | primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN command_rhs
206
+ {
207
+ result = @builder.op_assign(
208
+ @builder.index(
209
+ val[0], val[1], val[2], val[3]),
210
+ val[4], val[5])
211
+ }
212
+ | primary_value call_op tIDENTIFIER tOP_ASGN command_rhs
213
+ {
214
+ result = @builder.op_assign(
215
+ @builder.call_method(
216
+ val[0], val[1], val[2]),
217
+ val[3], val[4])
218
+ }
219
+ | primary_value call_op tCONSTANT tOP_ASGN command_rhs
220
+ {
221
+ result = @builder.op_assign(
222
+ @builder.call_method(
223
+ val[0], val[1], val[2]),
224
+ val[3], val[4])
225
+ }
226
+ | primary_value tCOLON2 tCONSTANT tOP_ASGN command_rhs
227
+ {
228
+ const = @builder.const_op_assignable(
229
+ @builder.const_fetch(val[0], val[1], val[2]))
230
+ result = @builder.op_assign(const, val[3], val[4])
231
+ }
232
+ | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_rhs
233
+ {
234
+ result = @builder.op_assign(
235
+ @builder.call_method(
236
+ val[0], val[1], val[2]),
237
+ val[3], val[4])
238
+ }
239
+ | backref tOP_ASGN command_rhs
240
+ {
241
+ @builder.op_assign(val[0], val[1], val[2])
242
+ }
243
+
244
+ command_rhs: command_call =tOP_ASGN
245
+ | command_call kRESCUE_MOD stmt
246
+ {
247
+ rescue_body = @builder.rescue_body(val[1],
248
+ nil, nil, nil,
249
+ nil, val[2])
250
+
251
+ result = @builder.begin_body(val[0], [ rescue_body ])
252
+ }
253
+ | command_asgn
254
+
255
+ expr: command_call
256
+ | expr kAND expr
257
+ {
258
+ result = @builder.logical_op(:and, val[0], val[1], val[2])
259
+ }
260
+ | expr kOR expr
261
+ {
262
+ result = @builder.logical_op(:or, val[0], val[1], val[2])
263
+ }
264
+ | kNOT opt_nl expr
265
+ {
266
+ result = @builder.not_op(val[0], nil, val[2], nil)
267
+ }
268
+ | tBANG command_call
269
+ {
270
+ result = @builder.not_op(val[0], nil, val[1], nil)
271
+ }
272
+ | arg
273
+
274
+ expr_value: expr
275
+
276
+ command_call: command
277
+ | block_command
278
+
279
+ block_command: block_call
280
+ | block_call dot_or_colon operation2 command_args
281
+ {
282
+ result = @builder.call_method(val[0], val[1], val[2],
283
+ nil, val[3], nil)
284
+ }
285
+
286
+ cmd_brace_block: tLBRACE_ARG brace_body tRCURLY
287
+ {
288
+ result = [ val[0], *val[1], val[2] ]
289
+ }
290
+
291
+ fcall: operation
292
+
293
+ command: fcall command_args =tLOWEST
294
+ {
295
+ result = @builder.call_method(nil, nil, val[0],
296
+ nil, val[1], nil)
297
+ }
298
+ | fcall command_args cmd_brace_block
299
+ {
300
+ method_call = @builder.call_method(nil, nil, val[0],
301
+ nil, val[1], nil)
302
+
303
+ begin_t, args, body, end_t = val[2]
304
+ result = @builder.block(method_call,
305
+ begin_t, args, body, end_t)
306
+ }
307
+ | primary_value call_op operation2 command_args =tLOWEST
308
+ {
309
+ result = @builder.call_method(val[0], val[1], val[2],
310
+ nil, val[3], nil)
311
+ }
312
+ | primary_value call_op operation2 command_args cmd_brace_block
313
+ {
314
+ method_call = @builder.call_method(val[0], val[1], val[2],
315
+ nil, val[3], nil)
316
+
317
+ begin_t, args, body, end_t = val[4]
318
+ result = @builder.block(method_call,
319
+ begin_t, args, body, end_t)
320
+ }
321
+ | primary_value tCOLON2 operation2 command_args =tLOWEST
322
+ {
323
+ result = @builder.call_method(val[0], val[1], val[2],
324
+ nil, val[3], nil)
325
+ }
326
+ | primary_value tCOLON2 operation2 command_args cmd_brace_block
327
+ {
328
+ method_call = @builder.call_method(val[0], val[1], val[2],
329
+ nil, val[3], nil)
330
+
331
+ begin_t, args, body, end_t = val[4]
332
+ result = @builder.block(method_call,
333
+ begin_t, args, body, end_t)
334
+ }
335
+ | kSUPER command_args
336
+ {
337
+ result = @builder.keyword_cmd(:super, val[0],
338
+ nil, val[1], nil)
339
+ }
340
+ | kYIELD command_args
341
+ {
342
+ result = @builder.keyword_cmd(:yield, val[0],
343
+ nil, val[1], nil)
344
+ }
345
+ | kRETURN call_args
346
+ {
347
+ result = @builder.keyword_cmd(:return, val[0],
348
+ nil, val[1], nil)
349
+ }
350
+ | kBREAK call_args
351
+ {
352
+ result = @builder.keyword_cmd(:break, val[0],
353
+ nil, val[1], nil)
354
+ }
355
+ | kNEXT call_args
356
+ {
357
+ result = @builder.keyword_cmd(:next, val[0],
358
+ nil, val[1], nil)
359
+ }
360
+
361
+ mlhs: mlhs_basic
362
+ {
363
+ result = @builder.multi_lhs(nil, val[0], nil)
364
+ }
365
+ | tLPAREN mlhs_inner rparen
366
+ {
367
+ result = @builder.begin(val[0], val[1], val[2])
368
+ }
369
+
370
+ mlhs_inner: mlhs_basic
371
+ {
372
+ result = @builder.multi_lhs(nil, val[0], nil)
373
+ }
374
+ | tLPAREN mlhs_inner rparen
375
+ {
376
+ result = @builder.multi_lhs(val[0], val[1], val[2])
377
+ }
378
+
379
+ mlhs_basic: mlhs_head
380
+ | mlhs_head mlhs_item
381
+ {
382
+ result = val[0].
383
+ push(val[1])
384
+ }
385
+ | mlhs_head tSTAR mlhs_node
386
+ {
387
+ result = val[0].
388
+ push(@builder.splat(val[1], val[2]))
389
+ }
390
+ | mlhs_head tSTAR mlhs_node tCOMMA mlhs_post
391
+ {
392
+ result = val[0].
393
+ push(@builder.splat(val[1], val[2])).
394
+ concat(val[4])
395
+ }
396
+ | mlhs_head tSTAR
397
+ {
398
+ result = val[0].
399
+ push(@builder.splat(val[1]))
400
+ }
401
+ | mlhs_head tSTAR tCOMMA mlhs_post
402
+ {
403
+ result = val[0].
404
+ push(@builder.splat(val[1])).
405
+ concat(val[3])
406
+ }
407
+ | tSTAR mlhs_node
408
+ {
409
+ result = [ @builder.splat(val[0], val[1]) ]
410
+ }
411
+ | tSTAR mlhs_node tCOMMA mlhs_post
412
+ {
413
+ result = [ @builder.splat(val[0], val[1]),
414
+ *val[3] ]
415
+ }
416
+ | tSTAR
417
+ {
418
+ result = [ @builder.splat(val[0]) ]
419
+ }
420
+ | tSTAR tCOMMA mlhs_post
421
+ {
422
+ result = [ @builder.splat(val[0]),
423
+ *val[2] ]
424
+ }
425
+
426
+ mlhs_item: mlhs_node
427
+ | tLPAREN mlhs_inner rparen
428
+ {
429
+ result = @builder.begin(val[0], val[1], val[2])
430
+ }
431
+
432
+ mlhs_head: mlhs_item tCOMMA
433
+ {
434
+ result = [ val[0] ]
435
+ }
436
+ | mlhs_head mlhs_item tCOMMA
437
+ {
438
+ result = val[0] << val[1]
439
+ }
440
+
441
+ mlhs_post: mlhs_item
442
+ {
443
+ result = [ val[0] ]
444
+ }
445
+ | mlhs_post tCOMMA mlhs_item
446
+ {
447
+ result = val[0] << val[2]
448
+ }
449
+
450
+ mlhs_node: user_variable
451
+ {
452
+ result = @builder.assignable(val[0])
453
+ }
454
+ | keyword_variable
455
+ {
456
+ result = @builder.assignable(val[0])
457
+ }
458
+ | primary_value tLBRACK2 opt_call_args rbracket
459
+ {
460
+ result = @builder.index_asgn(val[0], val[1], val[2], val[3])
461
+ }
462
+ | primary_value call_op tIDENTIFIER
463
+ {
464
+ result = @builder.attr_asgn(val[0], val[1], val[2])
465
+ }
466
+ | primary_value tCOLON2 tIDENTIFIER
467
+ {
468
+ result = @builder.attr_asgn(val[0], val[1], val[2])
469
+ }
470
+ | primary_value call_op tCONSTANT
471
+ {
472
+ result = @builder.attr_asgn(val[0], val[1], val[2])
473
+ }
474
+ | primary_value tCOLON2 tCONSTANT
475
+ {
476
+ result = @builder.assignable(
477
+ @builder.const_fetch(val[0], val[1], val[2]))
478
+ }
479
+ | tCOLON3 tCONSTANT
480
+ {
481
+ result = @builder.assignable(
482
+ @builder.const_global(val[0], val[1]))
483
+ }
484
+ | backref
485
+ {
486
+ result = @builder.assignable(val[0])
487
+ }
488
+
489
+ lhs: user_variable
490
+ {
491
+ result = @builder.assignable(val[0])
492
+ }
493
+ | keyword_variable
494
+ {
495
+ result = @builder.assignable(val[0])
496
+ }
497
+ | primary_value tLBRACK2 opt_call_args rbracket
498
+ {
499
+ result = @builder.index_asgn(val[0], val[1], val[2], val[3])
500
+ }
501
+ | primary_value call_op tIDENTIFIER
502
+ {
503
+ result = @builder.attr_asgn(val[0], val[1], val[2])
504
+ }
505
+ | primary_value tCOLON2 tIDENTIFIER
506
+ {
507
+ result = @builder.attr_asgn(val[0], val[1], val[2])
508
+ }
509
+ | primary_value call_op tCONSTANT
510
+ {
511
+ result = @builder.attr_asgn(val[0], val[1], val[2])
512
+ }
513
+ | primary_value tCOLON2 tCONSTANT
514
+ {
515
+ result = @builder.assignable(
516
+ @builder.const_fetch(val[0], val[1], val[2]))
517
+ }
518
+ | tCOLON3 tCONSTANT
519
+ {
520
+ result = @builder.assignable(
521
+ @builder.const_global(val[0], val[1]))
522
+ }
523
+ | backref
524
+ {
525
+ result = @builder.assignable(val[0])
526
+ }
527
+
528
+ cname: tIDENTIFIER
529
+ {
530
+ diagnostic :error, :module_name_const, nil, val[0]
531
+ }
532
+ | tCONSTANT
533
+
534
+ cpath: tCOLON3 cname
535
+ {
536
+ result = @builder.const_global(val[0], val[1])
537
+ }
538
+ | cname
539
+ {
540
+ result = @builder.const(val[0])
541
+ }
542
+ | primary_value tCOLON2 cname
543
+ {
544
+ result = @builder.const_fetch(val[0], val[1], val[2])
545
+ }
546
+
547
+ fname: tIDENTIFIER | tCONSTANT | tFID
548
+ | op
549
+ | reswords
550
+
551
+ fsym: fname
552
+ {
553
+ result = @builder.symbol(val[0])
554
+ }
555
+ | symbol
556
+
557
+ fitem: fsym
558
+ | dsym
559
+
560
+ undef_list: fitem
561
+ {
562
+ result = [ val[0] ]
563
+ }
564
+ | undef_list tCOMMA
565
+ {
566
+ @lexer.state = :expr_fname
567
+ }
568
+ fitem
569
+ {
570
+ result = val[0] << val[3]
571
+ }
572
+
573
+ op: tPIPE | tCARET | tAMPER2 | tCMP | tEQ | tEQQ
574
+ | tMATCH | tNMATCH | tGT | tGEQ | tLT | tLEQ
575
+ | tNEQ | tLSHFT | tRSHFT | tPLUS | tMINUS | tSTAR2
576
+ | tSTAR | tDIVIDE | tPERCENT | tPOW | tBANG | tTILDE
577
+ | tUPLUS | tUMINUS | tAREF | tASET | tDSTAR | tBACK_REF2
578
+
579
+ reswords: k__LINE__ | k__FILE__ | k__ENCODING__ | klBEGIN | klEND
580
+ | kALIAS | kAND | kBEGIN | kBREAK | kCASE
581
+ | kCLASS | kDEF | kDEFINED | kDO | kELSE
582
+ | kELSIF | kEND | kENSURE | kFALSE | kFOR
583
+ | kIN | kMODULE | kNEXT | kNIL | kNOT
584
+ | kOR | kREDO | kRESCUE | kRETRY | kRETURN
585
+ | kSELF | kSUPER | kTHEN | kTRUE | kUNDEF
586
+ | kWHEN | kYIELD | kIF | kUNLESS | kWHILE
587
+ | kUNTIL
588
+
589
+ arg: lhs tEQL arg_rhs
590
+ {
591
+ result = @builder.assign(val[0], val[1], val[2])
592
+ }
593
+ | var_lhs tOP_ASGN arg_rhs
594
+ {
595
+ result = @builder.op_assign(val[0], val[1], val[2])
596
+ }
597
+ | primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN arg_rhs
598
+ {
599
+ result = @builder.op_assign(
600
+ @builder.index(
601
+ val[0], val[1], val[2], val[3]),
602
+ val[4], val[5])
603
+ }
604
+ | primary_value call_op tIDENTIFIER tOP_ASGN arg_rhs
605
+ {
606
+ result = @builder.op_assign(
607
+ @builder.call_method(
608
+ val[0], val[1], val[2]),
609
+ val[3], val[4])
610
+ }
611
+ | primary_value call_op tCONSTANT tOP_ASGN arg_rhs
612
+ {
613
+ result = @builder.op_assign(
614
+ @builder.call_method(
615
+ val[0], val[1], val[2]),
616
+ val[3], val[4])
617
+ }
618
+ | primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg_rhs
619
+ {
620
+ result = @builder.op_assign(
621
+ @builder.call_method(
622
+ val[0], val[1], val[2]),
623
+ val[3], val[4])
624
+ }
625
+ | primary_value tCOLON2 tCONSTANT tOP_ASGN arg_rhs
626
+ {
627
+ const = @builder.const_op_assignable(
628
+ @builder.const_fetch(val[0], val[1], val[2]))
629
+ result = @builder.op_assign(const, val[3], val[4])
630
+ }
631
+ | tCOLON3 tCONSTANT tOP_ASGN arg_rhs
632
+ {
633
+ const = @builder.const_op_assignable(
634
+ @builder.const_global(val[0], val[1]))
635
+ result = @builder.op_assign(const, val[2], val[3])
636
+ }
637
+ | backref tOP_ASGN arg_rhs
638
+ {
639
+ result = @builder.op_assign(val[0], val[1], val[2])
640
+ }
641
+ | arg tDOT2 arg
642
+ {
643
+ result = @builder.range_inclusive(val[0], val[1], val[2])
644
+ }
645
+ | arg tDOT3 arg
646
+ {
647
+ result = @builder.range_exclusive(val[0], val[1], val[2])
648
+ }
649
+ | arg tPLUS arg
650
+ {
651
+ result = @builder.binary_op(val[0], val[1], val[2])
652
+ }
653
+ | arg tMINUS arg
654
+ {
655
+ result = @builder.binary_op(val[0], val[1], val[2])
656
+ }
657
+ | arg tSTAR2 arg
658
+ {
659
+ result = @builder.binary_op(val[0], val[1], val[2])
660
+ }
661
+ | arg tDIVIDE arg
662
+ {
663
+ result = @builder.binary_op(val[0], val[1], val[2])
664
+ }
665
+ | arg tPERCENT arg
666
+ {
667
+ result = @builder.binary_op(val[0], val[1], val[2])
668
+ }
669
+ | arg tPOW arg
670
+ {
671
+ result = @builder.binary_op(val[0], val[1], val[2])
672
+ }
673
+ | tUNARY_NUM simple_numeric tPOW arg
674
+ {
675
+ result = @builder.unary_op(val[0],
676
+ @builder.binary_op(
677
+ val[1], val[2], val[3]))
678
+ }
679
+ | tUPLUS arg
680
+ {
681
+ result = @builder.unary_op(val[0], val[1])
682
+ }
683
+ | tUMINUS arg
684
+ {
685
+ result = @builder.unary_op(val[0], val[1])
686
+ }
687
+ | arg tPIPE arg
688
+ {
689
+ result = @builder.binary_op(val[0], val[1], val[2])
690
+ }
691
+ | arg tCARET arg
692
+ {
693
+ result = @builder.binary_op(val[0], val[1], val[2])
694
+ }
695
+ | arg tAMPER2 arg
696
+ {
697
+ result = @builder.binary_op(val[0], val[1], val[2])
698
+ }
699
+ | arg tCMP arg
700
+ {
701
+ result = @builder.binary_op(val[0], val[1], val[2])
702
+ }
703
+ | rel_expr =tCMP
704
+ | arg tEQ arg
705
+ {
706
+ result = @builder.binary_op(val[0], val[1], val[2])
707
+ }
708
+ | arg tEQQ arg
709
+ {
710
+ result = @builder.binary_op(val[0], val[1], val[2])
711
+ }
712
+ | arg tNEQ arg
713
+ {
714
+ result = @builder.binary_op(val[0], val[1], val[2])
715
+ }
716
+ | arg tMATCH arg
717
+ {
718
+ result = @builder.match_op(val[0], val[1], val[2])
719
+ }
720
+ | arg tNMATCH arg
721
+ {
722
+ result = @builder.binary_op(val[0], val[1], val[2])
723
+ }
724
+ | tBANG arg
725
+ {
726
+ result = @builder.not_op(val[0], nil, val[1], nil)
727
+ }
728
+ | tTILDE arg
729
+ {
730
+ result = @builder.unary_op(val[0], val[1])
731
+ }
732
+ | arg tLSHFT arg
733
+ {
734
+ result = @builder.binary_op(val[0], val[1], val[2])
735
+ }
736
+ | arg tRSHFT arg
737
+ {
738
+ result = @builder.binary_op(val[0], val[1], val[2])
739
+ }
740
+ | arg tANDOP arg
741
+ {
742
+ result = @builder.logical_op(:and, val[0], val[1], val[2])
743
+ }
744
+ | arg tOROP arg
745
+ {
746
+ result = @builder.logical_op(:or, val[0], val[1], val[2])
747
+ }
748
+ | kDEFINED opt_nl arg
749
+ {
750
+ result = @builder.keyword_cmd(:defined?, val[0], nil, [ val[2] ], nil)
751
+ }
752
+ | arg tEH arg opt_nl tCOLON arg
753
+ {
754
+ result = @builder.ternary(val[0], val[1],
755
+ val[2], val[4], val[5])
756
+ }
757
+ | primary
758
+
759
+ relop: tGT | tLT | tGEQ | tLEQ
760
+
761
+ rel_expr: arg relop arg =tGT
762
+ {
763
+ result = @builder.binary_op(val[0], val[1], val[2])
764
+ }
765
+ | rel_expr relop arg =tGT
766
+ {
767
+ result = @builder.binary_op(val[0], val[1], val[2])
768
+ }
769
+
770
+ arg_value: arg
771
+
772
+ aref_args: none
773
+ | args trailer
774
+ | args tCOMMA assocs trailer
775
+ {
776
+ result = val[0] << @builder.associate(nil, val[2], nil)
777
+ }
778
+ | assocs trailer
779
+ {
780
+ result = [ @builder.associate(nil, val[0], nil) ]
781
+ }
782
+
783
+ arg_rhs: arg =tOP_ASGN
784
+ | arg kRESCUE_MOD arg
785
+ {
786
+ rescue_body = @builder.rescue_body(val[1],
787
+ nil, nil, nil,
788
+ nil, val[2])
789
+
790
+ result = @builder.begin_body(val[0], [ rescue_body ])
791
+ }
792
+
793
+ paren_args: tLPAREN2 opt_call_args rparen
794
+ {
795
+ result = val
796
+ }
797
+
798
+ opt_paren_args: # nothing
799
+ {
800
+ result = [ nil, [], nil ]
801
+ }
802
+ | paren_args
803
+
804
+ opt_call_args: # nothing
805
+ {
806
+ result = []
807
+ }
808
+ | call_args
809
+ | args tCOMMA
810
+ | args tCOMMA assocs tCOMMA
811
+ {
812
+ result = val[0] << @builder.associate(nil, val[2], nil)
813
+ }
814
+ | assocs tCOMMA
815
+ {
816
+ result = [ @builder.associate(nil, val[0], nil) ]
817
+ }
818
+
819
+ call_args: command
820
+ {
821
+ result = [ val[0] ]
822
+ }
823
+ | args opt_block_arg
824
+ {
825
+ result = val[0].concat(val[1])
826
+ }
827
+ | assocs opt_block_arg
828
+ {
829
+ result = [ @builder.associate(nil, val[0], nil) ]
830
+ result.concat(val[1])
831
+ }
832
+ | args tCOMMA assocs opt_block_arg
833
+ {
834
+ assocs = @builder.associate(nil, val[2], nil)
835
+ result = val[0] << assocs
836
+ result.concat(val[3])
837
+ }
838
+ | block_arg
839
+ {
840
+ result = [ val[0] ]
841
+ }
842
+
843
+ command_args: {
844
+ result = @lexer.cmdarg.dup
845
+ @lexer.cmdarg.push(true)
846
+ }
847
+ call_args
848
+ {
849
+ @lexer.cmdarg = val[0]
850
+
851
+ result = val[1]
852
+ }
853
+
854
+ block_arg: tAMPER arg_value
855
+ {
856
+ result = @builder.block_pass(val[0], val[1])
857
+ }
858
+
859
+ opt_block_arg: tCOMMA block_arg
860
+ {
861
+ result = [ val[1] ]
862
+ }
863
+ | # nothing
864
+ {
865
+ result = []
866
+ }
867
+
868
+ args: arg_value
869
+ {
870
+ result = [ val[0] ]
871
+ }
872
+ | tSTAR arg_value
873
+ {
874
+ result = [ @builder.splat(val[0], val[1]) ]
875
+ }
876
+ | args tCOMMA arg_value
877
+ {
878
+ result = val[0] << val[2]
879
+ }
880
+ | args tCOMMA tSTAR arg_value
881
+ {
882
+ result = val[0] << @builder.splat(val[2], val[3])
883
+ }
884
+
885
+ mrhs_arg: mrhs
886
+ {
887
+ result = @builder.array(nil, val[0], nil)
888
+ }
889
+ | arg_value
890
+
891
+ mrhs: args tCOMMA arg_value
892
+ {
893
+ result = val[0] << val[2]
894
+ }
895
+ | args tCOMMA tSTAR arg_value
896
+ {
897
+ result = val[0] << @builder.splat(val[2], val[3])
898
+ }
899
+ | tSTAR arg_value
900
+ {
901
+ result = [ @builder.splat(val[0], val[1]) ]
902
+ }
903
+
904
+ primary: literal
905
+ | strings
906
+ | xstring
907
+ | regexp
908
+ | words
909
+ | qwords
910
+ | symbols
911
+ | qsymbols
912
+ | var_ref
913
+ | backref
914
+ | tFID
915
+ {
916
+ result = @builder.call_method(nil, nil, val[0])
917
+ }
918
+ | kBEGIN
919
+ {
920
+ result = @lexer.cmdarg.dup
921
+ @lexer.cmdarg.clear
922
+ }
923
+ bodystmt kEND
924
+ {
925
+ @lexer.cmdarg = val[1]
926
+
927
+ result = @builder.begin_keyword(val[0], val[2], val[3])
928
+ }
929
+ | tLPAREN_ARG
930
+ {
931
+ result = @lexer.cmdarg.dup
932
+ @lexer.cmdarg.clear
933
+ }
934
+ stmt
935
+ {
936
+ @lexer.state = :expr_endarg
937
+ }
938
+ rparen
939
+ {
940
+ @lexer.cmdarg = val[1]
941
+
942
+ result = @builder.begin(val[0], val[2], val[4])
943
+ }
944
+ | tLPAREN_ARG
945
+ {
946
+ @lexer.state = :expr_endarg
947
+ }
948
+ opt_nl tRPAREN
949
+ {
950
+ result = @builder.begin(val[0], nil, val[3])
951
+ }
952
+ | tLPAREN compstmt tRPAREN
953
+ {
954
+ result = @builder.begin(val[0], val[1], val[2])
955
+ }
956
+ | primary_value tCOLON2 tCONSTANT
957
+ {
958
+ result = @builder.const_fetch(val[0], val[1], val[2])
959
+ }
960
+ | tCOLON3 tCONSTANT
961
+ {
962
+ result = @builder.const_global(val[0], val[1])
963
+ }
964
+ | tLBRACK aref_args tRBRACK
965
+ {
966
+ result = @builder.array(val[0], val[1], val[2])
967
+ }
968
+ | tLBRACE assoc_list tRCURLY
969
+ {
970
+ result = @builder.associate(val[0], val[1], val[2])
971
+ }
972
+ | kRETURN
973
+ {
974
+ result = @builder.keyword_cmd(:return, val[0])
975
+ }
976
+ | kYIELD tLPAREN2 call_args rparen
977
+ {
978
+ result = @builder.keyword_cmd(:yield, val[0], val[1], val[2], val[3])
979
+ }
980
+ | kYIELD tLPAREN2 rparen
981
+ {
982
+ result = @builder.keyword_cmd(:yield, val[0], val[1], [], val[2])
983
+ }
984
+ | kYIELD
985
+ {
986
+ result = @builder.keyword_cmd(:yield, val[0])
987
+ }
988
+ | kDEFINED opt_nl tLPAREN2 expr rparen
989
+ {
990
+ result = @builder.keyword_cmd(:defined?, val[0],
991
+ val[2], [ val[3] ], val[4])
992
+ }
993
+ | kNOT tLPAREN2 expr rparen
994
+ {
995
+ result = @builder.not_op(val[0], val[1], val[2], val[3])
996
+ }
997
+ | kNOT tLPAREN2 rparen
998
+ {
999
+ result = @builder.not_op(val[0], val[1], nil, val[2])
1000
+ }
1001
+ | fcall brace_block
1002
+ {
1003
+ method_call = @builder.call_method(nil, nil, val[0])
1004
+
1005
+ begin_t, args, body, end_t = val[1]
1006
+ result = @builder.block(method_call,
1007
+ begin_t, args, body, end_t)
1008
+ }
1009
+ | method_call
1010
+ | method_call brace_block
1011
+ {
1012
+ begin_t, args, body, end_t = val[1]
1013
+ result = @builder.block(val[0],
1014
+ begin_t, args, body, end_t)
1015
+ }
1016
+ | tLAMBDA lambda
1017
+ {
1018
+ lambda_call = @builder.call_lambda(val[0])
1019
+
1020
+ args, (begin_t, body, end_t) = val[1]
1021
+ result = @builder.block(lambda_call,
1022
+ begin_t, args, body, end_t)
1023
+ }
1024
+ | kIF expr_value then compstmt if_tail kEND
1025
+ {
1026
+ else_t, else_ = val[4]
1027
+ result = @builder.condition(val[0], val[1], val[2],
1028
+ val[3], else_t,
1029
+ else_, val[5])
1030
+ }
1031
+ | kUNLESS expr_value then compstmt opt_else kEND
1032
+ {
1033
+ else_t, else_ = val[4]
1034
+ result = @builder.condition(val[0], val[1], val[2],
1035
+ else_, else_t,
1036
+ val[3], val[5])
1037
+ }
1038
+ | kWHILE
1039
+ {
1040
+ @lexer.cond.push(true)
1041
+ }
1042
+ expr_value do
1043
+ {
1044
+ @lexer.cond.pop
1045
+ }
1046
+ compstmt kEND
1047
+ {
1048
+ result = @builder.loop(:while, val[0], val[2], val[3],
1049
+ val[5], val[6])
1050
+ }
1051
+ | kUNTIL
1052
+ {
1053
+ @lexer.cond.push(true)
1054
+ }
1055
+ expr_value do
1056
+ {
1057
+ @lexer.cond.pop
1058
+ }
1059
+ compstmt kEND
1060
+ {
1061
+ result = @builder.loop(:until, val[0], val[2], val[3],
1062
+ val[5], val[6])
1063
+ }
1064
+ | kCASE expr_value opt_terms case_body kEND
1065
+ {
1066
+ *when_bodies, (else_t, else_body) = *val[3]
1067
+
1068
+ result = @builder.case(val[0], val[1],
1069
+ when_bodies, else_t, else_body,
1070
+ val[4])
1071
+ }
1072
+ | kCASE opt_terms case_body kEND
1073
+ {
1074
+ *when_bodies, (else_t, else_body) = *val[2]
1075
+
1076
+ result = @builder.case(val[0], nil,
1077
+ when_bodies, else_t, else_body,
1078
+ val[3])
1079
+ }
1080
+ | kFOR for_var kIN
1081
+ {
1082
+ @lexer.cond.push(true)
1083
+ }
1084
+ expr_value do
1085
+ {
1086
+ @lexer.cond.pop
1087
+ }
1088
+ compstmt kEND
1089
+ {
1090
+ result = @builder.for(val[0], val[1],
1091
+ val[2], val[4],
1092
+ val[5], val[7], val[8])
1093
+ }
1094
+ | kCLASS cpath superclass
1095
+ {
1096
+ @static_env.extend_static
1097
+ @lexer.push_cmdarg
1098
+ }
1099
+ bodystmt kEND
1100
+ {
1101
+ if in_def?
1102
+ diagnostic :error, :class_in_def, nil, val[0]
1103
+ end
1104
+
1105
+ lt_t, superclass = val[2]
1106
+ result = @builder.def_class(val[0], val[1],
1107
+ lt_t, superclass,
1108
+ val[4], val[5])
1109
+
1110
+ @lexer.pop_cmdarg
1111
+ @static_env.unextend
1112
+ }
1113
+ | kCLASS tLSHFT expr term
1114
+ {
1115
+ result = @def_level
1116
+ @def_level = 0
1117
+
1118
+ @static_env.extend_static
1119
+ @lexer.push_cmdarg
1120
+ }
1121
+ bodystmt kEND
1122
+ {
1123
+ result = @builder.def_sclass(val[0], val[1], val[2],
1124
+ val[5], val[6])
1125
+
1126
+ @lexer.pop_cmdarg
1127
+ @static_env.unextend
1128
+
1129
+ @def_level = val[4]
1130
+ }
1131
+ | kMODULE cpath
1132
+ {
1133
+ @static_env.extend_static
1134
+ @lexer.push_cmdarg
1135
+ }
1136
+ bodystmt kEND
1137
+ {
1138
+ if in_def?
1139
+ diagnostic :error, :module_in_def, nil, val[0]
1140
+ end
1141
+
1142
+ result = @builder.def_module(val[0], val[1],
1143
+ val[3], val[4])
1144
+
1145
+ @lexer.pop_cmdarg
1146
+ @static_env.unextend
1147
+ }
1148
+ | kDEF fname
1149
+ {
1150
+ @def_level += 1
1151
+ @static_env.extend_static
1152
+ @lexer.push_cmdarg
1153
+ }
1154
+ f_arglist bodystmt kEND
1155
+ {
1156
+ result = @builder.def_method(val[0], val[1],
1157
+ val[3], val[4], val[5])
1158
+
1159
+ @lexer.pop_cmdarg
1160
+ @static_env.unextend
1161
+ @def_level -= 1
1162
+ }
1163
+ | kDEF singleton dot_or_colon
1164
+ {
1165
+ @lexer.state = :expr_fname
1166
+ }
1167
+ fname
1168
+ {
1169
+ @def_level += 1
1170
+ @static_env.extend_static
1171
+ @lexer.push_cmdarg
1172
+ }
1173
+ f_arglist bodystmt kEND
1174
+ {
1175
+ result = @builder.def_singleton(val[0], val[1], val[2],
1176
+ val[4], val[6], val[7], val[8])
1177
+
1178
+ @lexer.pop_cmdarg
1179
+ @static_env.unextend
1180
+ @def_level -= 1
1181
+ }
1182
+ | kBREAK
1183
+ {
1184
+ result = @builder.keyword_cmd(:break, val[0])
1185
+ }
1186
+ | kNEXT
1187
+ {
1188
+ result = @builder.keyword_cmd(:next, val[0])
1189
+ }
1190
+ | kREDO
1191
+ {
1192
+ result = @builder.keyword_cmd(:redo, val[0])
1193
+ }
1194
+ | kRETRY
1195
+ {
1196
+ result = @builder.keyword_cmd(:retry, val[0])
1197
+ }
1198
+
1199
+ primary_value: primary
1200
+
1201
+ then: term
1202
+ | kTHEN
1203
+ | term kTHEN
1204
+ {
1205
+ result = val[1]
1206
+ }
1207
+
1208
+ do: term
1209
+ | kDO_COND
1210
+
1211
+ if_tail: opt_else
1212
+ | kELSIF expr_value then compstmt if_tail
1213
+ {
1214
+ else_t, else_ = val[4]
1215
+ result = [ val[0],
1216
+ @builder.condition(val[0], val[1], val[2],
1217
+ val[3], else_t,
1218
+ else_, nil),
1219
+ ]
1220
+ }
1221
+
1222
+ opt_else: none
1223
+ | kELSE compstmt
1224
+ {
1225
+ result = val
1226
+ }
1227
+
1228
+ for_var: lhs
1229
+ | mlhs
1230
+
1231
+ f_marg: f_norm_arg
1232
+ {
1233
+ result = @builder.arg(val[0])
1234
+ }
1235
+ | tLPAREN f_margs rparen
1236
+ {
1237
+ result = @builder.multi_lhs(val[0], val[1], val[2])
1238
+ }
1239
+
1240
+ f_marg_list: f_marg
1241
+ {
1242
+ result = [ val[0] ]
1243
+ }
1244
+ | f_marg_list tCOMMA f_marg
1245
+ {
1246
+ result = val[0] << val[2]
1247
+ }
1248
+
1249
+ f_margs: f_marg_list
1250
+ | f_marg_list tCOMMA tSTAR f_norm_arg
1251
+ {
1252
+ result = val[0].
1253
+ push(@builder.restarg(val[2], val[3]))
1254
+ }
1255
+ | f_marg_list tCOMMA tSTAR f_norm_arg tCOMMA f_marg_list
1256
+ {
1257
+ result = val[0].
1258
+ push(@builder.restarg(val[2], val[3])).
1259
+ concat(val[5])
1260
+ }
1261
+ | f_marg_list tCOMMA tSTAR
1262
+ {
1263
+ result = val[0].
1264
+ push(@builder.restarg(val[2]))
1265
+ }
1266
+ | f_marg_list tCOMMA tSTAR tCOMMA f_marg_list
1267
+ {
1268
+ result = val[0].
1269
+ push(@builder.restarg(val[2])).
1270
+ concat(val[4])
1271
+ }
1272
+ | tSTAR f_norm_arg
1273
+ {
1274
+ result = [ @builder.restarg(val[0], val[1]) ]
1275
+ }
1276
+ | tSTAR f_norm_arg tCOMMA f_marg_list
1277
+ {
1278
+ result = [ @builder.restarg(val[0], val[1]),
1279
+ *val[3] ]
1280
+ }
1281
+ | tSTAR
1282
+ {
1283
+ result = [ @builder.restarg(val[0]) ]
1284
+ }
1285
+ | tSTAR tCOMMA f_marg_list
1286
+ {
1287
+ result = [ @builder.restarg(val[0]),
1288
+ *val[2] ]
1289
+ }
1290
+
1291
+ block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
1292
+ {
1293
+ result = val[0].concat(val[2]).concat(val[3])
1294
+ }
1295
+ | f_block_kwarg opt_f_block_arg
1296
+ {
1297
+ result = val[0].concat(val[1])
1298
+ }
1299
+ | f_kwrest opt_f_block_arg
1300
+ {
1301
+ result = val[0].concat(val[1])
1302
+ }
1303
+ | f_block_arg
1304
+ {
1305
+ result = [ val[0] ]
1306
+ }
1307
+
1308
+ opt_block_args_tail:
1309
+ tCOMMA block_args_tail
1310
+ {
1311
+ result = val[1]
1312
+ }
1313
+ | # nothing
1314
+ {
1315
+ result = []
1316
+ }
1317
+
1318
+ block_param: f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
1319
+ {
1320
+ result = val[0].
1321
+ concat(val[2]).
1322
+ concat(val[4]).
1323
+ concat(val[5])
1324
+ }
1325
+ | f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
1326
+ {
1327
+ result = val[0].
1328
+ concat(val[2]).
1329
+ concat(val[4]).
1330
+ concat(val[6]).
1331
+ concat(val[7])
1332
+ }
1333
+ | f_arg tCOMMA f_block_optarg opt_block_args_tail
1334
+ {
1335
+ result = val[0].
1336
+ concat(val[2]).
1337
+ concat(val[3])
1338
+ }
1339
+ | f_arg tCOMMA f_block_optarg tCOMMA f_arg opt_block_args_tail
1340
+ {
1341
+ result = val[0].
1342
+ concat(val[2]).
1343
+ concat(val[4]).
1344
+ concat(val[5])
1345
+ }
1346
+ | f_arg tCOMMA f_rest_arg opt_block_args_tail
1347
+ {
1348
+ result = val[0].
1349
+ concat(val[2]).
1350
+ concat(val[3])
1351
+ }
1352
+ | f_arg tCOMMA
1353
+ | f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
1354
+ {
1355
+ result = val[0].
1356
+ concat(val[2]).
1357
+ concat(val[4]).
1358
+ concat(val[5])
1359
+ }
1360
+ | f_arg opt_block_args_tail
1361
+ {
1362
+ if val[1].empty? && val[0].size == 1
1363
+ result = [@builder.procarg0(val[0][0])]
1364
+ else
1365
+ result = val[0].concat(val[1])
1366
+ end
1367
+ }
1368
+ | f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
1369
+ {
1370
+ result = val[0].
1371
+ concat(val[2]).
1372
+ concat(val[3])
1373
+ }
1374
+ | f_block_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
1375
+ {
1376
+ result = val[0].
1377
+ concat(val[2]).
1378
+ concat(val[4]).
1379
+ concat(val[5])
1380
+ }
1381
+ | f_block_optarg opt_block_args_tail
1382
+ {
1383
+ result = val[0].
1384
+ concat(val[1])
1385
+ }
1386
+ | f_block_optarg tCOMMA f_arg opt_block_args_tail
1387
+ {
1388
+ result = val[0].
1389
+ concat(val[2]).
1390
+ concat(val[3])
1391
+ }
1392
+ | f_rest_arg opt_block_args_tail
1393
+ {
1394
+ result = val[0].
1395
+ concat(val[1])
1396
+ }
1397
+ | f_rest_arg tCOMMA f_arg opt_block_args_tail
1398
+ {
1399
+ result = val[0].
1400
+ concat(val[2]).
1401
+ concat(val[3])
1402
+ }
1403
+ | block_args_tail
1404
+
1405
+ opt_block_param: # nothing
1406
+ {
1407
+ result = @builder.args(nil, [], nil)
1408
+ }
1409
+ | block_param_def
1410
+ {
1411
+ @lexer.state = :expr_value
1412
+ }
1413
+
1414
+ block_param_def: tPIPE opt_bv_decl tPIPE
1415
+ {
1416
+ result = @builder.args(val[0], val[1], val[2])
1417
+ }
1418
+ | tOROP
1419
+ {
1420
+ result = @builder.args(val[0], [], val[0])
1421
+ }
1422
+ | tPIPE block_param opt_bv_decl tPIPE
1423
+ {
1424
+ result = @builder.args(val[0], val[1].concat(val[2]), val[3])
1425
+ }
1426
+
1427
+ opt_bv_decl: opt_nl
1428
+ {
1429
+ result = []
1430
+ }
1431
+ | opt_nl tSEMI bv_decls opt_nl
1432
+ {
1433
+ result = val[2]
1434
+ }
1435
+
1436
+ bv_decls: bvar
1437
+ {
1438
+ result = [ val[0] ]
1439
+ }
1440
+ | bv_decls tCOMMA bvar
1441
+ {
1442
+ result = val[0] << val[2]
1443
+ }
1444
+
1445
+ bvar: tIDENTIFIER
1446
+ {
1447
+ @static_env.declare val[0][0]
1448
+ result = @builder.shadowarg(val[0])
1449
+ }
1450
+ | f_bad_arg
1451
+
1452
+ lambda: {
1453
+ @static_env.extend_dynamic
1454
+ }
1455
+ f_larglist
1456
+ {
1457
+ result = @lexer.cmdarg.dup
1458
+ @lexer.cmdarg.clear
1459
+ }
1460
+ lambda_body
1461
+ {
1462
+ @lexer.cmdarg = val[2]
1463
+ @lexer.cmdarg.lexpop
1464
+
1465
+ result = [ val[1], val[3] ]
1466
+
1467
+ @static_env.unextend
1468
+ }
1469
+
1470
+ f_larglist: tLPAREN2 f_args opt_bv_decl tRPAREN
1471
+ {
1472
+ result = @builder.args(val[0], val[1].concat(val[2]), val[3])
1473
+ }
1474
+ | f_args
1475
+ {
1476
+ result = @builder.args(nil, val[0], nil)
1477
+ }
1478
+
1479
+ lambda_body: tLAMBEG compstmt tRCURLY
1480
+ {
1481
+ result = [ val[0], val[1], val[2] ]
1482
+ }
1483
+ | kDO_LAMBDA compstmt kEND
1484
+ {
1485
+ result = [ val[0], val[1], val[2] ]
1486
+ }
1487
+
1488
+ do_block: kDO_BLOCK do_body kEND
1489
+ {
1490
+ result = [ val[0], *val[1], val[2] ]
1491
+ }
1492
+
1493
+ block_call: command do_block
1494
+ {
1495
+ begin_t, block_args, body, end_t = val[1]
1496
+ result = @builder.block(val[0],
1497
+ begin_t, block_args, body, end_t)
1498
+ }
1499
+ | block_call dot_or_colon operation2 opt_paren_args
1500
+ {
1501
+ lparen_t, args, rparen_t = val[3]
1502
+ result = @builder.call_method(val[0], val[1], val[2],
1503
+ lparen_t, args, rparen_t)
1504
+ }
1505
+ | block_call dot_or_colon operation2 opt_paren_args brace_block
1506
+ {
1507
+ lparen_t, args, rparen_t = val[3]
1508
+ method_call = @builder.call_method(val[0], val[1], val[2],
1509
+ lparen_t, args, rparen_t)
1510
+
1511
+ begin_t, args, body, end_t = val[4]
1512
+ result = @builder.block(method_call,
1513
+ begin_t, args, body, end_t)
1514
+ }
1515
+ | block_call dot_or_colon operation2 command_args do_block
1516
+ {
1517
+ method_call = @builder.call_method(val[0], val[1], val[2],
1518
+ nil, val[3], nil)
1519
+
1520
+ begin_t, args, body, end_t = val[4]
1521
+ result = @builder.block(method_call,
1522
+ begin_t, args, body, end_t)
1523
+ }
1524
+
1525
+ method_call: fcall paren_args
1526
+ {
1527
+ lparen_t, args, rparen_t = val[1]
1528
+ result = @builder.call_method(nil, nil, val[0],
1529
+ lparen_t, args, rparen_t)
1530
+ }
1531
+ | primary_value call_op operation2 opt_paren_args
1532
+ {
1533
+ lparen_t, args, rparen_t = val[3]
1534
+ result = @builder.call_method(val[0], val[1], val[2],
1535
+ lparen_t, args, rparen_t)
1536
+ }
1537
+ | primary_value tCOLON2 operation2 paren_args
1538
+ {
1539
+ lparen_t, args, rparen_t = val[3]
1540
+ result = @builder.call_method(val[0], val[1], val[2],
1541
+ lparen_t, args, rparen_t)
1542
+ }
1543
+ | primary_value tCOLON2 operation3
1544
+ {
1545
+ result = @builder.call_method(val[0], val[1], val[2])
1546
+ }
1547
+ | primary_value call_op paren_args
1548
+ {
1549
+ lparen_t, args, rparen_t = val[2]
1550
+ result = @builder.call_method(val[0], val[1], nil,
1551
+ lparen_t, args, rparen_t)
1552
+ }
1553
+ | primary_value tCOLON2 paren_args
1554
+ {
1555
+ lparen_t, args, rparen_t = val[2]
1556
+ result = @builder.call_method(val[0], val[1], nil,
1557
+ lparen_t, args, rparen_t)
1558
+ }
1559
+ | kSUPER paren_args
1560
+ {
1561
+ lparen_t, args, rparen_t = val[1]
1562
+ result = @builder.keyword_cmd(:super, val[0],
1563
+ lparen_t, args, rparen_t)
1564
+ }
1565
+ | kSUPER
1566
+ {
1567
+ result = @builder.keyword_cmd(:zsuper, val[0])
1568
+ }
1569
+ | primary_value tLBRACK2 opt_call_args rbracket
1570
+ {
1571
+ result = @builder.index(val[0], val[1], val[2], val[3])
1572
+ }
1573
+
1574
+ brace_block: tLCURLY brace_body tRCURLY
1575
+ {
1576
+ result = [ val[0], *val[1], val[2] ]
1577
+ }
1578
+ | kDO do_body kEND
1579
+ {
1580
+ result = [ val[0], *val[1], val[2] ]
1581
+ }
1582
+
1583
+ brace_body: {
1584
+ @static_env.extend_dynamic
1585
+ }
1586
+ {
1587
+ result = @lexer.cmdarg.dup
1588
+ @lexer.cmdarg.clear
1589
+ }
1590
+ opt_block_param compstmt
1591
+ {
1592
+ result = [ val[2], val[3] ]
1593
+
1594
+ @static_env.unextend
1595
+ @lexer.cmdarg = val[1]
1596
+ @lexer.cmdarg.pop
1597
+ }
1598
+
1599
+ do_body: {
1600
+ @static_env.extend_dynamic
1601
+ }
1602
+ {
1603
+ result = @lexer.cmdarg.dup
1604
+ @lexer.cmdarg.clear
1605
+ }
1606
+ opt_block_param bodystmt
1607
+ {
1608
+ result = [ val[2], val[3] ]
1609
+
1610
+ @static_env.unextend
1611
+ @lexer.cmdarg = val[1]
1612
+ @lexer.cmdarg.pop
1613
+ }
1614
+
1615
+ case_body: kWHEN args then compstmt cases
1616
+ {
1617
+ result = [ @builder.when(val[0], val[1], val[2], val[3]),
1618
+ *val[4] ]
1619
+ }
1620
+
1621
+ cases: opt_else
1622
+ {
1623
+ result = [ val[0] ]
1624
+ }
1625
+ | case_body
1626
+
1627
+ opt_rescue: kRESCUE exc_list exc_var then compstmt opt_rescue
1628
+ {
1629
+ assoc_t, exc_var = val[2]
1630
+
1631
+ if val[1]
1632
+ exc_list = @builder.array(nil, val[1], nil)
1633
+ end
1634
+
1635
+ result = [ @builder.rescue_body(val[0],
1636
+ exc_list, assoc_t, exc_var,
1637
+ val[3], val[4]),
1638
+ *val[5] ]
1639
+ }
1640
+ |
1641
+ {
1642
+ result = []
1643
+ }
1644
+
1645
+ exc_list: arg_value
1646
+ {
1647
+ result = [ val[0] ]
1648
+ }
1649
+ | mrhs
1650
+ | none
1651
+
1652
+ exc_var: tASSOC lhs
1653
+ {
1654
+ result = [ val[0], val[1] ]
1655
+ }
1656
+ | none
1657
+
1658
+ opt_ensure: kENSURE compstmt
1659
+ {
1660
+ result = [ val[0], val[1] ]
1661
+ }
1662
+ | none
1663
+
1664
+ literal: numeric
1665
+ | symbol
1666
+ | dsym
1667
+
1668
+ strings: string
1669
+ {
1670
+ result = @builder.string_compose(nil, val[0], nil)
1671
+ }
1672
+
1673
+ string: string1
1674
+ {
1675
+ result = [ val[0] ]
1676
+ }
1677
+ | string string1
1678
+ {
1679
+ result = val[0] << val[1]
1680
+ }
1681
+
1682
+ string1: tSTRING_BEG string_contents tSTRING_END
1683
+ {
1684
+ string = @builder.string_compose(val[0], val[1], val[2])
1685
+ result = @builder.dedent_string(string, @lexer.dedent_level)
1686
+ }
1687
+ | tSTRING
1688
+ {
1689
+ string = @builder.string(val[0])
1690
+ result = @builder.dedent_string(string, @lexer.dedent_level)
1691
+ }
1692
+ | tCHARACTER
1693
+ {
1694
+ result = @builder.character(val[0])
1695
+ }
1696
+
1697
+ xstring: tXSTRING_BEG xstring_contents tSTRING_END
1698
+ {
1699
+ string = @builder.xstring_compose(val[0], val[1], val[2])
1700
+ result = @builder.dedent_string(string, @lexer.dedent_level)
1701
+ }
1702
+
1703
+ regexp: tREGEXP_BEG regexp_contents tSTRING_END tREGEXP_OPT
1704
+ {
1705
+ opts = @builder.regexp_options(val[3])
1706
+ result = @builder.regexp_compose(val[0], val[1], val[2], opts)
1707
+ }
1708
+
1709
+ words: tWORDS_BEG word_list tSTRING_END
1710
+ {
1711
+ result = @builder.words_compose(val[0], val[1], val[2])
1712
+ }
1713
+
1714
+ word_list: # nothing
1715
+ {
1716
+ result = []
1717
+ }
1718
+ | word_list word tSPACE
1719
+ {
1720
+ result = val[0] << @builder.word(val[1])
1721
+ }
1722
+
1723
+ word: string_content
1724
+ {
1725
+ result = [ val[0] ]
1726
+ }
1727
+ | word string_content
1728
+ {
1729
+ result = val[0] << val[1]
1730
+ }
1731
+
1732
+ symbols: tSYMBOLS_BEG symbol_list tSTRING_END
1733
+ {
1734
+ result = @builder.symbols_compose(val[0], val[1], val[2])
1735
+ }
1736
+
1737
+ symbol_list: # nothing
1738
+ {
1739
+ result = []
1740
+ }
1741
+ | symbol_list word tSPACE
1742
+ {
1743
+ result = val[0] << @builder.word(val[1])
1744
+ }
1745
+
1746
+ qwords: tQWORDS_BEG qword_list tSTRING_END
1747
+ {
1748
+ result = @builder.words_compose(val[0], val[1], val[2])
1749
+ }
1750
+
1751
+ qsymbols: tQSYMBOLS_BEG qsym_list tSTRING_END
1752
+ {
1753
+ result = @builder.symbols_compose(val[0], val[1], val[2])
1754
+ }
1755
+
1756
+ qword_list: # nothing
1757
+ {
1758
+ result = []
1759
+ }
1760
+ | qword_list tSTRING_CONTENT tSPACE
1761
+ {
1762
+ result = val[0] << @builder.string_internal(val[1])
1763
+ }
1764
+
1765
+ qsym_list: # nothing
1766
+ {
1767
+ result = []
1768
+ }
1769
+ | qsym_list tSTRING_CONTENT tSPACE
1770
+ {
1771
+ result = val[0] << @builder.symbol_internal(val[1])
1772
+ }
1773
+
1774
+ string_contents: # nothing
1775
+ {
1776
+ result = []
1777
+ }
1778
+ | string_contents string_content
1779
+ {
1780
+ result = val[0] << val[1]
1781
+ }
1782
+
1783
+ xstring_contents: # nothing
1784
+ {
1785
+ result = []
1786
+ }
1787
+ | xstring_contents string_content
1788
+ {
1789
+ result = val[0] << val[1]
1790
+ }
1791
+
1792
+ regexp_contents: # nothing
1793
+ {
1794
+ result = []
1795
+ }
1796
+ | regexp_contents string_content
1797
+ {
1798
+ result = val[0] << val[1]
1799
+ }
1800
+
1801
+ string_content: tSTRING_CONTENT
1802
+ {
1803
+ result = @builder.string_internal(val[0])
1804
+ }
1805
+ | tSTRING_DVAR string_dvar
1806
+ {
1807
+ result = val[1]
1808
+ }
1809
+ | tSTRING_DBEG
1810
+ {
1811
+ @lexer.cond.push(false)
1812
+ @lexer.cmdarg.push(false)
1813
+ }
1814
+ compstmt tSTRING_DEND
1815
+ {
1816
+ @lexer.cond.lexpop
1817
+ @lexer.cmdarg.lexpop
1818
+
1819
+ result = @builder.begin(val[0], val[2], val[3])
1820
+ }
1821
+
1822
+ string_dvar: tGVAR
1823
+ {
1824
+ result = @builder.gvar(val[0])
1825
+ }
1826
+ | tIVAR
1827
+ {
1828
+ result = @builder.ivar(val[0])
1829
+ }
1830
+ | tCVAR
1831
+ {
1832
+ result = @builder.cvar(val[0])
1833
+ }
1834
+ | backref
1835
+
1836
+
1837
+ symbol: tSYMBOL
1838
+ {
1839
+ @lexer.state = :expr_endarg
1840
+ result = @builder.symbol(val[0])
1841
+ }
1842
+
1843
+ dsym: tSYMBEG xstring_contents tSTRING_END
1844
+ {
1845
+ @lexer.state = :expr_endarg
1846
+ result = @builder.symbol_compose(val[0], val[1], val[2])
1847
+ }
1848
+
1849
+ numeric: simple_numeric
1850
+ {
1851
+ result = val[0]
1852
+ }
1853
+ | tUNARY_NUM simple_numeric =tLOWEST
1854
+ {
1855
+ if @builder.respond_to? :negate
1856
+ # AST builder interface compatibility
1857
+ result = @builder.negate(val[0], val[1])
1858
+ else
1859
+ result = @builder.unary_num(val[0], val[1])
1860
+ end
1861
+ }
1862
+
1863
+ simple_numeric: tINTEGER
1864
+ {
1865
+ @lexer.state = :expr_endarg
1866
+ result = @builder.integer(val[0])
1867
+ }
1868
+ | tFLOAT
1869
+ {
1870
+ @lexer.state = :expr_endarg
1871
+ result = @builder.float(val[0])
1872
+ }
1873
+ | tRATIONAL
1874
+ {
1875
+ @lexer.state = :expr_endarg
1876
+ result = @builder.rational(val[0])
1877
+ }
1878
+ | tIMAGINARY
1879
+ {
1880
+ @lexer.state = :expr_endarg
1881
+ result = @builder.complex(val[0])
1882
+ }
1883
+
1884
+ user_variable: tIDENTIFIER
1885
+ {
1886
+ result = @builder.ident(val[0])
1887
+ }
1888
+ | tIVAR
1889
+ {
1890
+ result = @builder.ivar(val[0])
1891
+ }
1892
+ | tGVAR
1893
+ {
1894
+ result = @builder.gvar(val[0])
1895
+ }
1896
+ | tCONSTANT
1897
+ {
1898
+ result = @builder.const(val[0])
1899
+ }
1900
+ | tCVAR
1901
+ {
1902
+ result = @builder.cvar(val[0])
1903
+ }
1904
+
1905
+ keyword_variable: kNIL
1906
+ {
1907
+ result = @builder.nil(val[0])
1908
+ }
1909
+ | kSELF
1910
+ {
1911
+ result = @builder.self(val[0])
1912
+ }
1913
+ | kTRUE
1914
+ {
1915
+ result = @builder.true(val[0])
1916
+ }
1917
+ | kFALSE
1918
+ {
1919
+ result = @builder.false(val[0])
1920
+ }
1921
+ | k__FILE__
1922
+ {
1923
+ result = @builder.__FILE__(val[0])
1924
+ }
1925
+ | k__LINE__
1926
+ {
1927
+ result = @builder.__LINE__(val[0])
1928
+ }
1929
+ | k__ENCODING__
1930
+ {
1931
+ result = @builder.__ENCODING__(val[0])
1932
+ }
1933
+
1934
+ var_ref: user_variable
1935
+ {
1936
+ result = @builder.accessible(val[0])
1937
+ }
1938
+ | keyword_variable
1939
+ {
1940
+ result = @builder.accessible(val[0])
1941
+ }
1942
+
1943
+ var_lhs: user_variable
1944
+ {
1945
+ result = @builder.assignable(val[0])
1946
+ }
1947
+ | keyword_variable
1948
+ {
1949
+ result = @builder.assignable(val[0])
1950
+ }
1951
+
1952
+ backref: tNTH_REF
1953
+ {
1954
+ result = @builder.nth_ref(val[0])
1955
+ }
1956
+ | tBACK_REF
1957
+ {
1958
+ result = @builder.back_ref(val[0])
1959
+ }
1960
+
1961
+ superclass: tLT
1962
+ {
1963
+ @lexer.state = :expr_value
1964
+ }
1965
+ expr_value term
1966
+ {
1967
+ result = [ val[0], val[2] ]
1968
+ }
1969
+ | # nothing
1970
+ {
1971
+ result = nil
1972
+ }
1973
+
1974
+ f_arglist: tLPAREN2 f_args rparen
1975
+ {
1976
+ result = @builder.args(val[0], val[1], val[2])
1977
+
1978
+ @lexer.state = :expr_value
1979
+ }
1980
+ | {
1981
+ result = @lexer.in_kwarg
1982
+ @lexer.in_kwarg = true
1983
+ }
1984
+ f_args term
1985
+ {
1986
+ @lexer.in_kwarg = val[0]
1987
+ result = @builder.args(nil, val[1], nil)
1988
+ }
1989
+
1990
+ args_tail: f_kwarg tCOMMA f_kwrest opt_f_block_arg
1991
+ {
1992
+ result = val[0].concat(val[2]).concat(val[3])
1993
+ }
1994
+ | f_kwarg opt_f_block_arg
1995
+ {
1996
+ result = val[0].concat(val[1])
1997
+ }
1998
+ | f_kwrest opt_f_block_arg
1999
+ {
2000
+ result = val[0].concat(val[1])
2001
+ }
2002
+ | f_block_arg
2003
+ {
2004
+ result = [ val[0] ]
2005
+ }
2006
+
2007
+ opt_args_tail: tCOMMA args_tail
2008
+ {
2009
+ result = val[1]
2010
+ }
2011
+ | # nothing
2012
+ {
2013
+ result = []
2014
+ }
2015
+
2016
+ f_args: f_arg tCOMMA f_optarg tCOMMA f_rest_arg opt_args_tail
2017
+ {
2018
+ result = val[0].
2019
+ concat(val[2]).
2020
+ concat(val[4]).
2021
+ concat(val[5])
2022
+ }
2023
+ | f_arg tCOMMA f_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_args_tail
2024
+ {
2025
+ result = val[0].
2026
+ concat(val[2]).
2027
+ concat(val[4]).
2028
+ concat(val[6]).
2029
+ concat(val[7])
2030
+ }
2031
+ | f_arg tCOMMA f_optarg opt_args_tail
2032
+ {
2033
+ result = val[0].
2034
+ concat(val[2]).
2035
+ concat(val[3])
2036
+ }
2037
+ | f_arg tCOMMA f_optarg tCOMMA f_arg opt_args_tail
2038
+ {
2039
+ result = val[0].
2040
+ concat(val[2]).
2041
+ concat(val[4]).
2042
+ concat(val[5])
2043
+ }
2044
+ | f_arg tCOMMA f_rest_arg opt_args_tail
2045
+ {
2046
+ result = val[0].
2047
+ concat(val[2]).
2048
+ concat(val[3])
2049
+ }
2050
+ | f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_args_tail
2051
+ {
2052
+ result = val[0].
2053
+ concat(val[2]).
2054
+ concat(val[4]).
2055
+ concat(val[5])
2056
+ }
2057
+ | f_arg opt_args_tail
2058
+ {
2059
+ result = val[0].
2060
+ concat(val[1])
2061
+ }
2062
+ | f_optarg tCOMMA f_rest_arg opt_args_tail
2063
+ {
2064
+ result = val[0].
2065
+ concat(val[2]).
2066
+ concat(val[3])
2067
+ }
2068
+ | f_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_args_tail
2069
+ {
2070
+ result = val[0].
2071
+ concat(val[2]).
2072
+ concat(val[4]).
2073
+ concat(val[5])
2074
+ }
2075
+ | f_optarg opt_args_tail
2076
+ {
2077
+ result = val[0].
2078
+ concat(val[1])
2079
+ }
2080
+ | f_optarg tCOMMA f_arg opt_args_tail
2081
+ {
2082
+ result = val[0].
2083
+ concat(val[2]).
2084
+ concat(val[3])
2085
+ }
2086
+ | f_rest_arg opt_args_tail
2087
+ {
2088
+ result = val[0].
2089
+ concat(val[1])
2090
+ }
2091
+ | f_rest_arg tCOMMA f_arg opt_args_tail
2092
+ {
2093
+ result = val[0].
2094
+ concat(val[2]).
2095
+ concat(val[3])
2096
+ }
2097
+ | args_tail
2098
+ {
2099
+ result = val[0]
2100
+ }
2101
+ | # nothing
2102
+ {
2103
+ result = []
2104
+ }
2105
+
2106
+ f_bad_arg: tCONSTANT
2107
+ {
2108
+ diagnostic :error, :argument_const, nil, val[0]
2109
+ }
2110
+ | tIVAR
2111
+ {
2112
+ diagnostic :error, :argument_ivar, nil, val[0]
2113
+ }
2114
+ | tGVAR
2115
+ {
2116
+ diagnostic :error, :argument_gvar, nil, val[0]
2117
+ }
2118
+ | tCVAR
2119
+ {
2120
+ diagnostic :error, :argument_cvar, nil, val[0]
2121
+ }
2122
+
2123
+ f_norm_arg: f_bad_arg
2124
+ | tIDENTIFIER
2125
+ {
2126
+ @static_env.declare val[0][0]
2127
+
2128
+ result = val[0]
2129
+ }
2130
+
2131
+ f_arg_asgn: f_norm_arg
2132
+ {
2133
+ result = val[0]
2134
+ }
2135
+
2136
+ f_arg_item: f_arg_asgn
2137
+ {
2138
+ result = @builder.arg(val[0])
2139
+ }
2140
+ | tLPAREN f_margs rparen
2141
+ {
2142
+ result = @builder.multi_lhs(val[0], val[1], val[2])
2143
+ }
2144
+
2145
+ f_arg: f_arg_item
2146
+ {
2147
+ result = [ val[0] ]
2148
+ }
2149
+ | f_arg tCOMMA f_arg_item
2150
+ {
2151
+ result = val[0] << val[2]
2152
+ }
2153
+
2154
+ f_label: tLABEL
2155
+ {
2156
+ check_kwarg_name(val[0])
2157
+
2158
+ @static_env.declare val[0][0]
2159
+
2160
+ result = val[0]
2161
+ }
2162
+
2163
+ f_kw: f_label arg_value
2164
+ {
2165
+ result = @builder.kwoptarg(val[0], val[1])
2166
+ }
2167
+ | f_label
2168
+ {
2169
+ result = @builder.kwarg(val[0])
2170
+ }
2171
+
2172
+ f_block_kw: f_label primary_value
2173
+ {
2174
+ result = @builder.kwoptarg(val[0], val[1])
2175
+ }
2176
+ | f_label
2177
+ {
2178
+ result = @builder.kwarg(val[0])
2179
+ }
2180
+
2181
+ f_block_kwarg: f_block_kw
2182
+ {
2183
+ result = [ val[0] ]
2184
+ }
2185
+ | f_block_kwarg tCOMMA f_block_kw
2186
+ {
2187
+ result = val[0] << val[2]
2188
+ }
2189
+
2190
+ f_kwarg: f_kw
2191
+ {
2192
+ result = [ val[0] ]
2193
+ }
2194
+ | f_kwarg tCOMMA f_kw
2195
+ {
2196
+ result = val[0] << val[2]
2197
+ }
2198
+
2199
+ kwrest_mark: tPOW | tDSTAR
2200
+
2201
+ f_kwrest: kwrest_mark tIDENTIFIER
2202
+ {
2203
+ @static_env.declare val[1][0]
2204
+
2205
+ result = [ @builder.kwrestarg(val[0], val[1]) ]
2206
+ }
2207
+ | kwrest_mark
2208
+ {
2209
+ result = [ @builder.kwrestarg(val[0]) ]
2210
+ }
2211
+
2212
+ f_opt: f_arg_asgn tEQL arg_value
2213
+ {
2214
+ result = @builder.optarg(val[0], val[1], val[2])
2215
+ }
2216
+
2217
+ f_block_opt: f_arg_asgn tEQL primary_value
2218
+ {
2219
+ result = @builder.optarg(val[0], val[1], val[2])
2220
+ }
2221
+
2222
+ f_block_optarg: f_block_opt
2223
+ {
2224
+ result = [ val[0] ]
2225
+ }
2226
+ | f_block_optarg tCOMMA f_block_opt
2227
+ {
2228
+ result = val[0] << val[2]
2229
+ }
2230
+
2231
+ f_optarg: f_opt
2232
+ {
2233
+ result = [ val[0] ]
2234
+ }
2235
+ | f_optarg tCOMMA f_opt
2236
+ {
2237
+ result = val[0] << val[2]
2238
+ }
2239
+
2240
+ restarg_mark: tSTAR2 | tSTAR
2241
+
2242
+ f_rest_arg: restarg_mark tIDENTIFIER
2243
+ {
2244
+ @static_env.declare val[1][0]
2245
+
2246
+ result = [ @builder.restarg(val[0], val[1]) ]
2247
+ }
2248
+ | restarg_mark
2249
+ {
2250
+ result = [ @builder.restarg(val[0]) ]
2251
+ }
2252
+
2253
+ blkarg_mark: tAMPER2 | tAMPER
2254
+
2255
+ f_block_arg: blkarg_mark tIDENTIFIER
2256
+ {
2257
+ @static_env.declare val[1][0]
2258
+
2259
+ result = @builder.blockarg(val[0], val[1])
2260
+ }
2261
+
2262
+ opt_f_block_arg: tCOMMA f_block_arg
2263
+ {
2264
+ result = [ val[1] ]
2265
+ }
2266
+ |
2267
+ {
2268
+ result = []
2269
+ }
2270
+
2271
+ singleton: var_ref
2272
+ | tLPAREN2 expr rparen
2273
+ {
2274
+ result = val[1]
2275
+ }
2276
+
2277
+ assoc_list: # nothing
2278
+ {
2279
+ result = []
2280
+ }
2281
+ | assocs trailer
2282
+
2283
+ assocs: assoc
2284
+ {
2285
+ result = [ val[0] ]
2286
+ }
2287
+ | assocs tCOMMA assoc
2288
+ {
2289
+ result = val[0] << val[2]
2290
+ }
2291
+
2292
+ assoc: arg_value tASSOC arg_value
2293
+ {
2294
+ result = @builder.pair(val[0], val[1], val[2])
2295
+ }
2296
+ | tLABEL arg_value
2297
+ {
2298
+ result = @builder.pair_keyword(val[0], val[1])
2299
+ }
2300
+ | tSTRING_BEG string_contents tLABEL_END arg_value
2301
+ {
2302
+ result = @builder.pair_quoted(val[0], val[1], val[2], val[3])
2303
+ }
2304
+ | tDSTAR arg_value
2305
+ {
2306
+ result = @builder.kwsplat(val[0], val[1])
2307
+ }
2308
+
2309
+ operation: tIDENTIFIER | tCONSTANT | tFID
2310
+ operation2: tIDENTIFIER | tCONSTANT | tFID | op
2311
+ operation3: tIDENTIFIER | tFID | op
2312
+ dot_or_colon: call_op | tCOLON2
2313
+ call_op: tDOT
2314
+ {
2315
+ result = [:dot, val[0][1]]
2316
+ }
2317
+ | tANDDOT
2318
+ {
2319
+ result = [:anddot, val[0][1]]
2320
+ }
2321
+ opt_terms: | terms
2322
+ opt_nl: | tNL
2323
+ rparen: opt_nl tRPAREN
2324
+ {
2325
+ result = val[1]
2326
+ }
2327
+ rbracket: opt_nl tRBRACK
2328
+ {
2329
+ result = val[1]
2330
+ }
2331
+ trailer: | tNL | tCOMMA
2332
+
2333
+ term: tSEMI
2334
+ {
2335
+ yyerrok
2336
+ }
2337
+ | tNL
2338
+
2339
+ terms: term
2340
+ | terms tSEMI
2341
+
2342
+ none: # nothing
2343
+ {
2344
+ result = nil
2345
+ }
2346
+ end
2347
+
2348
+ ---- header
2349
+
2350
+ require 'parser'
2351
+
2352
+ Parser.check_for_encoding_support
2353
+
2354
+ ---- inner
2355
+
2356
+ def version
2357
+ 25
2358
+ end
2359
+
2360
+ def default_encoding
2361
+ Encoding::UTF_8
2362
+ end