parser 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/parser/ruby19.y CHANGED
@@ -44,14 +44,14 @@ preclow
44
44
 
45
45
  rule
46
46
 
47
- program: top_compstmt
47
+ program: top_compstmt
48
48
 
49
49
  top_compstmt: top_stmts opt_terms
50
50
  {
51
51
  result = @builder.compstmt(val[0])
52
52
  }
53
53
 
54
- top_stmts: none
54
+ top_stmts: # nothing
55
55
  {
56
56
  result = []
57
57
  }
@@ -69,15 +69,9 @@ rule
69
69
  }
70
70
 
71
71
  top_stmt: stmt
72
- | klBEGIN
72
+ | klBEGIN tLCURLY top_compstmt tRCURLY
73
73
  {
74
- @static_env.extend_static
75
- }
76
- tLCURLY top_compstmt tRCURLY
77
- {
78
- @static_env.unextend
79
-
80
- result = @builder.preexe(val[0], val[2], val[3], val[4])
74
+ result = @builder.preexe(val[0], val[1], val[2], val[3])
81
75
  }
82
76
 
83
77
  bodystmt: compstmt opt_rescue opt_else opt_ensure
@@ -101,7 +95,7 @@ rule
101
95
  result = @builder.compstmt(val[0])
102
96
  }
103
97
 
104
- stmts: none
98
+ stmts: # nothing
105
99
  {
106
100
  result = []
107
101
  }
@@ -846,13 +840,13 @@ rule
846
840
  result = val
847
841
  }
848
842
 
849
- opt_paren_args: none
843
+ opt_paren_args: # nothing
850
844
  {
851
845
  result = [ nil, [], nil ]
852
846
  }
853
847
  | paren_args
854
848
 
855
- opt_call_args: none
849
+ opt_call_args: # nothing
856
850
  {
857
851
  result = []
858
852
  }
@@ -895,7 +889,7 @@ rule
895
889
  result = @lexer.cmdarg.dup
896
890
  @lexer.cmdarg.push(true)
897
891
  }
898
- call_args
892
+ call_args
899
893
  {
900
894
  @lexer.cmdarg = val[0]
901
895
 
@@ -911,7 +905,7 @@ rule
911
905
  {
912
906
  result = [ val[1] ]
913
907
  }
914
- | none
908
+ | # nothing
915
909
  {
916
910
  result = []
917
911
  }
@@ -968,10 +962,7 @@ rule
968
962
  }
969
963
  opt_nl tRPAREN
970
964
  {
971
- # TODO better location info here
972
- diagnostic :warning, :grouped_expression, val[0]
973
-
974
- result = @builder.parenthesize(val[0], val[1], val[3])
965
+ result = @builder.parenthesize(val[0], val[1], val[4])
975
966
  }
976
967
  | tLPAREN compstmt tRPAREN
977
968
  {
@@ -1399,11 +1390,14 @@ rule
1399
1390
  result = [ val[0] ]
1400
1391
  }
1401
1392
 
1402
- opt_block_param: none
1393
+ opt_block_param: # nothing
1403
1394
  {
1404
1395
  result = @builder.args(nil, [], nil)
1405
1396
  }
1406
1397
  | block_param_def
1398
+ {
1399
+ @lexer.state = :expr_value
1400
+ }
1407
1401
 
1408
1402
  block_param_def: tPIPE opt_bv_decl tPIPE
1409
1403
  {
@@ -1418,7 +1412,7 @@ rule
1418
1412
  result = @builder.args(val[0], val[1].concat(val[2]), val[3])
1419
1413
  }
1420
1414
 
1421
- opt_bv_decl: none
1415
+ opt_bv_decl: # nothing
1422
1416
  {
1423
1417
  result = []
1424
1418
  }
@@ -1558,7 +1552,7 @@ rule
1558
1552
  {
1559
1553
  @static_env.extend_dynamic
1560
1554
  }
1561
- opt_block_param compstmt kEND
1555
+ opt_block_param compstmt kEND
1562
1556
  {
1563
1557
  result = [ val[0], val[2], val[3], val[4] ]
1564
1558
 
@@ -1653,40 +1647,35 @@ rule
1653
1647
  result = @builder.regexp_compose(val[0], val[1], val[2], opts)
1654
1648
  }
1655
1649
 
1656
- words: tWORDS_BEG tSPACE tSTRING_END
1657
- { # :nocov: TODO: unused with Ragel lexer; remove?
1658
- result = @builder.words_compose(val[0], [], val[2])
1659
- }
1660
- | tWORDS_BEG word_list tSTRING_END
1650
+ words: tWORDS_BEG word_list tSTRING_END
1661
1651
  {
1662
1652
  result = @builder.words_compose(val[0], val[1], val[2])
1663
1653
  }
