lrama 0.5.9 → 0.5.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yaml +5 -0
  3. data/.gitignore +7 -4
  4. data/Gemfile +9 -5
  5. data/Rakefile +13 -0
  6. data/Steepfile +9 -3
  7. data/lib/lrama/context.rb +1 -3
  8. data/lib/lrama/counterexamples/path.rb +0 -46
  9. data/lib/lrama/counterexamples/production_path.rb +17 -0
  10. data/lib/lrama/counterexamples/start_path.rb +21 -0
  11. data/lib/lrama/counterexamples/transition_path.rb +17 -0
  12. data/lib/lrama/counterexamples.rb +3 -0
  13. data/lib/lrama/grammar/code/initial_action_code.rb +28 -0
  14. data/lib/lrama/grammar/code/no_reference_code.rb +24 -0
  15. data/lib/lrama/grammar/code/printer_code.rb +34 -0
  16. data/lib/lrama/grammar/code/rule_action.rb +62 -0
  17. data/lib/lrama/grammar/code.rb +9 -93
  18. data/lib/lrama/grammar/counter.rb +15 -0
  19. data/lib/lrama/grammar/error_token.rb +3 -3
  20. data/lib/lrama/grammar/parameterizing_rules/builder/base.rb +28 -0
  21. data/lib/lrama/grammar/parameterizing_rules/builder/list.rb +20 -0
  22. data/lib/lrama/grammar/parameterizing_rules/builder/nonempty_list.rb +20 -0
  23. data/lib/lrama/grammar/parameterizing_rules/builder/option.rb +20 -0
  24. data/lib/lrama/grammar/parameterizing_rules/builder/separated_list.rb +28 -0
  25. data/lib/lrama/grammar/parameterizing_rules/builder/separated_nonempty_list.rb +27 -0
  26. data/lib/lrama/grammar/parameterizing_rules/builder.rb +43 -0
  27. data/lib/lrama/grammar/printer.rb +3 -3
  28. data/lib/lrama/grammar/reference.rb +7 -16
  29. data/lib/lrama/grammar/rule.rb +18 -2
  30. data/lib/lrama/grammar/rule_builder.rb +179 -0
  31. data/lib/lrama/grammar.rb +109 -324
  32. data/lib/lrama/lexer/location.rb +22 -0
  33. data/lib/lrama/lexer/token/parameterizing.rb +18 -3
  34. data/lib/lrama/lexer/token/tag.rb +4 -0
  35. data/lib/lrama/lexer/token/user_code.rb +54 -4
  36. data/lib/lrama/lexer/token.rb +22 -4
  37. data/lib/lrama/lexer.rb +31 -29
  38. data/lib/lrama/options.rb +1 -2
  39. data/lib/lrama/output.rb +2 -2
  40. data/lib/lrama/parser.rb +420 -343
  41. data/lib/lrama/report/profile.rb +1 -12
  42. data/lib/lrama/version.rb +1 -1
  43. data/parser.y +106 -49
  44. data/rbs_collection.lock.yaml +5 -1
  45. data/rbs_collection.yaml +1 -0
  46. data/sig/lrama/grammar/code/printer_code.rbs +15 -0
  47. data/sig/lrama/grammar/code.rbs +24 -0
  48. data/sig/lrama/grammar/counter.rbs +11 -0
  49. data/sig/lrama/grammar/parameterizing_rules/builder.rbs +10 -0
  50. data/sig/lrama/grammar/precedence.rbs +11 -0
  51. data/sig/lrama/grammar/printer.rbs +11 -0
  52. data/sig/lrama/grammar/reference.rbs +5 -5
  53. data/sig/lrama/grammar/rule.rbs +13 -0
  54. data/sig/lrama/grammar/rule_builder.rbs +41 -0
  55. data/sig/lrama/lexer/location.rbs +14 -0
  56. data/sig/lrama/lexer/token/parameterizing.rbs +7 -0
  57. data/sig/lrama/lexer/token/tag.rbs +1 -0
  58. data/sig/lrama/lexer/token/user_code.rbs +8 -1
  59. data/sig/lrama/lexer/token.rbs +8 -3
  60. data/sig/stdlib/strscan/string_scanner.rbs +5 -0
  61. data/template/bison/yacc.c +5 -0
  62. metadata +29 -2
data/lib/lrama/parser.rb CHANGED
@@ -658,7 +658,7 @@ end
658
658
  module Lrama
659
659
  class Parser < Racc::Parser
660
660
 
661
- module_eval(<<'...end parser.y/module_eval...', 'parser.y', 383)
661
+ module_eval(<<'...end parser.y/module_eval...', 'parser.y', 418)
662
662
 
663
663
  include Lrama::Report::Duration
664
664
 
@@ -666,18 +666,18 @@ def initialize(text, path, debug = false)
666
666
  @text = text
667
667
  @path = path
668
668
  @yydebug = debug
669
+ @rule_counter = Lrama::Grammar::Counter.new(0)
670
+ @midrule_action_counter = Lrama::Grammar::Counter.new(1)
669
671
  end
670
672
 
671
673
  def parse
672
674
  report_duration(:parse) do
673
675
  @lexer = Lrama::Lexer.new(@text)
674
- @grammar = Lrama::Grammar.new
676
+ @grammar = Lrama::Grammar.new(@rule_counter)
675
677
  @precedence_number = 0
676
678
  reset_precs
677
679
  do_parse
678
680
  @grammar.prepare
679
- @grammar.compute_nullable
680
- @grammar.compute_first_set
681
681
  @grammar.validate!
682
682
  @grammar
683
683
  end
@@ -688,18 +688,40 @@ def next_token
688
688
  end
689
689
 
690
690
  def on_error(error_token_id, error_value, value_stack)
691
- if error_value.respond_to?(:line) && error_value.respond_to?(:column)
692
- line = error_value.line
693
- first_column = error_value.column
691
+ if error_value.is_a?(Lrama::Lexer::Token)
692
+ line = error_value.first_line
693
+ first_column = error_value.first_column
694
+ last_column = error_value.last_column
695
+ value = "'#{error_value.s_value}'"
694
696
  else
695
697
  line = @lexer.line
696
698
  first_column = @lexer.head_column
699
+ last_column = @lexer.column
700
+ value = error_value.inspect
697
701
  end
698
702
 
699
703
  raise ParseError, <<~ERROR
700
- #{@path}:#{line}:#{first_column}: parse error on value #{error_value.inspect} (#{token_to_str(error_token_id) || '?'})
704
+ #{@path}:#{line}:#{first_column}: parse error on value #{value} (#{token_to_str(error_token_id) || '?'})
701
705
  #{@text.split("\n")[line - 1]}
702
- #{carrets(first_column)}
706
+ #{carrets(first_column, last_column)}
707
+ ERROR
708
+ end
709
+
710
+ def on_action_error(error_message, error_value)
711
+ if error_value.is_a?(Lrama::Lexer::Token)
712
+ line = error_value.first_line
713
+ first_column = error_value.first_column
714
+ last_column = error_value.last_column
715
+ else
716
+ line = @lexer.line
717
+ first_column = @lexer.head_column
718
+ last_column = @lexer.column
719
+ end
720
+
721
+ raise ParseError, <<~ERROR
722
+ #{@path}:#{line}: #{error_message}
723
+ #{@text.split("\n")[line - 1]}
724
+ #{carrets(first_column, last_column)}
703
725
  ERROR
704
726
  end
705
727
 
@@ -720,255 +742,266 @@ def end_c_declaration
720
742
  @lexer.end_symbol = nil
721
743
  end
722
744
 
723
- def carrets(first_column)
724
- ' ' * (first_column + 1) + '^' * (@lexer.column - first_column)
745
+ def carrets(first_column, last_column)
746
+ ' ' * (first_column + 1) + '^' * (last_column - first_column)
725
747
  end
726
748
  ...end parser.y/module_eval...
727
749
  ##### State transition tables begin ###
728
750
 
