lrama 0.6.8 → 0.6.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb427615ab5c822c3d3c83edb934e110b478fcf7e149058a15f06c48cbb85b0b
4
- data.tar.gz: 6b781dc123779bb4e51ec10185cc9215296629d6d3856e28c53c387388e45d4c
3
+ metadata.gz: 9143e179e798e02afb8e7b2b4b1dd64291ac9ec128c851a4b4e660c647531675
4
+ data.tar.gz: 34613495597d6d8c9334034d7167f34253ca97e910752b446fa6cc26f773a2ce
5
5
  SHA512:
6
- metadata.gz: 2c7962cff0ec5b31d0ef7e4c899e52258968c887bf42056775f1342d103badf93cff17a27a4b7fae390f4b451b75c3423408be21f2bcfb189b1acc6df7fcc6e7
7
- data.tar.gz: cdfc5d75fb400e2a0612f911845a99ce0c0bfce583089b202a5be25aecd69e73484bb4cf172fce392c65cee0e496b911b064706035f0baba2de227289c4667e3
6
+ metadata.gz: a54f5f7096bc3f3f984a7da54945cd3913d02a16882975e99c982f06a2dd70988dba461106f000b54cc26f06c0e62eb294c63d3d35dd606b0e63ff6a17b127d4
7
+ data.tar.gz: 007f8c7b8cf7ad1690f3b59e505f790273ddfacdab18ede2f1e3667a48309487739310d065fd7c54ee7656f9ee3791e2e1ed29e69726b69a4b861c083b8e5b4e
@@ -9,6 +9,28 @@ module Lrama
9
9
  @user_code = nil
10
10
  @precedence_sym = nil
11
11
  end
12
+
13
+ def resolve_user_code(bindings)
14
+ return unless user_code
15
+
16
+ var_to_arg = {}
17
+ symbols.each do |sym|
18
+ resolved_sym = bindings.resolve_symbol(sym)
19
+ if resolved_sym != sym
20
+ var_to_arg[sym.s_value] = resolved_sym.s_value
21
+ end
22
+ end
23
+
24
+ var_to_arg.each do |var, arg|
25
+ user_code.references.each do |ref|
26
+ if ref.name == var
27
+ ref.name = arg
28
+ end
29
+ end
30
+ end
31
+
32
+ return user_code
33
+ end
12
34
  end
13
35
  end
14
36
  end
@@ -2,12 +2,13 @@ module Lrama
2
2
  class Grammar
3
3
  class ParameterizingRule
4
4
  class Rule
5
- attr_reader :name, :parameters, :rhs_list, :required_parameters_count, :is_inline
5
+ attr_reader :name, :parameters, :rhs_list, :required_parameters_count, :tag, :is_inline
6
6
 
7
- def initialize(name, parameters, rhs_list, is_inline: false)
7
+ def initialize(name, parameters, rhs_list, tag: nil, is_inline: false)
8
8
  @name = name
9
9
  @parameters = parameters
10
10
  @rhs_list = rhs_list
11
+ @tag = tag
11
12
  @is_inline = is_inline
12
13
  @required_parameters_count = parameters.count
13
14
  end
@@ -130,12 +130,12 @@ module Lrama
130
130
  @replaced_rhs << lhs_token
131
131
  parameterizing_rule_resolver.created_lhs_list << lhs_token
132
132
  parameterizing_rule.rhs_list.each do |r|
133
- rule_builder = RuleBuilder.new(@rule_counter, @midrule_action_counter, lhs_tag: token.lhs_tag)
133
+ rule_builder = RuleBuilder.new(@rule_counter, @midrule_action_counter, lhs_tag: token.lhs_tag || parameterizing_rule.tag)
134
134
  rule_builder.lhs = lhs_token
135
135
  r.symbols.each { |sym| rule_builder.add_rhs(bindings.resolve_symbol(sym)) }
136
136
  rule_builder.line = line
137
137
  rule_builder.precedence_sym = r.precedence_sym