1664
1654
 
1665
- word_list: none
1655
+ word_list: # nothing
1666
1656
  {
1667
1657
  result = []
1668
1658
  }
1669
1659
  | word_list word tSPACE
1670
1660
  {
1671
- result = val[0] << val[1]
1661
+ result = val[0] << @builder.word(val[1])
1672
1662
  }
1673
1663
 
1674
1664
  word: string_content
1665
+ {
1666
+ result = [ val[0] ]
1667
+ }
1675
1668
  | word string_content
1676
- { # :nocov: TODO: test this rule, remove if unused
1677
- raise "unused 'word string_content'"
1669
+ {
1670
+ result = val[0] << val[1]
1678
1671
  }
1679
1672
 
1680
- qwords: tQWORDS_BEG tSPACE tSTRING_END
1681
- { # :nocov: TODO: unused with Ragel lexer; remove?
1682
- result = @builder.words_compose(val[0], [], val[2])
1683
- }
1684
- | tQWORDS_BEG qword_list tSTRING_END
1673
+ qwords: tQWORDS_BEG qword_list tSTRING_END
1685
1674
  {
1686
1675
  result = @builder.words_compose(val[0], val[1], val[2])
1687
1676
  }
1688
1677
 
1689
- qword_list: none
1678
+ qword_list: # nothing
1690
1679
  {
1691
1680
  result = []
1692
1681
  }
@@ -1695,7 +1684,7 @@ rule
1695
1684
  result = val[0] << @builder.string(val[1])
1696
1685
  }
1697
1686
 
1698
- string_contents: none
1687
+ string_contents: # nothing
1699
1688
  {
1700
1689
  result = []
1701
1690
  }
@@ -1704,7 +1693,7 @@ rule
1704
1693
  result = val[0] << val[1]
1705
1694
  }
1706
1695
 
1707
- xstring_contents: none # TODO: replace with string_contents?
1696
+ xstring_contents: # nothing
1708
1697
  {
1709
1698
  result = []
1710
1699
  }
@@ -1713,7 +1702,7 @@ xstring_contents: none # TODO: replace with string_contents?
1713
1702
  result = val[0] << val[1]
1714
1703
  }
1715
1704
 
1716
- regexp_contents: none
1705
+ regexp_contents: # nothing
1717
1706
  {
1718
1707
  result = []
1719
1708
  }
@@ -1758,17 +1747,11 @@ regexp_contents: none
1758
1747
  | backref
1759
1748
 
1760
1749
 
1761
- symbol: tSYMBEG sym
1762
- { # :nocov: TODO: not used, delete.
1763
- result = nil
1764
- }
1765
- | tSYMBOL
1750
+ symbol: tSYMBOL
1766
1751
  {
1767
1752
  result = @builder.symbol(val[0])
1768
1753
  }
1769
1754
 
1770
- sym: fname | tIVAR | tGVAR | tCVAR
1771
-
1772
1755
  dsym: tSYMBEG xstring_contents tSTRING_END
1773
1756
  {
1774
1757
  result = @builder.symbol_compose(val[0], val[1], val[2])
@@ -1886,11 +1869,13 @@ keyword_variable: kNIL
1886
1869
  {
1887
1870
  result = @builder.args(val[0], val[1], val[2])
1888
1871
 
1889
- @lexer.state = :expr_beg
1872
+ @lexer.state = :expr_value
1890
1873
  }
1891
1874
  | f_args term
1892
1875
  {
1893
1876
  result = @builder.args(nil, val[0], nil)
1877
+
1878
+ @lexer.state = :expr_value
1894
1879
  }
1895
1880
 
1896
1881
  f_args: f_arg tCOMMA f_optarg tCOMMA f_rest_arg opt_f_block_arg
@@ -2081,7 +2066,7 @@ keyword_variable: kNIL
2081
2066
  {
2082
2067
  result = [ val[1] ]
2083
2068
  }
2084
- |
2069
+ | # nothing
2085
2070
  {
2086
2071
  result = []
2087
2072
  }
@@ -2092,7 +2077,7 @@ keyword_variable: kNIL
2092
2077
  result = val[1]
2093
2078
  }
2094
2079
 
2095
- assoc_list: none
2080
+ assoc_list: # nothing
2096
2081
  {
2097
2082
  result = []
2098
2083
  }