729
751
  racc_action_table = [
730
- 84, 137, 85, 3, 6, 43, 7, 42, 39, 67,
731
- 43, 8, 42, 136, 67, 43, 43, 42, 42, 33,
732
- 58, 142, 43, 43, 42, 42, 142, 21, 23, 24,
733
- 25, 26, 27, 28, 29, 30, 31, 86, 139, 140,
734
- 141, 143, 39, 139, 140, 141, 143, 79, 43, 43,
735
- 42, 42, 67, 63, 70, 43, 43, 42, 42, 40,
736
- 70, 21, 23, 24, 25, 26, 27, 28, 29, 30,
737
- 31, 9, 45, 47, 14, 12, 13, 15, 16, 17,
738
- 18, 47, 47, 19, 20, 21, 23, 24, 25, 26,
739
- 27, 28, 29, 30, 31, 43, 43, 42, 42, 50,
740
- 70, 70, 43, 43, 42, 42, 67, 161, 43, 43,
741
- 42, 42, 67, 161, 43, 43, 42, 42, 67, 161,
742
- 43, 43, 42, 42, 67, 161, 43, 43, 42, 42,
743
- 67, 161, 43, 43, 42, 42, 67, 161, 43, 43,
744
- 42, 42, 67, 67, 43, 43, 42, 42, 67, 67,
745
- 43, 43, 42, 42, 67, 67, 43, 43, 42, 42,
746
- 43, 43, 42, 42, 51, 52, 53, 54, 55, 76,
747
- 80, 82, 87, 87, 87, 89, 95, 99, 100, 108,
748
- 109, 111, 113, 114, 115, 116, 117, 120, 122, 123,
749
- 126, 127, 128, 130, 145, 147, 148, 149, 150, 151,
750
- 126, 82, 156, 157, 164, 167, 82 ]
752
+ 84, 43, 85, 139, 39, 67, 43, 138, 139, 153,
753
+ 67, 171, 172, 154, 155, 156, 43, 141, 42, 137,
754
+ 3, 58, 141, 21, 23, 24, 25, 26, 27, 28,
755
+ 29, 30, 31, 39, 6, 8, 7, 142, 79, 43,
756
+ 86, 42, 142, 67, 63, 43, 43, 42, 42, 33,
757
+ 70, 70, 21, 23, 24, 25, 26, 27, 28, 29,
758
+ 30, 31, 9, 40, 45, 14, 12, 13, 15, 16,
759
+ 17, 18, 47, 47, 19, 20, 21, 23, 24, 25,
760
+ 26, 27, 28, 29, 30, 31, 43, 43, 42, 42,
761
+ 47, 70, 70, 43, 43, 42, 42, 67, 165, 43,
762
+ 43, 42, 42, 67, 165, 43, 43, 42, 42, 67,
763
+ 165, 43, 43, 42, 42, 67, 165, 43, 43, 42,
764
+ 42, 67, 165, 43, 43, 42, 42, 67, 165, 43,
765
+ 43, 42, 42, 67, 67, 43, 43, 42, 42, 67,
766
+ 67, 43, 43, 42, 42, 67, 67, 43, 43, 42,
767
+ 42, 67, 67, 43, 43, 42, 42, 43, 43, 42,
768
+ 42, 43, 50, 42, 51, 52, 53, 54, 55, 76,
769
+ 80, 82, 87, 87, 87, 89, 95, 99, 100, 103,
770
+ 103, 103, 103, 108, 109, 111, 113, 114, 115, 116,
771
+ 117, 120, 123, 124, 127, 128, 129, 131, 144, 146,
772
+ 147, 148, 149, 150, 127, 82, 160, 161, 169, 175,
773
+ 176, 82 ]
751
774
 
752
775
  racc_action_check = [
753
- 41, 124, 41, 1, 2, 125, 2, 125, 9, 125,
754
- 152, 3, 152, 124, 152, 26, 13, 26, 13, 7,
755
- 26, 125, 57, 58, 57, 58, 152, 9, 9, 9,
756
- 9, 9, 9, 9, 9, 9, 9, 41, 125, 125,
757
- 125, 125, 34, 152, 152, 152, 152, 34, 27, 28,
758
- 27, 28, 27, 27, 28, 29, 68, 29, 68, 12,
759
- 29, 34, 34, 34, 34, 34, 34, 34, 34, 34,
760
- 34, 4, 14, 15, 4, 4, 4, 4, 4, 4,
761
- 4, 16, 17, 4, 4, 4, 4, 4, 4, 4,
762
- 4, 4, 4, 4, 4, 30, 31, 30, 31, 18,
763
- 30, 31, 149, 69, 149, 69, 149, 149, 150, 70,
764
- 150, 70, 150, 150, 151, 73, 151, 73, 151, 151,
765
- 158, 74, 158, 74, 158, 158, 162, 75, 162, 75,
766
- 162, 162, 163, 95, 163, 95, 163, 163, 62, 63,
767
- 62, 63, 62, 63, 100, 102, 100, 102, 100, 102,
768
- 121, 143, 121, 143, 121, 143, 97, 103, 97, 103,
769
- 105, 118, 105, 118, 19, 21, 23, 24, 25, 32,
770
- 37, 38, 46, 48, 49, 50, 56, 60, 61, 81,
771
- 82, 88, 90, 91, 92, 93, 94, 98, 106, 107,
772
- 108, 109, 110, 112, 129, 131, 132, 133, 134, 135,
773
- 136, 138, 144, 146, 154, 166, 167 ]
776
+ 41, 126, 41, 126, 9, 126, 151, 125, 151, 139,
777
+ 151, 168, 168, 139, 139, 139, 26, 126, 26, 125,
778
+ 1, 26, 151, 9, 9, 9, 9, 9, 9, 9,
779
+ 9, 9, 9, 34, 2, 3, 2, 126, 34, 27,
780
+ 41, 27, 151, 27, 27, 28, 29, 28, 29, 7,
781
+ 28, 29, 34, 34, 34, 34, 34, 34, 34, 34,
782
+ 34, 34, 4, 12, 14, 4, 4, 4, 4, 4,
783
+ 4, 4, 15, 16, 4, 4, 4, 4, 4, 4,
784
+ 4, 4, 4, 4, 4, 4, 30, 31, 30, 31,
785
+ 17, 30, 31, 148, 13, 148, 13, 148, 148, 149,
786
+ 57, 149, 57, 149, 149, 150, 58, 150, 58, 150,
787
+ 150, 162, 69, 162, 69, 162, 162, 166, 70, 166,
788
+ 70, 166, 166, 167, 95, 167, 95, 167, 167, 62,
789
+ 63, 62, 63, 62, 63, 100, 102, 100, 102, 100,
790
+ 102, 121, 142, 121, 142, 121, 142, 153, 172, 153,
791
+ 172, 153, 172, 97, 103, 97, 103, 105, 118, 105,
792
+ 118, 122, 18, 122, 19, 21, 23, 24, 25, 32,
793
+ 37, 38, 46, 48, 49, 50, 56, 60, 61, 68,
794
+ 73, 74, 75, 81, 82, 88, 90, 91, 92, 93,
795
+ 94, 98, 106, 107, 108, 109, 110, 112, 130, 132,
796
+ 133, 134, 135, 136, 137, 140, 143, 145, 158, 173,
797
+ 174, 175 ]
774
798
 
775
799
  racc_action_pointer = [
776
- nil, 3, -6, 11, 62, nil, nil, 12, nil, 4,
777
- nil, nil, 53, 13, 65, 54, 62, 63, 94, 145,
778
- nil, 146, nil, 147, 148, 149, 12, 45, 46, 52,
779
- 92, 93, 167, nil, 38, nil, nil, 148, 131, nil,
800
+ nil, 20, 24, 35, 53, nil, nil, 42, nil, 0,
801
+ nil, nil, 57, 91, 57, 53, 54, 71, 157, 145,
802
+ nil, 146, nil, 147, 148, 149, 13, 36, 42, 43,
803
+ 83, 84, 167, nil, 29, nil, nil, 148, 128, nil,
780
804
  nil, -5, nil, nil, nil, nil, 153, nil, 154, 155,
781
- 156, nil, nil, nil, nil, nil, 168, 19, 20, nil,
782
- 171, 170, 135, 136, nil, nil, nil, nil, 53, 100,
783
- 106, nil, nil, 112, 118, 124, nil, nil, nil, nil,
784
- nil, 146, 175, nil, nil, nil, nil, nil, 179, nil,
785
- 180, 181, 182, 183, 184, 130, nil, 153, 180, nil,
786
- 141, nil, 142, 154, nil, 157, 177, 187, 155, 150,
787
- 190, nil, 191, nil, nil, nil, nil, nil, 158, nil,
788
- nil, 147, nil, nil, -21, 2, nil, nil, nil, 174,
789
- nil, 175, 176, 177, 178, 179, 165, nil, 161, nil,
790
- nil, nil, nil, 148, 182, nil, 183, nil, nil, 99,
791
- 105, 111, 7, nil, 202, nil, nil, nil, 117, nil,
792
- nil, nil, 123, 129, nil, nil, 185, 166, nil ]
805
+ 156, nil, nil, nil, nil, nil, 168, 97, 103, nil,
806
+ 171, 170, 126, 127, nil, nil, nil, nil, 171, 109,
807
+ 115, nil, nil, 172, 173, 174, nil, nil, nil, nil,
808
+ nil, 150, 179, nil, nil, nil, nil, nil, 183, nil,
809
+ 184, 185, 186, 187, 188, 121, nil, 150, 184, nil,
810
+ 132, nil, 133, 151, nil, 154, 181, 191, 159, 151,
811
+ 194, nil, 195, nil, nil, nil, nil, nil, 155, nil,
812
+ nil, 138, 158, nil, nil, -15, -2, nil, nil, nil,
813
+ 178, nil, 179, 180, 181, 182, 183, 169, nil, -27,
814
+ 162, nil, 139, 186, nil, 187, nil, nil, 90, 96,
815
+ 102, 3, nil, 144, nil, nil, nil, nil, 206, nil,
816
+ nil, nil, 108, nil, nil, nil, 114, 120, -26, nil,
817
+ nil, nil, 145, 189, 173, 168, nil, nil ]
793
818
 