138
- rule_builder.user_code = r.user_code
138
+ rule_builder.user_code = r.resolve_user_code(bindings)
139
139
  rule_builder.complete_input
140
140
  rule_builder.setup_rules(parameterizing_rule_resolver)
141
141
  @rule_builders_for_parameterizing_rules << rule_builder
data/lib/lrama/parser.rb CHANGED
@@ -732,43 +732,43 @@ end
732
732
  ##### State transition tables begin ###
733
733
 
734
734
  racc_action_table = [
735
- 98, 51, 99, 163, 88, 79, 51, 51, 179, 163,
736
- 79, 79, 51, 162, 179, 156, 79, 165, 157, 51,
737
- 3, 50, 180, 165, 70, 51, 8, 50, 180, 79,
735
+ 98, 51, 99, 163, 88, 79, 51, 51, 180, 163,
736
+ 79, 79, 51, 162, 180, 156, 79, 165, 157, 51,
737
+ 3, 50, 181, 165, 70, 51, 8, 50, 181, 79,
738
738
  75, 51, 6, 50, 7, 161, 82, 47, 51, 51,
739
739
  50, 50, 89, 82, 82, 166, 41, 51, 100, 50,
740
- 181, 166, 82, 51, 48, 50, 181, 23, 25, 26,
740
+ 182, 166, 82, 51, 48, 50, 182, 23, 25, 26,
741
741
  27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
742
- 37, 38, 47, 51, 51, 50, 50, 93, 79, 196,
743
- 51, 51, 50, 50, 79, 196, 51, 51, 50, 50,
744
- 79, 196, 23, 25, 26, 27, 28, 29, 30, 31,
742
+ 37, 38, 47, 51, 51, 50, 50, 93, 79, 197,
743
+ 51, 51, 50, 50, 79, 197, 51, 51, 50, 50,
744
+ 79, 197, 23, 25, 26, 27, 28, 29, 30, 31,
745
745
  32, 33, 34, 35, 36, 37, 38, 9, 51, 54,
746
746
  50, 14, 15, 16, 17, 18, 19, 54, 54, 20,
747
747
  21, 22, 23, 25, 26, 27, 28, 29, 30, 31,
748
748
  32, 33, 34, 35, 36, 37, 38, 39, 51, 51,
749
- 50, 50, 79, 196, 51, 51, 50, 50, 79, 196,
750
- 51, 51, 50, 50, 79, 196, 51, 51, 50, 50,
749
+ 50, 50, 79, 197, 51, 51, 50, 50, 79, 197,
750
+ 51, 51, 50, 50, 79, 197, 51, 51, 50, 50,
751
751
  79, 79, 51, 51, 50, 50, 79, 79, 51, 51,
752
- 50, 50, 79, 79, 51, 51, 50, 206, 79, 79,
753
- 51, 51, 206, 206, 79, 79, 51, 51, 50, 50,
754
- 79, 186, 187, 188, 96, 186, 187, 188, 96, 216,
755
- 220, 228, 217, 217, 217, 51, 51, 50, 50, 186,
756
- 187, 188, 57, 58, 59, 60, 61, 62, 63, 64,
752
+ 50, 50, 79, 79, 51, 51, 50, 207, 79, 79,
753
+ 51, 51, 207, 207, 79, 79, 51, 51, 50, 50,
754
+ 79, 187, 188, 189, 96, 187, 188, 189, 96, 217,
755
+ 221, 229, 218, 218, 218, 51, 51, 50, 50, 187,
756
+ 188, 189, 57, 58, 59, 60, 61, 62, 63, 64,
757
757
  65, 66, 67, 90, 94, 96, 101, 101, 101, 103,
758
758
  109, 113, 114, 117, 117, 117, 117, 120, 47, 124,
759
759
  125, 127, 129, 130, 131, 132, 133, 136, 140, 141,
760
760
  142, 143, 146, 147, 148, 150, 160, 168, 170, 171,
761
- 172, 173, 174, 175, 176, 177, 146, 183, 191, 192,
762
- 160, 160, 203, 210, 211, 177, 214, 215, 210, 225,
763
- 210, 227, 96, 96, 210 ]
761
+ 172, 173, 174, 176, 177, 178, 146, 184, 192, 193,
762
+ 200, 160, 204, 176, 211, 160, 215, 216, 178, 176,
763
+ 226, 176, 228, 96, 96, 176 ]
764
764
 
765
765
  racc_action_check = [
766
- 49, 145, 49, 145, 39, 145, 159, 182, 159, 182,
767
- 159, 182, 200, 144, 200, 139, 200, 145, 139, 33,
768
- 1, 33, 159, 182, 33, 34, 3, 34, 200, 34,
766
+ 49, 145, 49, 145, 39, 145, 159, 183, 159, 183,
767
+ 159, 183, 201, 144, 201, 139, 201, 145, 139, 33,
768
+ 1, 33, 159, 183, 33, 34, 3, 34, 201, 34,
769
769
  34, 35, 2, 35, 2, 144, 35, 9, 36, 37,
770
770
  36, 37, 39, 36, 37, 145, 7, 38, 49, 38,
771
- 159, 182, 38, 15, 14, 15, 200, 9, 9, 9,
771
+ 159, 183, 38, 15, 14, 15, 201, 9, 9, 9,
772
772
  9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
773
773
  9, 9, 42, 69, 172, 69, 172, 42, 172, 172,
774
774
  173, 70, 173, 70, 173, 173, 174, 81, 174, 81,
@@ -776,22 +776,22 @@ racc_action_check = [
776
776
  42, 42, 42, 42, 42, 42, 42, 4, 82, 16,
777
777
  82, 4, 4, 4, 4, 4, 4, 17, 18, 4,
778
778
  4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
779
- 4, 4, 4, 4, 4, 4, 4, 4, 193, 109,
780
- 193, 109, 193, 193, 197, 111, 197, 111, 197, 197,
781
- 198, 117, 198, 117, 198, 198, 74, 75, 74, 75,
779
+ 4, 4, 4, 4, 4, 4, 4, 4, 194, 109,
780
+ 194, 109, 194, 194, 198, 111, 198, 111, 198, 198,
781
+ 199, 117, 199, 117, 199, 199, 74, 75, 74, 75,
782
782
  74, 75, 114, 116, 114, 116, 114, 116, 137, 166,
783
- 137, 166, 137, 166, 181, 183, 181, 183, 181, 183,
784
- 203, 215, 203, 215, 203, 215, 217, 119, 217, 119,
785
- 217, 164, 164, 164, 164, 178, 178, 178, 178, 207,
786
- 213, 222, 207, 213, 222, 134, 138, 134, 138, 208,
787
- 208, 208, 19, 20, 23, 25, 26, 27, 28, 29,
783
+ 137, 166, 137, 166, 182, 184, 182, 184, 182, 184,
784
+ 204, 216, 204, 216, 204, 216, 218, 119, 218, 119,
785
+ 218, 164, 164, 164, 164, 179, 179, 179, 179, 208,
786
+ 214, 223, 208, 214, 223, 134, 138, 134, 138, 209,
787
+ 209, 209, 19, 20, 23, 25, 26, 27, 28, 29,
788
788
  30, 31, 32, 40, 45, 46, 53, 55, 56, 57,
789
789
  68, 72, 73, 80, 85, 86, 87, 88, 89, 95,
790
790
  96, 102, 104, 105, 106, 107, 108, 112, 120, 121,
791
791
  122, 123, 124, 125, 126, 128, 141, 149, 151, 152,
792
792
  153, 154, 155, 156, 157, 158, 161, 163, 167, 169,
793
- 175, 177, 179, 185, 189, 199, 204, 206, 216, 219,
794
- 220, 221, 225, 227, 229 ]
793
+ 175, 178, 180, 186, 190, 200, 205, 207, 213, 217,
794
+ 220, 221, 222, 226, 228, 230 ]
795
795
 