794
819
  racc_action_default = [
795
- -2, -108, -8, -108, -108, -3, -4, -108, 169, -108,
796
- -9, -10, -108, -108, -108, -108, -108, -108, -108, -108,
797
- -23, -108, -27, -108, -108, -108, -108, -108, -108, -108,
798
- -108, -108, -108, -7, -95, -74, -76, -108, -92, -94,
799
- -11, -99, -72, -73, -98, -13, -14, -63, -15, -16,
800
- -108, -20, -24, -28, -31, -34, -37, -43, -108, -46,
801
- -49, -38, -53, -108, -56, -58, -59, -107, -39, -66,
802
- -108, -69, -71, -40, -41, -42, -5, -1, -75, -96,
803
- -77, -108, -108, -12, -100, -101, -102, -60, -108, -17,
804
- -108, -108, -108, -108, -108, -108, -47, -44, -51, -50,
805
- -108, -57, -54, -68, -70, -67, -108, -108, -82, -108,
806
- -108, -64, -108, -21, -25, -29, -32, -35, -45, -48,
807
- -52, -55, -6, -97, -78, -79, -83, -93, -61, -108,
808
- -18, -108, -108, -108, -108, -108, -82, -81, -92, -85,
809
- -86, -87, -88, -108, -108, -65, -108, -22, -26, -108,
810
- -108, -108, -80, -84, -108, -91, -62, -19, -30, -103,
811
- -105, -106, -33, -36, -89, -104, -108, -92, -90 ]
820
+ -2, -111, -8, -111, -111, -3, -4, -111, 178, -111,
821
+ -9, -10, -111, -111, -111, -111, -111, -111, -111, -111,
822
+ -23, -111, -27, -111, -111, -111, -111, -111, -111, -111,
823
+ -111, -111, -111, -7, -98, -74, -76, -111, -95, -97,
824
+ -11, -102, -72, -73, -101, -13, -14, -63, -15, -16,
825
+ -111, -20, -24, -28, -31, -34, -37, -43, -111, -46,
826
+ -49, -38, -53, -111, -56, -58, -59, -110, -39, -66,
827
+ -111, -69, -71, -40, -41, -42, -5, -1, -75, -99,
828
+ -77, -111, -111, -12, -103, -104, -105, -60, -111, -17,
829
+ -111, -111, -111, -111, -111, -111, -47, -44, -51, -50,
830
+ -111, -57, -54, -111, -70, -67, -111, -111, -82, -111,
831
+ -111, -64, -111, -21, -25, -29, -32, -35, -45, -48,
832
+ -52, -55, -68, -6, -100, -78, -79, -83, -96, -61,
833
+ -111, -18, -111, -111, -111, -111, -111, -82, -81, -72,
834
+ -95, -88, -111, -111, -65, -111, -22, -26, -111, -111,
835
+ -111, -80, -85, -111, -92, -93, -94, -84, -111, -91,
836
+ -62, -19, -30, -106, -108, -109, -33, -36, -111, -89,
837
+ -107, -86, -111, -111, -111, -95, -87, -90 ]
812
838
 
813
839
  racc_goto_table = [
814
- 81, 64, 44, 57, 62, 96, 125, 104, 35, 165,
815
- 46, 48, 49, 165, 165, 60, 1, 72, 72, 72,
816
- 72, 103, 2, 105, 4, 34, 103, 103, 103, 68,
817
- 73, 74, 75, 78, 152, 97, 101, 64, 77, 5,
818
- 102, 104, 32, 104, 106, 96, 60, 60, 158, 162,
819
- 163, 10, 11, 41, 83, 112, 146, 72, 72, 72,
820
- 90, 131, 72, 72, 72, 91, 96, 132, 92, 133,
821
- 93, 134, 118, 94, 64, 135, 101, 121, 56, 61,
822
- 98, 119, 110, 144, 60, 88, 60, 129, 124, 154,
823
- 166, 107, 72, nil, 72, 101, nil, nil, nil, 138,
824
- 153, nil, nil, nil, nil, nil, nil, 60, nil, nil,
825
- nil, nil, nil, nil, nil, nil, nil, 155, nil, nil,
826
- nil, nil, nil, nil, nil, nil, 138, nil, nil, 168 ]
840
+ 64, 81, 57, 44, 62, 96, 105, 35, 104, 126,
841
+ 170, 46, 48, 49, 170, 170, 60, 1, 72, 72,
842
+ 72, 72, 68, 73, 74, 75, 162, 166, 167, 2,
843
+ 4, 34, 78, 77, 97, 101, 64, 5, 151, 122,
844
+ 102, 32, 106, 10, 104, 96, 11, 60, 60, 41,
845
+ 83, 112, 145, 90, 132, 91, 133, 92, 134, 72,
846
+ 72, 104, 93, 135, 94, 136, 96, 56, 61, 98,
847
+ 119, 118, 110, 64, 143, 101, 88, 121, 130, 125,
848
+ 152, 158, 173, 107, nil, 60, nil, 60, nil, nil,
849
+ nil, nil, nil, 72, 101, 72, nil, nil, nil, 140,
850
+ nil, nil, nil, 157, nil, nil, nil, nil, 60, nil,
851
+ nil, nil, 72, nil, nil, 159, nil, nil, nil, nil,
852
+ nil, nil, nil, nil, 140, nil, 168, nil, nil, nil,
853
+ nil, nil, nil, nil, nil, nil, nil, nil, 177, nil,
854
+ nil, nil, nil, nil, nil, 174 ]
827
855
 
828
856
  racc_goto_check = [
829
- 48, 37, 33, 31, 36, 32, 50, 44, 45, 54,
830
- 13, 13, 13, 54, 54, 33, 1, 33, 33, 33,
831
- 33, 43, 2, 43, 3, 4, 43, 43, 43, 30,
832
- 30, 30, 30, 45, 50, 31, 37, 37, 5, 6,
833
- 36, 44, 7, 44, 8, 32, 33, 33, 19, 19,
834
- 19, 9, 10, 11, 12, 14, 15, 33, 33, 33,
835
- 16, 17, 33, 33, 33, 20, 32, 21, 22, 23,
836
- 24, 25, 31, 26, 37, 27, 37, 36, 28, 29,
837
- 34, 35, 39, 40, 33, 41, 33, 42, 49, 51,
838
- 52, 53, 33, nil, 33, 37, nil, nil, nil, 37,
839
- 48, nil, nil, nil, nil, nil, nil, 33, nil, nil,
840
- nil, nil, nil, nil, nil, nil, nil, 37, nil, nil,
841
- nil, nil, nil, nil, nil, nil, 37, nil, nil, 48 ]
857
+ 37, 48, 31, 33, 36, 32, 43, 45, 44, 50,
858
+ 55, 13, 13, 13, 55, 55, 33, 1, 33, 33,
859
+ 33, 33, 30, 30, 30, 30, 19, 19, 19, 2,
860
+ 3, 4, 45, 5, 31, 37, 37, 6, 50, 43,
861
+ 36, 7, 8, 9, 44, 32, 10, 33, 33, 11,
862
+ 12, 14, 15, 16, 17, 20, 21, 22, 23, 33,
863
+ 33, 44, 24, 25, 26, 27, 32, 28, 29, 34,
864
+ 35, 31, 39, 37, 40, 37, 41, 36, 42, 49,
865
+ 51, 52, 53, 54, nil, 33, nil, 33, nil, nil,
866
+ nil, nil, nil, 33, 37, 33, nil, nil, nil, 37,
867
+ nil, nil, nil, 48, nil, nil, nil, nil, 33, nil,
868
+ nil, nil, 33, nil, nil, 37, nil, nil, nil, nil,
869
+ nil, nil, nil, nil, 37, nil, 37, nil, nil, nil,
870
+ nil, nil, nil, nil, nil, nil, nil, nil, 48, nil,
871
+ nil, nil, nil, nil, nil, 37 ]
842
872
 
843
873
  racc_goto_pointer = [
844
- nil, 16, 22, 22, 16, 4, 37, 36, -32, 47,
845
- 48, 40, 13, -5, -34, -74, 9, -52, nil, -101,
846
- 13, -47, 15, -46, 16, -45, 18, -42, 52, 52,
847
- 1, -23, -52, -11, 20, -17, -23, -26, nil, -5,
848
- -45, 38, -24, -47, -62, -1, nil, nil, -38, -20,
849
- -102, -53, -74, 12, -149 ]
874
+ nil, 17, 29, 28, 22, -1, 35, 35, -34, 39,
875
+ 42, 36, 9, -4, -38, -79, 2, -59, nil, -122,
876
+ 3, -58, 4, -57, 8, -53, 9, -52, 41, 41,
877
+ -6, -24, -52, -10, 9, -28, -23, -27, nil, -15,
878
+ -55, 29, -33, -64, -61, -2, nil, nil, -37, -29,
879
+ -99, -59, -60, -87, 4, -152 ]
850
880
 
851
881
  racc_goto_default = [
852
882
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
853
883
  37, nil, nil, nil, nil, nil, nil, nil, 22, nil,
854
884
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
855
- nil, nil, 59, 65, nil, nil, nil, 160, 66, nil,
885
+ nil, nil, 59, 65, nil, nil, nil, 164, 66, nil,
856
886
  nil, nil, nil, 69, 71, nil, 36, 38, nil, nil,
857
- nil, nil, nil, nil, 159 ]
887
+ nil, nil, nil, nil, nil, 163 ]
858
888
 