796
796
  racc_action_pointer = [
797
797
  nil, 20, 22, 26, 98, nil, nil, 39, nil, 33,
@@ -809,18 +809,18 @@ racc_action_pointer = [
809
809
  243, 207, 239, 249, 206, 201, 252, nil, 253, nil,
810
810
  nil, nil, nil, nil, 202, nil, nil, 165, 203, -26,
811
811
  nil, 210, nil, nil, -10, -2, nil, nil, nil, 237,
812
- nil, 238, 239, 240, 241, 242, 221, 259, 220, 3,
812
+ nil, 238, 239, 240, 241, 242, 255, 259, 220, 3,
813
813
  nil, 220, nil, 227, 143, nil, 166, 248, nil, 249,
814
- nil, nil, 71, 77, 83, 224, nil, 225, 147, 232,
815
- nil, 171, 4, 172, nil, 265, nil, nil, nil, 272,
816
- nil, nil, nil, 135, nil, nil, nil, 141, 147, 230,
817
- 9, nil, nil, 177, 274, nil, 237, 158, 161, nil,
818
- nil, nil, nil, 159, nil, 178, 270, 183, nil, 259,
819
- 272, 261, 160, nil, nil, 231, nil, 232, nil, 276,
820
- nil, nil ]
814
+ nil, nil, 71, 77, 83, 228, nil, nil, 225, 147,
815
+ 232, nil, 171, 4, 172, nil, 265, nil, nil, nil,
816
+ 272, nil, nil, nil, 135, nil, nil, nil, 141, 147,
817
+ 229, 9, nil, nil, 177, 274, nil, 237, 158, 161,
818
+ nil, nil, nil, 233, 159, nil, 178, 271, 183, nil,
819
+ 260, 273, 262, 160, nil, nil, 232, nil, 233, nil,
820
+ 277, nil, nil ]
821
821
 
822
822
  racc_action_default = [
823
- -2, -138, -8, -138, -138, -3, -4, -138, 232, -138,
823
+ -2, -138, -8, -138, -138, -3, -4, -138, 233, -138,
824
824
  -9, -10, -11, -12, -138, -138, -138, -138, -138, -138,
825
825
  -138, -24, -25, -138, -29, -138, -138, -138, -138, -138,
826
826
  -138, -138, -138, -138, -138, -138, -138, -138, -138, -138,
@@ -835,75 +835,75 @@ racc_action_default = [
835
835
  -138, -138, -138, -138, -104, -138, -138, -86, -138, -22,
836
836
  -27, -31, -34, -37, -52, -55, -74, -77, -90, -138,
837
837
  -58, -62, -6, -125, -100, -101, -105, -121, -83, -138,
838
- -19, -138, -138, -138, -138, -138, -138, -138, -57, -60,
838
+ -19, -138, -138, -138, -138, -138, -136, -138, -57, -60,
839
839
  -63, -104, -103, -94, -120, -109, -138, -138, -87, -138,
840
- -23, -28, -138, -138, -138, -62, -59, -62, -120, -94,
841
- -67, -138, -102, -138, -106, -136, -113, -114, -115, -138,
842
- -112, -84, -20, -32, -131, -133, -134, -35, -38, -56,
843
- -61, -64, -65, -138, -138, -70, -94, -138, -116, -107,
844
- -137, -110, -132, -138, -68, -138, -136, -138, -118, -138,
845
- -136, -138, -138, -108, -117, -120, -66, -120, -119, -136,
846
- -69, -111 ]
840
+ -23, -28, -138, -138, -138, -138, -137, -59, -62, -120,
841
+ -94, -67, -138, -102, -138, -106, -136, -113, -114, -115,
842
+ -138, -112, -84, -20, -32, -131, -133, -134, -35, -38,
843
+ -62, -61, -64, -65, -138, -138, -70, -94, -138, -116,
844
+ -107, -110, -132, -56, -138, -68, -138, -136, -138, -118,
845
+ -138, -136, -138, -138, -108, -117, -120, -66, -120, -119,
846
+ -136, -69, -111 ]
847
847
 