859
889
  racc_reduce_table = [
860
890
  0, 0, :racc_error,
861
- 5, 44, :_reduce_none,
862
- 0, 45, :_reduce_none,
863
- 2, 45, :_reduce_none,
864
- 0, 50, :_reduce_4,
865
- 0, 51, :_reduce_5,
866
- 5, 49, :_reduce_6,
867
- 2, 49, :_reduce_none,
868
- 0, 46, :_reduce_8,
869
- 2, 46, :_reduce_none,
870
- 1, 52, :_reduce_none,
871
- 2, 52, :_reduce_11,
872
- 3, 52, :_reduce_none,
873
- 2, 52, :_reduce_none,
874
- 2, 52, :_reduce_none,
875
- 2, 52, :_reduce_15,
876
- 2, 52, :_reduce_16,
877
- 0, 57, :_reduce_17,
878
- 0, 58, :_reduce_18,
879
- 7, 52, :_reduce_19,
880
- 0, 59, :_reduce_20,
881
- 0, 60, :_reduce_21,
882
- 6, 52, :_reduce_22,
883
- 1, 52, :_reduce_none,
884
- 0, 63, :_reduce_24,
885
- 0, 64, :_reduce_25,
886
- 6, 53, :_reduce_26,
887
- 1, 53, :_reduce_none,
888
- 0, 65, :_reduce_28,
889
- 0, 66, :_reduce_29,
890
- 7, 53, :_reduce_none,
891
- 0, 67, :_reduce_31,
892
- 0, 68, :_reduce_32,
893
- 7, 53, :_reduce_33,
894
- 0, 69, :_reduce_34,
895
- 0, 70, :_reduce_35,
896
- 7, 53, :_reduce_36,
897
- 2, 61, :_reduce_none,
898
- 2, 61, :_reduce_38,
899
- 2, 61, :_reduce_39,
900
- 2, 61, :_reduce_40,
901
- 2, 61, :_reduce_41,
902
- 2, 61, :_reduce_42,
903
- 1, 71, :_reduce_43,
904
- 2, 71, :_reduce_44,
905
- 3, 71, :_reduce_45,
906
- 1, 74, :_reduce_46,
907
- 2, 74, :_reduce_47,
908
- 3, 75, :_reduce_48,
909
- 0, 77, :_reduce_none,
910
- 1, 77, :_reduce_none,
911
- 0, 78, :_reduce_none,
912
- 1, 78, :_reduce_none,
913
- 1, 72, :_reduce_53,
914
- 2, 72, :_reduce_54,
915
- 3, 72, :_reduce_55,
916
- 1, 79, :_reduce_56,
917
- 2, 79, :_reduce_57,
918
- 1, 80, :_reduce_none,
919
- 1, 80, :_reduce_none,
920
- 0, 82, :_reduce_60,
921
- 0, 83, :_reduce_61,
922
- 6, 56, :_reduce_62,
923
- 0, 84, :_reduce_63,
924
- 0, 85, :_reduce_64,
925
- 5, 56, :_reduce_65,
926
- 1, 73, :_reduce_66,
927
- 2, 73, :_reduce_67,
928
- 2, 73, :_reduce_68,
929
- 1, 86, :_reduce_69,
930
- 2, 86, :_reduce_70,
931
- 1, 87, :_reduce_none,
932
- 1, 76, :_reduce_72,
933
- 1, 76, :_reduce_73,
934
- 1, 47, :_reduce_none,
935
- 2, 47, :_reduce_none,
936
- 1, 88, :_reduce_none,
937
- 2, 88, :_reduce_none,
938
- 4, 89, :_reduce_78,
939
- 1, 92, :_reduce_79,
940
- 3, 92, :_reduce_80,
941
- 2, 92, :_reduce_none,
942
- 0, 93, :_reduce_82,
943
- 1, 93, :_reduce_83,
944
- 3, 93, :_reduce_84,
945
- 2, 93, :_reduce_85,
946
- 2, 93, :_reduce_86,
947
- 2, 93, :_reduce_87,
948
- 0, 94, :_reduce_88,
949
- 0, 95, :_reduce_89,
950
- 7, 93, :_reduce_90,
951
- 3, 93, :_reduce_91,
952
- 0, 91, :_reduce_none,
953
- 3, 91, :_reduce_93,
954
- 1, 90, :_reduce_none,
891
+ 5, 47, :_reduce_none,
955
892
  0, 48, :_reduce_none,
956
- 0, 96, :_reduce_96,
957
- 3, 48, :_reduce_97,
958
- 1, 54, :_reduce_none,
959
- 0, 55, :_reduce_none,
960
- 1, 55, :_reduce_none,
893
+ 2, 48, :_reduce_none,
894
+ 0, 53, :_reduce_4,
895
+ 0, 54, :_reduce_5,
896
+ 5, 52, :_reduce_6,
897
+ 2, 52, :_reduce_none,
898
+ 0, 49, :_reduce_8,
899
+ 2, 49, :_reduce_none,
961
900
  1, 55, :_reduce_none,
901
+ 2, 55, :_reduce_11,
902
+ 3, 55, :_reduce_none,
903
+ 2, 55, :_reduce_none,
904
+ 2, 55, :_reduce_none,
905
+ 2, 55, :_reduce_15,
906
+ 2, 55, :_reduce_16,
907
+ 0, 60, :_reduce_17,
908
+ 0, 61, :_reduce_18,
909
+ 7, 55, :_reduce_19,
910
+ 0, 62, :_reduce_20,
911
+ 0, 63, :_reduce_21,
912
+ 6, 55, :_reduce_22,
962
913
  1, 55, :_reduce_none,
963
- 1, 62, :_reduce_103,
964
- 2, 62, :_reduce_104,
914
+ 0, 66, :_reduce_24,
915
+ 0, 67, :_reduce_25,
916
+ 6, 56, :_reduce_26,
917
+ 1, 56, :_reduce_none,
918
+ 0, 68, :_reduce_28,
919
+ 0, 69, :_reduce_29,
920
+ 7, 56, :_reduce_none,
921
+ 0, 70, :_reduce_31,
922
+ 0, 71, :_reduce_32,
923
+ 7, 56, :_reduce_33,
924
+ 0, 72, :_reduce_34,
925
+ 0, 73, :_reduce_35,
926
+ 7, 56, :_reduce_36,
927
+ 2, 64, :_reduce_none,
928
+ 2, 64, :_reduce_38,
929
+ 2, 64, :_reduce_39,
930
+ 2, 64, :_reduce_40,
931
+ 2, 64, :_reduce_41,
932
+ 2, 64, :_reduce_42,
933
+ 1, 74, :_reduce_43,
934
+ 2, 74, :_reduce_44,
935
+ 3, 74, :_reduce_45,
936
+ 1, 77, :_reduce_46,
937
+ 2, 77, :_reduce_47,
938
+ 3, 78, :_reduce_48,
939
+ 0, 80, :_reduce_none,
940
+ 1, 80, :_reduce_none,
941
+ 0, 81, :_reduce_none,
942
+ 1, 81, :_reduce_none,
943
+ 1, 75, :_reduce_53,
944
+ 2, 75, :_reduce_54,
945
+ 3, 75, :_reduce_55,
946
+ 1, 82, :_reduce_56,
947
+ 2, 82, :_reduce_57,
948
+ 1, 83, :_reduce_none,
949
+ 1, 83, :_reduce_none,
950
+ 0, 85, :_reduce_60,
951
+ 0, 86, :_reduce_61,
952
+ 6, 59, :_reduce_62,
953
+ 0, 87, :_reduce_63,
954
+ 0, 88, :_reduce_64,
955
+ 5, 59, :_reduce_65,
956
+ 1, 76, :_reduce_66,
957
+ 2, 76, :_reduce_67,
958
+ 3, 76, :_reduce_68,
959
+ 1, 89, :_reduce_69,
960
+ 2, 89, :_reduce_70,
961
+ 1, 90, :_reduce_none,
962
+ 1, 79, :_reduce_72,
963
+ 1, 79, :_reduce_73,
964
+ 1, 50, :_reduce_none,
965
+ 2, 50, :_reduce_none,
966
+ 1, 91, :_reduce_none,
967
+ 2, 91, :_reduce_none,
968
+ 4, 92, :_reduce_78,
969
+ 1, 95, :_reduce_79,
970
+ 3, 95, :_reduce_80,
971
+ 2, 95, :_reduce_none,
972
+ 0, 96, :_reduce_82,
973
+ 1, 96, :_reduce_83,
974
+ 3, 96, :_reduce_84,
975
+ 3, 96, :_reduce_85,
976
+ 5, 96, :_reduce_86,
977
+ 7, 96, :_reduce_87,
978
+ 0, 98, :_reduce_88,
979
+ 0, 99, :_reduce_89,
980
+ 7, 96, :_reduce_90,
981
+ 3, 96, :_reduce_91,
965
982
  1, 97, :_reduce_none,
966
983
  1, 97, :_reduce_none,
967
- 1, 81, :_reduce_107 ]
968
-
969
- racc_reduce_n = 108
970
-
971
- racc_shift_n = 169
984
+ 1, 97, :_reduce_none,
985
+ 0, 94, :_reduce_none,
986
+ 3, 94, :_reduce_96,
987
+ 1, 93, :_reduce_none,
988
+ 0, 51, :_reduce_none,
989
+ 0, 100, :_reduce_99,
990
+ 3, 51, :_reduce_100,
991
+ 1, 57, :_reduce_none,
992
+ 0, 58, :_reduce_none,
993
+ 1, 58, :_reduce_none,
994
+ 1, 58, :_reduce_none,
995
+ 1, 58, :_reduce_none,
996
+ 1, 65, :_reduce_106,
997
+ 2, 65, :_reduce_107,
998
+ 1, 101, :_reduce_none,
999
+ 1, 101, :_reduce_none,
1000
+ 1, 84, :_reduce_110 ]
1001
+
1002
+ racc_reduce_n = 111
1003
+
1004
+ racc_shift_n = 178
972
1005
 
973
1006
  racc_token_table = {
974
1007
  false => 0,
@@ -1007,15 +1040,18 @@ racc_token_table = {
1007
1040
  ":" => 33,
1008
1041
  "|" => 34,
1009
1042
  "%empty" => 35,
1010
- "?" => 36,
1011
- "+" => 37,
1012
- "*" => 38,
1043
+ "(" => 36,
1044
+ ")" => 37,
1045
+ "," => 38,
1013
1046
  "%prec" => 39,
1014
- "[" => 40,
1015
- "]" => 41,
1016
- "{...}" => 42 }
1047
+ "?" => 40,
1048
+ "+" => 41,
1049
+ "*" => 42,
1050
+ "[" => 43,
1051
+ "]" => 44,
1052
+ "{...}" => 45 }
1017
1053
 
1018
- racc_nt_base = 43
1054
+ racc_nt_base = 46
1019
1055
 
1020
1056
  racc_use_result_var = true
1021
1057
 
@@ -1073,10 +1109,13 @@ Racc_token_to_s_table = [
1073
1109
  "\":\"",
1074
1110
  "\"|\"",
1075
1111
  "\"%empty\"",
1112
+ "\"(\"",
1113
+ "\")\"",
1114
+ "\",\"",
1115
+ "\"%prec\"",
1076
1116
  "\"?\"",
1077
1117
  "\"+\"",
1078
1118
  "\"*\"",
1079
- "\"%prec\"",
1080
1119
  "\"[\"",
1081
1120
  "\"]\"",
1082
1121
  "\"{...}\"",
@@ -1131,6 +1170,7 @@ Racc_token_to_s_table = [
1131
1170
  "named_ref_opt",
1132
1171
  "rhs_list",
1133
1172
  "rhs",
1173
+ "parameterizing_suffix",
1134
1174
  "@19",
1135
1175
  "@20",
1136
1176
  "@21",
@@ -1203,26 +1243,24 @@ module_eval(<<'.,.,', 'parser.y', 31)
1203
1243
  module_eval(<<'.,.,', 'parser.y', 37)
1204
1244
  def _reduce_15(val, _values, result)
1205
1245
  val[1].each {|token|
1206
- token.references = []
1207
- @grammar.lex_param = @grammar.build_code(:lex_param, token).token_code.s_value
1246
+ @grammar.lex_param = Grammar::Code::NoReferenceCode.new(type: :lex_param, token_code: token).token_code.s_value
1208
1247
  }
1209
1248
 
1210
1249
  result
1211
1250
  end
1212
1251
  .,.,
1213
1252
 
1214
- module_eval(<<'.,.,', 'parser.y', 44)
1253
+ module_eval(<<'.,.,', 'parser.y', 43)
1215
1254
  def _reduce_16(val, _values, result)
1216
1255
  val[1].each {|token|
1217
- token.references = []
1218
- @grammar.parse_param = @grammar.build_code(:parse_param, token).token_code.s_value
1256
+ @grammar.parse_param = Grammar::Code::NoReferenceCode.new(type: :parse_param, token_code: token).token_code.s_value
1219
1257
  }
1220
1258
 
1221
1259
  result
1222
1260
  end
1223
1261
  .,.,
1224
1262
 
1225
- module_eval(<<'.,.,', 'parser.y', 51)
1263
+ module_eval(<<'.,.,', 'parser.y', 49)
1226
1264
  def _reduce_17(val, _values, result)
1227
1265
  begin_c_declaration("}")
1228
1266
 
@@ -1230,7 +1268,7 @@ module_eval(<<'.,.,', 'parser.y', 51)
1230
1268
  end
1231
1269
  .,.,
1232
1270
 
1233
- module_eval(<<'.,.,', 'parser.y', 55)
1271
+ module_eval(<<'.,.,', 'parser.y', 53)
1234
1272
  def _reduce_18(val, _values, result)
1235
1273
  end_c_declaration
1236
1274
 
@@ -1238,7 +1276,7 @@ module_eval(<<'.,.,', 'parser.y', 55)
1238
1276
  end
1239
1277
  .,.,
1240
1278
 
1241
- module_eval(<<'.,.,', 'parser.y', 59)
1279
+ module_eval(<<'.,.,', 'parser.y', 57)
1242
1280
  def _reduce_19(val, _values, result)
1243
1281
  @grammar.add_percent_code(id: val[1], code: val[4])
1244
1282
 
@@ -1246,7 +1284,7 @@ module_eval(<<'.,.,', 'parser.y', 59)
1246
1284
  end
1247
1285
  .,.,
1248
1286
 
1249
- module_eval(<<'.,.,', 'parser.y', 63)
1287
+ module_eval(<<'.,.,', 'parser.y', 61)
1250
1288
  def _reduce_20(val, _values, result)
1251
1289
  begin_c_declaration("}")
1252
1290
 
@@ -1254,7 +1292,7 @@ module_eval(<<'.,.,', 'parser.y', 63)
1254
1292
  end
1255
1293
  .,.,
1256
1294
 
1257
- module_eval(<<'.,.,', 'parser.y', 67)
1295
+ module_eval(<<'.,.,', 'parser.y', 65)
1258
1296
  def _reduce_21(val, _values, result)
1259
1297
  end_c_declaration
1260
1298
 
@@ -1262,9 +1300,9 @@ module_eval(<<'.,.,', 'parser.y', 67)
1262
1300
  end
1263
1301
  .,.,
1264
1302
 
1265
- module_eval(<<'.,.,', 'parser.y', 71)
1303
+ module_eval(<<'.,.,', 'parser.y', 69)
1266
1304
  def _reduce_22(val, _values, result)
1267
- @grammar.initial_action = @grammar.build_code(:initial_action, val[3])
1305
+ @grammar.initial_action = Grammar::Code::InitialActionCode.new(type: :initial_action, token_code: val[3])
1268
1306
 
1269
1307
  result
1270
1308
  end
@@ -1272,7 +1310,7 @@ module_eval(<<'.,.,', 'parser.y', 71)
1272
1310
 
1273
1311
  # reduce 23 omitted
1274
1312
 
1275
- module_eval(<<'.,.,', 'parser.y', 77)
1313
+ module_eval(<<'.,.,', 'parser.y', 75)
1276
1314
  def _reduce_24(val, _values, result)
1277
1315
  begin_c_declaration("}")
1278
1316
 
@@ -1280,7 +1318,7 @@ module_eval(<<'.,.,', 'parser.y', 77)
1280
1318
  end
1281
1319
  .,.,
1282
1320
 
1283
- module_eval(<<'.,.,', 'parser.y', 81)
1321
+ module_eval(<<'.,.,', 'parser.y', 79)
1284
1322
  def _reduce_25(val, _values, result)
1285
1323
  end_c_declaration
1286
1324
 
@@ -1288,9 +1326,12 @@ module_eval(<<'.,.,', 'parser.y', 81)
1288
1326
  end
1289
1327
  .,.,
1290
1328
 
1291
- module_eval(<<'.,.,', 'parser.y', 85)
1329
+ module_eval(<<'.,.,', 'parser.y', 83)
1292
1330
  def _reduce_26(val, _values, result)
1293
- @grammar.set_union(@grammar.build_code(:union, val[3]), val[3].line)
1331
+ @grammar.set_union(
1332
+ Grammar::Code::NoReferenceCode.new(type: :union, token_code: val[3]),
1333
+ val[3].line
1334
+ )
1294
1335
 
1295
1336
  result
1296
1337
  end
@@ -1298,7 +1339,7 @@ module_eval(<<'.,.,', 'parser.y', 85)
1298
1339
 
1299
1340
  # reduce 27 omitted
1300
1341
 
1301
- module_eval(<<'.,.,', 'parser.y', 90)
1342
+ module_eval(<<'.,.,', 'parser.y', 91)
1302
1343
  def _reduce_28(val, _values, result)
1303
1344
  begin_c_declaration("}")
1304
1345
 
@@ -1306,7 +1347,7 @@ module_eval(<<'.,.,', 'parser.y', 90)
1306
1347
  end
1307
1348
  .,.,
1308
1349
 
1309
- module_eval(<<'.,.,', 'parser.y', 94)
1350
+ module_eval(<<'.,.,', 'parser.y', 95)
1310
1351
  def _reduce_29(val, _values, result)
1311
1352
  end_c_declaration
1312
1353
 
@@ -1316,7 +1357,7 @@ module_eval(<<'.,.,', 'parser.y', 94)
1316
1357
 
1317
1358
  # reduce 30 omitted
1318
1359
 
1319
- module_eval(<<'.,.,', 'parser.y', 99)
1360
+ module_eval(<<'.,.,', 'parser.y', 100)
1320
1361
  def _reduce_31(val, _values, result)
1321
1362
  begin_c_declaration("}")
1322
1363
 
@@ -1324,7 +1365,7 @@ module_eval(<<'.,.,', 'parser.y', 99)
1324
1365
  end
1325
1366
  .,.,
1326
1367
 
1327
- module_eval(<<'.,.,', 'parser.y', 103)
1368
+ module_eval(<<'.,.,', 'parser.y', 104)
1328
1369
  def _reduce_32(val, _values, result)
1329
1370
  end_c_declaration
1330
1371
 
@@ -1332,15 +1373,19 @@ module_eval(<<'.,.,', 'parser.y', 103)
1332
1373
  end
1333
1374
  .,.,
1334
1375
 
1335
- module_eval(<<'.,.,', 'parser.y', 107)
1376
+ module_eval(<<'.,.,', 'parser.y', 108)
1336
1377
  def _reduce_33(val, _values, result)
1337
- @grammar.add_printer(ident_or_tags: val[6], code: @grammar.build_code(:printer, val[3]), lineno: val[3].line)
1378
+ @grammar.add_printer(
1379
+ ident_or_tags: val[6],
1380
+ token_code: val[3],
1381
+ lineno: val[3].line
1382
+ )
1338
1383
 
1339
1384
  result
1340
1385
  end
1341
1386
  .,.,
1342
1387
 
1343
- module_eval(<<'.,.,', 'parser.y', 111)
1388
+ module_eval(<<'.,.,', 'parser.y', 116)
1344
1389
  def _reduce_34(val, _values, result)
1345
1390
  begin_c_declaration("}")
1346
1391
 
@@ -1348,7 +1393,7 @@ module_eval(<<'.,.,', 'parser.y', 111)
1348
1393
  end
1349
1394
  .,.,
1350
1395
 
1351
- module_eval(<<'.,.,', 'parser.y', 115)
1396
+ module_eval(<<'.,.,', 'parser.y', 120)
1352
1397
  def _reduce_35(val, _values, result)
1353
1398
  end_c_declaration
1354
1399
 
@@ -1356,9 +1401,13 @@ module_eval(<<'.,.,', 'parser.y', 115)
1356
1401
  end
1357
1402
  .,.,
1358
1403
 
1359
- module_eval(<<'.,.,', 'parser.y', 119)
1404
+ module_eval(<<'.,.,', 'parser.y', 124)
1360
1405
  def _reduce_36(val, _values, result)
1361
- @grammar.add_error_token(ident_or_tags: val[6], code: @grammar.build_code(:error_token, val[3]), lineno: val[3].line)
1406
+ @grammar.add_error_token(
1407
+ ident_or_tags: val[6],
1408
+ token_code: val[3],
1409
+ lineno: val[3].line
1410
+ )
1362
1411
 
1363
1412
  result
1364
1413
  end
@@ -1366,7 +1415,7 @@ module_eval(<<'.,.,', 'parser.y', 119)
1366
1415
 
1367
1416
  # reduce 37 omitted
1368
1417
 
1369
- module_eval(<<'.,.,', 'parser.y', 125)
1418
+ module_eval(<<'.,.,', 'parser.y', 134)
1370
1419
  def _reduce_38(val, _values, result)
1371
1420
  val[1].each {|hash|
1372
1421
  hash[:tokens].each {|id|
@@ -1378,7 +1427,7 @@ module_eval(<<'.,.,', 'parser.y', 125)
1378
1427
  end
1379
1428
  .,.,
1380
1429
 
1381
- module_eval(<<'.,.,', 'parser.y', 133)
1430
+ module_eval(<<'.,.,', 'parser.y', 142)
1382
1431
  def _reduce_39(val, _values, result)
1383
1432
  val[1].each {|hash|
1384
1433
  hash[:tokens].each {|id|
@@ -1392,7 +1441,7 @@ module_eval(<<'.,.,', 'parser.y', 133)
1392
1441
  end
1393
1442
  .,.,
1394
1443
 
1395
- module_eval(<<'.,.,', 'parser.y', 143)
1444
+ module_eval(<<'.,.,', 'parser.y', 152)
1396
1445
  def _reduce_40(val, _values, result)
1397
1446
  val[1].each {|hash|
1398
1447
  hash[:tokens].each {|id|
@@ -1406,7 +1455,7 @@ module_eval(<<'.,.,', 'parser.y', 143)
1406
1455
  end
1407
1456
  .,.,
1408
1457
 
1409
- module_eval(<<'.,.,', 'parser.y', 153)
1458
+ module_eval(<<'.,.,', 'parser.y', 162)
1410
1459
  def _reduce_41(val, _values, result)
1411
1460
  val[1].each {|hash|
1412
1461
  hash[:tokens].each {|id|
@@ -1420,7 +1469,7 @@ module_eval(<<'.,.,', 'parser.y', 153)
1420
1469
  end
1421
1470
  .,.,
1422
1471
 
1423
- module_eval(<<'.,.,', 'parser.y', 163)
1472
+ module_eval(<<'.,.,', 'parser.y', 172)
1424
1473
  def _reduce_42(val, _values, result)
1425
1474
  val[1].each {|hash|
1426
1475
  hash[:tokens].each {|id|
@@ -1434,7 +1483,7 @@ module_eval(<<'.,.,', 'parser.y', 163)
1434
1483
  end
1435
1484
  .,.,
1436
1485
 
1437
- module_eval(<<'.,.,', 'parser.y', 174)
1486
+ module_eval(<<'.,.,', 'parser.y', 183)
1438
1487
  def _reduce_43(val, _values, result)
1439
1488
  val[0].each {|token_declaration|
1440
1489
  @grammar.add_term(id: token_declaration[0], alias_name: token_declaration[2], token_id: token_declaration[1], tag: nil, replace: true)
@@ -1444,7 +1493,7 @@ module_eval(<<'.,.,', 'parser.y', 174)
1444
1493
  end
1445
1494
  .,.,
1446
1495
 
1447
- module_eval(<<'.,.,', 'parser.y', 180)
1496
+ module_eval(<<'.,.,', 'parser.y', 189)
1448
1497
  def _reduce_44(val, _values, result)
1449
1498
  val[1].each {|token_declaration|
1450
1499
  @grammar.add_term(id: token_declaration[0], alias_name: token_declaration[2], token_id: token_declaration[1], tag: val[0], replace: true)
@@ -1454,7 +1503,7 @@ module_eval(<<'.,.,', 'parser.y', 180)
1454
1503
  end
1455
1504
  .,.,
1456
1505
 
1457
- module_eval(<<'.,.,', 'parser.y', 186)
1506
+ module_eval(<<'.,.,', 'parser.y', 195)
1458
1507
  def _reduce_45(val, _values, result)
1459
1508
  val[2].each {|token_declaration|
1460
1509
  @grammar.add_term(id: token_declaration[0], alias_name: token_declaration[2], token_id: token_declaration[1], tag: val[1], replace: true)
@@ -1464,21 +1513,21 @@ module_eval(<<'.,.,', 'parser.y', 186)
1464
1513
  end
1465
1514
  .,.,
1466
1515
 
1467
- module_eval(<<'.,.,', 'parser.y', 191)
1516
+ module_eval(<<'.,.,', 'parser.y', 200)
1468
1517
  def _reduce_46(val, _values, result)
1469
1518
  result = [val[0]]
1470
1519
  result
1471
1520
  end
1472
1521
  .,.,
1473
1522
 
1474
- module_eval(<<'.,.,', 'parser.y', 192)
1523
+ module_eval(<<'.,.,', 'parser.y', 201)
1475
1524
  def _reduce_47(val, _values, result)
1476
1525
  result = val[0].append(val[1])
1477
1526
  result
1478
1527
  end
1479
1528
  .,.,
1480
1529
 
1481
- module_eval(<<'.,.,', 'parser.y', 194)
1530
+ module_eval(<<'.,.,', 'parser.y', 203)
1482
1531
  def _reduce_48(val, _values, result)
1483
1532
  result = val
1484
1533
  result
@@ -1493,7 +1542,7 @@ module_eval(<<'.,.,', 'parser.y', 194)
1493
1542
 
1494
1543
  # reduce 52 omitted
1495
1544
 
1496
- module_eval(<<'.,.,', 'parser.y', 204)
1545
+ module_eval(<<'.,.,', 'parser.y', 213)
1497
1546
  def _reduce_53(val, _values, result)
1498
1547
  result = [{tag: nil, tokens: val[0]}]
1499
1548
 
@@ -1501,7 +1550,7 @@ module_eval(<<'.,.,', 'parser.y', 204)
1501
1550
  end
1502
1551
  .,.,
1503
1552
 
1504
- module_eval(<<'.,.,', 'parser.y', 208)
1553
+ module_eval(<<'.,.,', 'parser.y', 217)
1505
1554
  def _reduce_54(val, _values, result)
1506
1555
  result = [{tag: val[0], tokens: val[1]}]
1507
1556
 
@@ -1509,7 +1558,7 @@ module_eval(<<'.,.,', 'parser.y', 208)
1509
1558
  end
1510
1559
  .,.,
1511
1560
 
1512
- module_eval(<<'.,.,', 'parser.y', 212)
1561
+ module_eval(<<'.,.,', 'parser.y', 221)
1513
1562
  def _reduce_55(val, _values, result)
1514
1563
  result = val[0].append({tag: val[1], tokens: val[2]})
1515
1564
 
@@ -1517,14 +1566,14 @@ module_eval(<<'.,.,', 'parser.y', 212)
1517
1566
  end
1518
1567
  .,.,
1519
1568
 
1520
- module_eval(<<'.,.,', 'parser.y', 215)
1569
+ module_eval(<<'.,.,', 'parser.y', 224)
1521
1570
  def _reduce_56(val, _values, result)
1522
1571
  result = [val[0]]
1523
1572
  result
1524
1573
  end
1525
1574
  .,.,
1526
1575
 
1527
- module_eval(<<'.,.,', 'parser.y', 216)
1576
+ module_eval(<<'.,.,', 'parser.y', 225)
1528
1577
  def _reduce_57(val, _values, result)
1529
1578
  result = val[0].append(val[1])
1530
1579
  result
@@ -1535,7 +1584,7 @@ module_eval(<<'.,.,', 'parser.y', 216)
1535
1584
 
1536
1585
  # reduce 59 omitted
1537
1586
 
1538
- module_eval(<<'.,.,', 'parser.y', 223)
1587
+ module_eval(<<'.,.,', 'parser.y', 232)
1539
1588
  def _reduce_60(val, _values, result)
1540
1589
  begin_c_declaration("}")
1541
1590
 
@@ -1543,7 +1592,7 @@ module_eval(<<'.,.,', 'parser.y', 223)
1543
1592
  end
1544
1593
  .,.,
1545
1594
 
1546
- module_eval(<<'.,.,', 'parser.y', 227)
1595
+ module_eval(<<'.,.,', 'parser.y', 236)
1547
1596
  def _reduce_61(val, _values, result)
1548
1597
  end_c_declaration
1549
1598
 
@@ -1551,7 +1600,7 @@ module_eval(<<'.,.,', 'parser.y', 227)
1551
1600
  end
1552
1601
  .,.,
1553
1602
 
1554
- module_eval(<<'.,.,', 'parser.y', 231)
1603
+ module_eval(<<'.,.,', 'parser.y', 240)
1555
1604
  def _reduce_62(val, _values, result)
1556
1605
  result = val[0].append(val[3])
1557
1606
 
@@ -1559,7 +1608,7 @@ module_eval(<<'.,.,', 'parser.y', 231)
1559
1608
  end
1560
1609
  .,.,
1561
1610
 
1562
- module_eval(<<'.,.,', 'parser.y', 235)
1611
+ module_eval(<<'.,.,', 'parser.y', 244)
1563
1612
  def _reduce_63(val, _values, result)
1564
1613
  begin_c_declaration("}")
1565
1614
 
@@ -1567,7 +1616,7 @@ module_eval(<<'.,.,', 'parser.y', 235)
1567
1616
  end
1568
1617
  .,.,
1569
1618
 
1570
- module_eval(<<'.,.,', 'parser.y', 239)
1619
+ module_eval(<<'.,.,', 'parser.y', 248)
1571
1620
  def _reduce_64(val, _values, result)
1572
1621
  end_c_declaration
1573
1622
 
@@ -1575,7 +1624,7 @@ module_eval(<<'.,.,', 'parser.y', 239)
1575
1624
  end
1576
1625
  .,.,
1577
1626
 
1578
- module_eval(<<'.,.,', 'parser.y', 243)
1627
+ module_eval(<<'.,.,', 'parser.y', 252)
1579
1628
  def _reduce_65(val, _values, result)
1580
1629
  result = [val[2]]
1581
1630
 
@@ -1583,7 +1632,7 @@ module_eval(<<'.,.,', 'parser.y', 243)
1583
1632
  end
1584
1633
  .,.,
1585
1634
 
1586
- module_eval(<<'.,.,', 'parser.y', 248)
1635
+ module_eval(<<'.,.,', 'parser.y', 257)
1587
1636
  def _reduce_66(val, _values, result)
1588
1637
  result = [{tag: nil, tokens: val[0]}]
1589
1638
 
@@ -1591,7 +1640,7 @@ module_eval(<<'.,.,', 'parser.y', 248)
1591
1640
  end
1592
1641
  .,.,
1593
1642
 
1594
- module_eval(<<'.,.,', 'parser.y', 252)
1643
+ module_eval(<<'.,.,', 'parser.y', 261)
1595
1644
  def _reduce_67(val, _values, result)
1596
1645
  result = [{tag: val[0], tokens: val[1]}]
1597
1646
 
@@ -1599,22 +1648,22 @@ module_eval(<<'.,.,', 'parser.y', 252)
1599
1648
  end
1600
1649
  .,.,
1601
1650
 
1602
- module_eval(<<'.,.,', 'parser.y', 256)
1651
+ module_eval(<<'.,.,', 'parser.y', 265)
1603
1652
  def _reduce_68(val, _values, result)
1604
- result = val[0].append({tag: nil, tokens: val[1]})
1653
+ result = val[0].append({tag: val[1], tokens: val[2]})
1605
1654
 
1606
1655
  result
1607
1656
  end
1608
1657
  .,.,
1609
1658
 
1610
- module_eval(<<'.,.,', 'parser.y', 259)
1659
+ module_eval(<<'.,.,', 'parser.y', 268)
1611
1660
  def _reduce_69(val, _values, result)
1612
1661
  result = [val[0]]
1613
1662
  result
1614
1663
  end
1615
1664
  .,.,
1616
1665
 
1617
- module_eval(<<'.,.,', 'parser.y', 260)
1666
+ module_eval(<<'.,.,', 'parser.y', 269)
1618
1667
  def _reduce_70(val, _values, result)
1619
1668
  result = val[0].append(val[1])
1620
1669
  result
@@ -1623,16 +1672,16 @@ module_eval(<<'.,.,', 'parser.y', 260)
1623
1672
 
1624
1673
  # reduce 71 omitted
1625
1674
 
1626
- module_eval(<<'.,.,', 'parser.y', 264)
1675
+ module_eval(<<'.,.,', 'parser.y', 273)
1627
1676
  def _reduce_72(val, _values, result)
1628
- raise "Ident after %prec" if @prec_seen
1677
+ on_action_error("ident after %prec", val[0]) if @prec_seen
1629
1678
  result
1630
1679
  end
1631
1680
  .,.,
1632
1681
 
1633
- module_eval(<<'.,.,', 'parser.y', 265)
1682
+ module_eval(<<'.,.,', 'parser.y', 274)
1634
1683
  def _reduce_73(val, _values, result)
1635
- raise "Char after %prec" if @prec_seen
1684
+ on_action_error("char after %prec", val[0]) if @prec_seen
1636
1685
  result
1637
1686
  end
1638
1687
  .,.,
@@ -1645,29 +1694,39 @@ module_eval(<<'.,.,', 'parser.y', 265)
1645
1694
 
1646
1695
  # reduce 77 omitted
1647
1696
 
1648
- module_eval(<<'.,.,', 'parser.y', 275)
1697
+ module_eval(<<'.,.,', 'parser.y', 284)
1649
1698
  def _reduce_78(val, _values, result)
1650
1699
  lhs = val[0]
1651
1700
  lhs.alias_name = val[1]
1652
- val[3].each {|hash|
1653
- @grammar.add_rule(lhs: lhs, rhs: hash[:rhs], lineno: hash[:lineno])
1654
- }
1701
+ val[3].each do |builder|
1702
+ builder.lhs = lhs
1703
+ builder.complete_input
1704
+ @grammar.add_rule_builder(builder)
1705
+ end
1655
1706
 
1656
1707
  result
1657
1708
  end
1658
1709
  .,.,
1659
1710
 
1660
- module_eval(<<'.,.,', 'parser.y', 284)
1711
+ module_eval(<<'.,.,', 'parser.y', 295)
1661
1712
  def _reduce_79(val, _values, result)
1662
- result = [{rhs: val[0], lineno: val[0].first&.line || @lexer.line - 1}]
1713
+ builder = val[0]
1714
+ if !builder.line
1715
+ builder.line = @lexer.line - 1
1716
+ end
1717
+ result = [builder]
1663
1718
 
1664
1719
  result
1665
1720
  end
1666
1721
  .,.,
1667
1722
 
1668
- module_eval(<<'.,.,', 'parser.y', 288)
1723
+ module_eval(<<'.,.,', 'parser.y', 303)
1669
1724
  def _reduce_80(val, _values, result)
1670
- result = val[0].append({rhs: val[2], lineno: val[2].first&.line || @lexer.line - 1})
1725
+ builder = val[2]
1726
+ if !builder.line
1727
+ builder.line = @lexer.line - 1
1728
+ end
1729
+ result = val[0].append(builder)
1671
1730
 
1672
1731
  result
1673
1732
  end
@@ -1675,65 +1734,73 @@ module_eval(<<'.,.,', 'parser.y', 288)
1675
1734
 
1676
1735
  # reduce 81 omitted
1677
1736
 
1678
- module_eval(<<'.,.,', 'parser.y', 294)
1737
+ module_eval(<<'.,.,', 'parser.y', 313)
1679
1738
  def _reduce_82(val, _values, result)
1680
1739
  reset_precs
1681
- result = []
1740
+ result = Grammar::RuleBuilder.new(@rule_counter, @midrule_action_counter)
1682
1741
 
1683
1742
  result
1684
1743
  end
1685
1744
  .,.,
1686
1745
 
1687
- module_eval(<<'.,.,', 'parser.y', 299)
1746
+ module_eval(<<'.,.,', 'parser.y', 318)
1688
1747
  def _reduce_83(val, _values, result)
1689
1748
  reset_precs
1690
- result = []
1749
+ result = Grammar::RuleBuilder.new(@rule_counter, @midrule_action_counter)
1691
1750
 
1692
1751
  result
1693
1752
  end
1694
1753
  .,.,
1695
1754
 
1696
- module_eval(<<'.,.,', 'parser.y', 304)
1755
+ module_eval(<<'.,.,', 'parser.y', 323)
1697
1756
  def _reduce_84(val, _values, result)
1698
1757
  token = val[1]
1699
1758
  token.alias_name = val[2]
1700
- result = val[0].append(token)
1759
+ builder = val[0]
1760
+ builder.add_rhs(token)
1761
+ result = builder
1701
1762
 
1702
1763
  result
1703
1764
  end
1704
1765
  .,.,
1705
1766
 
1706
- module_eval(<<'.,.,', 'parser.y', 310)
1767
+ module_eval(<<'.,.,', 'parser.y', 331)
1707
1768
  def _reduce_85(val, _values, result)
1708
- token = Lrama::Lexer::Token::Parameterizing.new(s_value: val[1])
1709
- result = val[0].append(token)
1769
+ token = Lrama::Lexer::Token::Parameterizing.new(s_value: val[2], location: @lexer.location, args: [val[1]])
1770
+ builder = val[0]
1771
+ builder.add_rhs(token)
1772
+ result = builder
1710
1773
 
1711
1774
  result
1712
1775
  end
1713
1776
  .,.,
1714
1777
 
1715
- module_eval(<<'.,.,', 'parser.y', 315)
1778
+ module_eval(<<'.,.,', 'parser.y', 338)
1716
1779
  def _reduce_86(val, _values, result)
1717
- token = Lrama::Lexer::Token::Parameterizing.new(s_value: val[1])
1718
- result = val[0].append(token)
1780
+ token = Lrama::Lexer::Token::Parameterizing.new(s_value: val[1].s_value, location: @lexer.location, args: [val[3]])
1781
+ builder = val[0]
1782
+ builder.add_rhs(token)
1783
+ result = builder
1719
1784
 
1720
1785
  result
1721
1786
  end
1722
1787
  .,.,
1723
1788
 
1724
- module_eval(<<'.,.,', 'parser.y', 320)
1789
+ module_eval(<<'.,.,', 'parser.y', 345)
1725
1790
  def _reduce_87(val, _values, result)
1726
- token = Lrama::Lexer::Token::Parameterizing.new(s_value: val[1])
1727
- result = val[0].append(token)
1791
+ token = Lrama::Lexer::Token::Parameterizing.new(s_value: val[1].s_value, location: @lexer.location, args: [val[3], val[5]])
1792
+ builder = val[0]
1793
+ builder.add_rhs(token)
1794
+ result = builder
1728
1795
 
1729
1796
  result
1730
1797
  end
1731
1798
  .,.,
1732
1799
 
1733
- module_eval(<<'.,.,', 'parser.y', 325)
1800
+ module_eval(<<'.,.,', 'parser.y', 352)
1734
1801
  def _reduce_88(val, _values, result)
1735
1802
  if @prec_seen
1736
- raise "Multiple User_code after %prec" if @code_after_prec
1803
+ on_action_error("multiple User_code after %prec", val[0]) if @code_after_prec
1737
1804
  @code_after_prec = true
1738
1805
  end
1739
1806
  begin_c_declaration("}")
@@ -1742,7 +1809,7 @@ module_eval(<<'.,.,', 'parser.y', 325)
1742
1809
  end
1743
1810
  .,.,
1744
1811
 
1745
- module_eval(<<'.,.,', 'parser.y', 333)
1812
+ module_eval(<<'.,.,', 'parser.y', 360)
1746
1813
  def _reduce_89(val, _values, result)
1747
1814
  end_c_declaration
1748
1815
 
@@ -1750,21 +1817,25 @@ module_eval(<<'.,.,', 'parser.y', 333)
1750
1817
  end
1751
1818
  .,.,
1752
1819
 
1753
- module_eval(<<'.,.,', 'parser.y', 337)
1820
+ module_eval(<<'.,.,', 'parser.y', 364)
1754
1821
  def _reduce_90(val, _values, result)
1755
1822
  token = val[3]
1756
1823
  token.alias_name = val[6]
1757
- result = val[0].append(token)
1824
+ builder = val[0]
1825
+ builder.user_code = token
1826
+ result = builder
1758
1827
 
1759
1828
  result
1760
1829
  end
1761
1830
  .,.,
1762
1831
 
1763
- module_eval(<<'.,.,', 'parser.y', 343)
1832
+ module_eval(<<'.,.,', 'parser.y', 372)
1764
1833
  def _reduce_91(val, _values, result)
1765
1834
  sym = @grammar.find_symbol_by_id!(val[2])
1766
- result = val[0].append(sym)
1767
1835
  @prec_seen = true
1836
+ builder = val[0]
1837
+ builder.precedence_sym = sym
1838
+ result = builder
1768
1839
 
1769
1840
  result
1770
1841
  end
@@ -1772,19 +1843,25 @@ module_eval(<<'.,.,', 'parser.y', 343)
1772
1843
 
1773
1844
  # reduce 92 omitted
1774
1845
 
1775
- module_eval(<<'.,.,', 'parser.y', 349)
1776
- def _reduce_93(val, _values, result)
1846
+ # reduce 93 omitted
1847
+
1848
+ # reduce 94 omitted
1849
+
1850
+ # reduce 95 omitted
1851
+
1852
+ module_eval(<<'.,.,', 'parser.y', 384)
1853
+ def _reduce_96(val, _values, result)
1777
1854
  result = val[1].s_value
1778
1855
  result
1779
1856
  end
1780
1857
  .,.,
1781
1858
 
1782
- # reduce 94 omitted
1859
+ # reduce 97 omitted
1783
1860
 
1784
- # reduce 95 omitted
1861
+ # reduce 98 omitted
1785
1862
 
1786
- module_eval(<<'.,.,', 'parser.y', 356)
1787
- def _reduce_96(val, _values, result)
1863
+ module_eval(<<'.,.,', 'parser.y', 391)
1864
+ def _reduce_99(val, _values, result)
1788
1865
  begin_c_declaration('\Z')
1789
1866
  @grammar.epilogue_first_lineno = @lexer.line + 1
1790
1867
 
@@ -1792,8 +1869,8 @@ module_eval(<<'.,.,', 'parser.y', 356)
1792
1869
  end
1793
1870
  .,.,
1794
1871
 
1795
- module_eval(<<'.,.,', 'parser.y', 361)
1796
- def _reduce_97(val, _values, result)
1872
+ module_eval(<<'.,.,', 'parser.y', 396)
1873
+ def _reduce_100(val, _values, result)
1797
1874
  end_c_declaration
1798
1875
  @grammar.epilogue = val[2].s_value
1799
1876
 
@@ -1801,36 +1878,36 @@ module_eval(<<'.,.,', 'parser.y', 361)
1801
1878
  end
1802
1879
  .,.,
1803
1880
 
1804
- # reduce 98 omitted
1881
+ # reduce 101 omitted
1805
1882
 
1806
- # reduce 99 omitted
1883
+ # reduce 102 omitted
1807
1884
 
1808
- # reduce 100 omitted
1885
+ # reduce 103 omitted
1809
1886
 
1810
- # reduce 101 omitted
1887
+ # reduce 104 omitted
1811
1888
 
1812
- # reduce 102 omitted
1889
+ # reduce 105 omitted
1813
1890
 
1814
- module_eval(<<'.,.,', 'parser.y', 372)
1815
- def _reduce_103(val, _values, result)
1891
+ module_eval(<<'.,.,', 'parser.y', 407)
1892
+ def _reduce_106(val, _values, result)
1816
1893
  result = [val[0]]
1817
1894
  result
1818
1895
  end
1819
1896
  .,.,
1820
1897
 
1821
- module_eval(<<'.,.,', 'parser.y', 373)
1822
- def _reduce_104(val, _values, result)
1898
+ module_eval(<<'.,.,', 'parser.y', 408)
1899
+ def _reduce_107(val, _values, result)
1823
1900
  result = val[0].append(val[1])
1824
1901
  result
1825
1902
  end
1826
1903
  .,.,
1827
1904
 
1828
- # reduce 105 omitted
1905
+ # reduce 108 omitted
1829
1906
 
1830
- # reduce 106 omitted
1907
+ # reduce 109 omitted
1831
1908
 
1832
- module_eval(<<'.,.,', 'parser.y', 378)
1833
- def _reduce_107(val, _values, result)
1909
+ module_eval(<<'.,.,', 'parser.y', 413)
1910
+ def _reduce_110(val, _values, result)
1834
1911
  result = Lrama::Lexer::Token::Ident.new(s_value: val[0])
1835
1912
  result
1836
1913
  end