848
848
  racc_goto_table = [
849
- 76, 95, 69, 52, 74, 118, 110, 209, 185, 145,
850
- 158, 1, 119, 212, 2, 4, 43, 212, 212, 42,
851
- 91, 72, 202, 84, 84, 84, 84, 80, 85, 86,
852
- 87, 5, 40, 207, 53, 55, 56, 122, 223, 111,
853
- 115, 76, 226, 118, 199, 116, 182, 138, 110, 92,
854
- 10, 231, 218, 213, 193, 197, 198, 72, 72, 11,
855
- 12, 13, 118, 49, 97, 222, 128, 169, 104, 84,
856
- 84, 110, 151, 105, 152, 106, 153, 107, 134, 154,
857
- 76, 108, 115, 155, 137, 68, 73, 112, 135, 139,
858
- 121, 200, 204, 221, 126, 167, 102, 72, 149, 72,
859
- 144, 189, 219, 115, 123, 84, nil, 84, nil, nil,
860
- nil, 164, nil, nil, nil, nil, nil, nil, nil, 184,
861
- nil, nil, 72, nil, nil, 178, 84, nil, nil, nil,
862
- nil, nil, 190, 201, nil, nil, nil, nil, nil, nil,
863
- nil, nil, nil, nil, nil, nil, nil, 205, 164, 208,
864
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
865
- nil, nil, nil, nil, nil, nil, 178, nil, nil, 208,
866
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
867
- 229, 208, 230, 224 ]
849
+ 76, 95, 69, 52, 74, 158, 110, 175, 118, 119,
850
+ 145, 208, 1, 212, 186, 2, 43, 212, 212, 4,
851
+ 42, 72, 91, 84, 84, 84, 84, 5, 40, 203,
852
+ 122, 214, 80, 85, 86, 87, 10, 210, 11, 111,
853
+ 115, 76, 12, 223, 138, 116, 118, 183, 110, 92,
854
+ 53, 55, 56, 194, 198, 199, 13, 72, 72, 219,
855
+ 49, 97, 128, 169, 213, 118, 104, 151, 224, 84,
856
+ 84, 110, 227, 105, 152, 106, 153, 107, 134, 154,
857
+ 76, 232, 115, 108, 137, 155, 68, 73, 112, 135,
858
+ 139, 121, 201, 205, 222, 126, 167, 72, 102, 72,
859
+ 149, 144, 190, 115, 220, 84, 123, 84, nil, nil,
860
+ nil, 164, nil, nil, nil, nil, nil, nil, nil, 185,
861
+ nil, nil, 72, nil, nil, 179, 84, nil, nil, nil,
862
+ nil, nil, 191, nil, 202, nil, nil, nil, nil, nil,
863
+ nil, nil, nil, nil, nil, nil, nil, nil, 206, 164,
864
+ 209, nil, nil, nil, nil, nil, nil, nil, nil, nil,
865
+ nil, nil, nil, nil, nil, nil, nil, 179, nil, nil,
866
+ 209, nil, nil, nil, nil, nil, nil, nil, nil, nil,
867
+ nil, 230, 209, 231, 225 ]
868
868
 
869
869
  racc_goto_check = [
870
- 42, 43, 33, 35, 49, 56, 34, 46, 44, 60,
871
- 39, 1, 55, 64, 2, 3, 57, 64, 64, 4,
872
- 5, 35, 44, 35, 35, 35, 35, 32, 32, 32,
873
- 32, 6, 7, 45, 15, 15, 15, 8, 46, 33,
874
- 42, 42, 46, 56, 39, 49, 60, 55, 34, 57,
875
- 9, 46, 44, 45, 21, 21, 21, 35, 35, 10,
876
- 11, 12, 56, 13, 14, 45, 16, 17, 18, 35,
877
- 35, 34, 19, 22, 23, 24, 25, 26, 33, 27,
878
- 42, 28, 42, 29, 49, 30, 31, 36, 37, 38,
879
- 40, 41, 47, 48, 51, 52, 53, 35, 54, 35,
880
- 59, 61, 62, 42, 63, 35, nil, 35, nil, nil,
881
- nil, 42, nil, nil, nil, nil, nil, nil, nil, 43,
882
- nil, nil, 35, nil, nil, 42, 35, nil, nil, nil,
883
- nil, nil, 42, 43, nil, nil, nil, nil, nil, nil,
884
- nil, nil, nil, nil, nil, nil, nil, 42, 42, 42,
885
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
886
- nil, nil, nil, nil, nil, nil, 42, nil, nil, 42,
887
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
888
- 43, 42, 43, 42 ]
870
+ 43, 44, 33, 35, 49, 40, 34, 39, 56, 55,
871
+ 60, 46, 1, 64, 45, 2, 57, 64, 64, 3,
872
+ 4, 35, 5, 35, 35, 35, 35, 6, 7, 45,
873
+ 8, 46, 32, 32, 32, 32, 9, 39, 10, 33,
874
+ 43, 43, 11, 46, 55, 49, 56, 60, 34, 57,
875
+ 15, 15, 15, 21, 21, 21, 12, 35, 35, 45,
876
+ 13, 14, 16, 17, 40, 56, 18, 19, 39, 35,
877
+ 35, 34, 39, 22, 23, 24, 25, 26, 33, 27,
878
+ 43, 39, 43, 28, 49, 29, 30, 31, 36, 37,
879
+ 38, 41, 42, 47, 48, 51, 52, 35, 53, 35,
880
+ 54, 59, 61, 43, 62, 35, 63, 35, nil, nil,
881
+ nil, 43, nil, nil, nil, nil, nil, nil, nil, 44,
882
+ nil, nil, 35, nil, nil, 43, 35, nil, nil, nil,
883
+ nil, nil, 43, nil, 44, nil, nil, nil, nil, nil,
884
+ nil, nil, nil, nil, nil, nil, nil, nil, 43, 43,
885
+ 43, nil, nil, nil, nil, nil, nil, nil, nil, nil,
886
+ nil, nil, nil, nil, nil, nil, nil, 43, nil, nil,
887
+ 43, nil, nil, nil, nil, nil, nil, nil, nil, nil,
888
+ nil, 44, 43, 44, 43 ]
889
889
 
890
890
  racc_goto_pointer = [
891
- nil, 11, 14, 13, 10, -22, 29, 26, -53, 46,
892
- 55, 56, 57, 48, 15, 18, -37, -83, 10, -57,
893
- nil, -118, 14, -56, 15, -55, 16, -53, 19, -50,
894
- 52, 52, -8, -31, -63, -12, 15, -24, -31, -131,
895
- 1, -86, -34, -45, -156, -150, -178, -88, -121, -30,
896
- nil, -7, -53, 42, -29, -70, -76, 7, nil, -24,
897
- -115, -64, -109, 11, -180 ]
891
+ nil, 12, 15, 17, 11, -20, 25, 22, -60, 32,
892
+ 34, 38, 52, 45, 12, 34, -41, -87, 8, -62,
893
+ nil, -119, 14, -56, 15, -55, 16, -53, 21, -48,
894
+ 53, 53, -3, -31, -63, -12, 16, -23, -30, -149,
895
+ -136, 2, -86, -34, -45, -150, -173, -88, -121, -30,
896
+ nil, -6, -52, 44, -27, -73, -73, 7, nil, -23,
897
+ -114, -63, -107, 13, -181 ]
898
898
 
899
899
  racc_goto_default = [
900
900
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
901
901
  45, nil, nil, nil, nil, nil, nil, nil, nil, nil,
902
902
  24, nil, nil, nil, nil, nil, nil, nil, nil, nil,
903
903
  nil, nil, nil, nil, 71, 77, nil, nil, nil, nil,
904
- 46, 159, 195, nil, nil, nil, nil, nil, nil, nil,
904
+ nil, 46, 159, 196, nil, nil, nil, nil, nil, nil,
905
905
  78, nil, nil, nil, nil, 81, 83, nil, 44, nil,
906
- nil, nil, nil, nil, 194 ]
906
+ nil, nil, nil, nil, 195 ]
907
907
 
908
908
  racc_reduce_table = [
909
909
  0, 0, :racc_error,
@@ -962,21 +962,21 @@ racc_reduce_table = [
962
962
  1, 87, :_reduce_53,
963
963
  2, 87, :_reduce_54,
964
964
  3, 88, :_reduce_55,
965
- 7, 65, :_reduce_56,
965
+ 8, 65, :_reduce_56,
966
966
  5, 66, :_reduce_57,
967
967
  1, 92, :_reduce_58,
968
968
  3, 92, :_reduce_59,
969
- 1, 93, :_reduce_60,
970
- 3, 93, :_reduce_61,
971
- 0, 95, :_reduce_62,
972
- 1, 95, :_reduce_63,
973
- 3, 95, :_reduce_64,
974
- 3, 95, :_reduce_65,
975
- 6, 95, :_reduce_66,
969
+ 1, 94, :_reduce_60,
970
+ 3, 94, :_reduce_61,
971
+ 0, 96, :_reduce_62,
972
+ 1, 96, :_reduce_63,
973
+ 3, 96, :_reduce_64,
974
+ 3, 96, :_reduce_65,
975
+ 6, 96, :_reduce_66,
976
976
  0, 101, :_reduce_67,
977
977
  0, 102, :_reduce_68,
978
- 7, 95, :_reduce_69,
979
- 3, 95, :_reduce_70,
978
+ 7, 96, :_reduce_69,
979
+ 3, 96, :_reduce_70,
980
980
  0, 90, :_reduce_none,
981
981
  1, 90, :_reduce_none,
982
982
  0, 91, :_reduce_none,
@@ -986,8 +986,8 @@ racc_reduce_table = [
986
986
  3, 85, :_reduce_77,
987
987
  1, 103, :_reduce_78,
988
988
  2, 103, :_reduce_79,
989
- 1, 96, :_reduce_none,
990
- 1, 96, :_reduce_none,
989
+ 1, 97, :_reduce_none,
990
+ 1, 97, :_reduce_none,
991
991
  0, 105, :_reduce_82,
992
992
  0, 106, :_reduce_83,
993
993
  6, 69, :_reduce_84,
@@ -1019,16 +1019,16 @@ racc_reduce_table = [
1019
1019
  0, 116, :_reduce_110,
1020
1020
  8, 114, :_reduce_111,
1021
1021
  3, 114, :_reduce_112,
1022
- 1, 98, :_reduce_113,
1023
- 1, 98, :_reduce_114,
1024
- 1, 98, :_reduce_115,
1025
- 1, 99, :_reduce_116,
1026
- 3, 99, :_reduce_117,
1027
- 2, 99, :_reduce_118,
1028
- 4, 99, :_reduce_119,
1029
- 0, 97, :_reduce_none,
1030
- 3, 97, :_reduce_121,
1031
- 1, 94, :_reduce_none,
1022
+ 1, 99, :_reduce_113,
1023
+ 1, 99, :_reduce_114,
1024
+ 1, 99, :_reduce_115,
1025
+ 1, 100, :_reduce_116,
1026
+ 3, 100, :_reduce_117,
1027
+ 2, 100, :_reduce_118,
1028
+ 4, 100, :_reduce_119,
1029
+ 0, 98, :_reduce_none,
1030
+ 3, 98, :_reduce_121,
1031
+ 1, 95, :_reduce_none,
1032
1032
  0, 59, :_reduce_none,
1033
1033
  0, 117, :_reduce_124,
1034
1034
  3, 59, :_reduce_125,
@@ -1042,12 +1042,12 @@ racc_reduce_table = [
1042
1042
  1, 118, :_reduce_none,
1043
1043
  1, 118, :_reduce_none,
1044
1044
  1, 104, :_reduce_135,
1045
- 0, 100, :_reduce_none,
1046
- 1, 100, :_reduce_none ]
1045
+ 0, 93, :_reduce_none,
1046
+ 1, 93, :_reduce_none ]
1047
1047
 
1048
1048
  racc_reduce_n = 138
1049
1049
 
1050
- racc_shift_n = 232
1050
+ racc_shift_n = 233
1051
1051
 
1052
1052
  racc_token_table = {
1053
1053
  false => 0,
@@ -1220,6 +1220,7 @@ Racc_token_to_s_table = [
1220
1220
  "int_opt",
1221
1221
  "alias",
1222
1222
  "rule_args",
1223
+ "tag_opt",
1223
1224
  "rule_rhs_list",
1224
1225
  "id_colon",
1225
1226
  "rule_rhs",
@@ -1227,7 +1228,6 @@ Racc_token_to_s_table = [
1227
1228
  "named_ref_opt",
1228
1229
  "parameterizing_suffix",
1229
1230
  "parameterizing_args",
1230
- "tag_opt",
1231
1231
  "@15",
1232
1232
  "@16",
1233
1233
  "symbol_declaration_list",
@@ -1666,7 +1666,7 @@ module_eval(<<'.,.,', 'parser.y', 232)
1666
1666
 
1667
1667
  module_eval(<<'.,.,', 'parser.y', 236)
1668
1668
  def _reduce_56(val, _values, result)
1669
- rule = Grammar::ParameterizingRule::Rule.new(val[1].s_value, val[3], val[6])
1669
+ rule = Grammar::ParameterizingRule::Rule.new(val[1].s_value, val[3], val[7], tag: val[5])
1670
1670
  @grammar.add_parameterizing_rule(rule)
1671
1671
 
1672
1672
  result
data/lib/lrama/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lrama
2
- VERSION = "0.6.8".freeze
2
+ VERSION = "0.6.9".freeze
3
3
  end
data/parser.y CHANGED
@@ -232,9 +232,9 @@ rule
232
232
 
233
233
  token_declaration: id int_opt alias { result = val }
234
234
 
235
- rule_declaration: "%rule" IDENTIFIER "(" rule_args ")" ":" rule_rhs_list
235
+ rule_declaration: "%rule" IDENTIFIER "(" rule_args ")" tag_opt ":" rule_rhs_list
236
236
  {
237
- rule = Grammar::ParameterizingRule::Rule.new(val[1].s_value, val[3], val[6])
237
+ rule = Grammar::ParameterizingRule::Rule.new(val[1].s_value, val[3], val[7], tag: val[5])
238
238
  @grammar.add_parameterizing_rule(rule)
239
239
  }
240
240
 
@@ -7,6 +7,7 @@ module Lrama
7
7
  attr_reader precedence_sym: Lexer::Token?
8
8
 
9
9
  def initialize: () -> void
10
+ def resolve_user_code: (Grammar::Binding bindings) -> Lexer::Token::UserCode?
10
11
  end
11
12
  end
12
13
  end
@@ -6,9 +6,10 @@ module Lrama
6
6
  attr_reader parameters: Array[Lexer::Token]
7
7
  attr_reader rhs_list: Array[Grammar::ParameterizingRule::Rhs]
8
8
  attr_reader required_parameters_count: Integer
9
+ attr_reader tag: Lexer::Token::Tag?
9
10
  attr_reader is_inline: bool
10
11
 
11
- def initialize: (String name, Array[Lexer::Token] parameters, Array[Grammar::ParameterizingRule::Rhs] rhs_list, ?is_inline: bool) -> void
12
+ def initialize: (String name, Array[Lexer::Token] parameters, Array[Grammar::ParameterizingRule::Rhs] rhs_list, ?tag: Lexer::Token::Tag, ?is_inline: bool) -> void
12
13
  end
13
14
  end
14
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lrama
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.8
4
+ version: 0.6.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuichiro Kaneko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-29 00:00:00.000000000 Z
11
+ date: 2024-05-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: LALR (1) parser generator written by Ruby
14
14
  email: