cybrid_api_organization_ruby 0.73.0 → 0.73.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +4 -2
  3. data/README.md +5 -5
  4. data/cybrid_api_organization_ruby.gemspec +1 -1
  5. data/lib/cybrid_api_organization_ruby/api/organizations_organization_api.rb +1 -1
  6. data/lib/cybrid_api_organization_ruby/api_client.rb +1 -1
  7. data/lib/cybrid_api_organization_ruby/api_error.rb +1 -1
  8. data/lib/cybrid_api_organization_ruby/configuration.rb +1 -1
  9. data/lib/cybrid_api_organization_ruby/models/error_response_organization_model.rb +1 -1
  10. data/lib/cybrid_api_organization_ruby/models/organization_organization_model.rb +1 -1
  11. data/lib/cybrid_api_organization_ruby/models/patch_organization_organization_model.rb +1 -1
  12. data/lib/cybrid_api_organization_ruby/version.rb +2 -2
  13. data/lib/cybrid_api_organization_ruby.rb +1 -1
  14. data/spec/api/organizations_organization_api_spec.rb +1 -1
  15. data/spec/api_client_spec.rb +1 -1
  16. data/spec/configuration_spec.rb +1 -1
  17. data/spec/models/error_response_organization_model_spec.rb +1 -1
  18. data/spec/models/organization_organization_model_spec.rb +1 -1
  19. data/spec/models/patch_organization_organization_model_spec.rb +1 -1
  20. data/spec/spec_helper.rb +1 -1
  21. data/vendor/bundle/ruby/3.2.0/bin/racc +29 -0
  22. data/vendor/bundle/ruby/3.2.0/cache/parser-3.2.2.3.gem +0 -0
  23. data/vendor/bundle/ruby/3.2.0/cache/racc-1.7.0.gem +0 -0
  24. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/byebug-11.1.3/gem_make.out +5 -5
  25. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/ffi-1.15.5/gem_make.out +5 -5
  26. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/jaro_winkler-1.5.6/gem_make.out +5 -5
  27. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/psych-5.1.0/gem_make.out +5 -5
  28. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/racc-1.7.0/gem.build_complete +0 -0
  29. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/racc-1.7.0/gem_make.out +28 -0
  30. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/racc-1.7.0/mkmf.log +57 -0
  31. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/racc-1.7.0/racc/cparse.so +0 -0
  32. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/stringio-3.0.7/gem_make.out +5 -5
  33. data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/macruby.rb +3 -1
  34. data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/ruby18.rb +3 -1
  35. data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/ruby19.rb +3 -1
  36. data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/ruby20.rb +3 -1
  37. data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/ruby21.rb +3 -1
  38. data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/ruby22.rb +3 -1
  39. data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/ruby23.rb +3 -1
  40. data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/ruby24.rb +3 -1
  41. data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/ruby25.rb +3 -1
  42. data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/ruby26.rb +3 -1
  43. data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/ruby27.rb +3 -1
  44. data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/ruby30.rb +3 -1
  45. data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/ruby31.rb +3 -1
  46. data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/ruby32.rb +3 -1
  47. data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/ruby33.rb +3 -1
  48. data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/rubymotion.rb +3 -1
  49. data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/version.rb +1 -1
  50. data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/parser.gemspec +1 -1
  51. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/COPYING +22 -0
  52. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/ChangeLog +846 -0
  53. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/README.ja.rdoc +94 -0
  54. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/README.rdoc +79 -0
  55. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/TODO +5 -0
  56. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/bin/racc +320 -0
  57. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/doc/en/NEWS.en.rdoc +282 -0
  58. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/doc/en/grammar.en.rdoc +226 -0
  59. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/doc/en/grammar2.en.rdoc +219 -0
  60. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/doc/ja/NEWS.ja.rdoc +307 -0
  61. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/doc/ja/command.ja.html +94 -0
  62. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/doc/ja/debug.ja.rdoc +36 -0
  63. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/doc/ja/grammar.ja.rdoc +348 -0
  64. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/doc/ja/index.ja.html +10 -0
  65. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/doc/ja/parser.ja.rdoc +125 -0
  66. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/doc/ja/usage.ja.html +414 -0
  67. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/ext/racc/MANIFEST +4 -0
  68. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/ext/racc/cparse/Makefile +269 -0
  69. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/ext/racc/cparse/cparse.c +861 -0
  70. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/ext/racc/cparse/extconf.rb +9 -0
  71. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/lib/racc/compat.rb +33 -0
  72. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/lib/racc/cparse.so +0 -0
  73. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/lib/racc/debugflags.rb +60 -0
  74. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/lib/racc/exception.rb +16 -0
  75. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/lib/racc/grammar.rb +1114 -0
  76. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/lib/racc/grammarfileparser.rb +561 -0
  77. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/lib/racc/info.rb +17 -0
  78. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/lib/racc/iset.rb +92 -0
  79. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/lib/racc/logfilegenerator.rb +212 -0
  80. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/lib/racc/parser-text.rb +658 -0
  81. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/lib/racc/parser.rb +632 -0
  82. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/lib/racc/parserfilegenerator.rb +470 -0
  83. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/lib/racc/sourcetext.rb +35 -0
  84. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/lib/racc/state.rb +972 -0
  85. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/lib/racc/statetransitiontable.rb +311 -0
  86. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/lib/racc/static.rb +5 -0
  87. data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.0/lib/racc.rb +6 -0
  88. data/vendor/bundle/ruby/3.2.0/specifications/{parser-3.2.2.1.gemspec → parser-3.2.2.3.gemspec} +5 -5
  89. data/vendor/bundle/ruby/3.2.0/specifications/racc-1.7.0.gemspec +27 -0
  90. metadata +127 -83
  91. data/vendor/bundle/ruby/3.2.0/cache/parser-3.2.2.1.gem +0 -0
  92. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/LICENSE.txt +0 -0
  93. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/bin/ruby-parse +0 -0
  94. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/bin/ruby-rewrite +0 -0
  95. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/gauntlet_parser.rb +0 -0
  96. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/all.rb +0 -0
  97. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/ast/node.rb +0 -0
  98. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/ast/processor.rb +0 -0
  99. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/base.rb +0 -0
  100. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/builders/default.rb +0 -0
  101. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/clobbering_error.rb +0 -0
  102. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/color.rb +0 -0
  103. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/context.rb +0 -0
  104. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/current.rb +0 -0
  105. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/current_arg_stack.rb +0 -0
  106. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/deprecation.rb +0 -0
  107. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/diagnostic/engine.rb +0 -0
  108. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/diagnostic.rb +0 -0
  109. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/lexer/dedenter.rb +0 -0
  110. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/lexer/explanation.rb +0 -0
  111. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/lexer/literal.rb +0 -0
  112. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/lexer/stack_state.rb +0 -0
  113. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/lexer-F0.rb +0 -0
  114. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/lexer-F1.rb +0 -0
  115. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/lexer-strings.rb +0 -0
  116. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/max_numparam_stack.rb +0 -0
  117. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/messages.rb +0 -0
  118. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/meta.rb +0 -0
  119. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/rewriter.rb +0 -0
  120. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/ruby28.rb +0 -0
  121. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/runner/ruby_parse.rb +0 -0
  122. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/runner/ruby_rewrite.rb +0 -0
  123. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/runner.rb +0 -0
  124. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/source/buffer.rb +0 -0
  125. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/source/comment/associator.rb +0 -0
  126. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/source/comment.rb +0 -0
  127. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/source/map/collection.rb +0 -0
  128. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/source/map/condition.rb +0 -0
  129. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/source/map/constant.rb +0 -0
  130. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/source/map/definition.rb +0 -0
  131. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/source/map/for.rb +0 -0
  132. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/source/map/heredoc.rb +0 -0
  133. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/source/map/index.rb +0 -0
  134. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/source/map/keyword.rb +0 -0
  135. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/source/map/method_definition.rb +0 -0
  136. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/source/map/objc_kwarg.rb +0 -0
  137. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/source/map/operator.rb +0 -0
  138. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/source/map/rescue_body.rb +0 -0
  139. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/source/map/send.rb +0 -0
  140. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/source/map/ternary.rb +0 -0
  141. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/source/map/variable.rb +0 -0
  142. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/source/map.rb +0 -0
  143. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/source/range.rb +0 -0
  144. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/source/rewriter/action.rb +0 -0
  145. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/source/rewriter.rb +0 -0
  146. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/source/tree_rewriter/action.rb +0 -0
  147. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/source/tree_rewriter.rb +0 -0
  148. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/static_environment.rb +0 -0
  149. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/syntax_error.rb +0 -0
  150. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/tree_rewriter.rb +0 -0
  151. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser/variables_stack.rb +0 -0
  152. /data/vendor/bundle/ruby/3.2.0/gems/{parser-3.2.2.1 → parser-3.2.2.3}/lib/parser.rb +0 -0
@@ -0,0 +1,972 @@
1
+ #--
2
+ #
3
+ #
4
+ #
5
+ # Copyright (c) 1999-2006 Minero Aoki
6
+ #
7
+ # This program is free software.
8
+ # You can distribute/modify this program under the same terms of ruby.
9
+ # see the file "COPYING".
10
+ #
11
+ #++
12
+
13
+ require 'racc/iset'
14
+ require 'racc/statetransitiontable'
15
+ require 'racc/exception'
16
+ require 'forwardable'
17
+
18
+ module Racc
19
+
20
+ # A table of LALR states.
21
+ class States
22
+
23
+ include Enumerable
24
+
25
+ def initialize(grammar, debug_flags = DebugFlags.new)
26
+ @grammar = grammar
27
+ @symboltable = grammar.symboltable
28
+ @d_state = debug_flags.state
29
+ @d_la = debug_flags.la
30
+ @d_prec = debug_flags.prec
31
+ @states = []
32
+ @statecache = {}
33
+ @actions = ActionTable.new(@grammar, self)
34
+ @nfa_computed = false
35
+ @dfa_computed = false
36
+ end
37
+
38
+ attr_reader :grammar
39
+ attr_reader :actions
40
+
41
+ def size
42
+ @states.size
43
+ end
44
+
45
+ def inspect
46
+ '#<state table>'
47
+ end
48
+
49
+ alias to_s inspect
50
+
51
+ def [](i)
52
+ @states[i]
53
+ end
54
+
55
+ def each_state(&block)
56
+ @states.each(&block)
57
+ end
58
+
59
+ alias each each_state
60
+
61
+ def each_index(&block)
62
+ @states.each_index(&block)
63
+ end
64
+
65
+ extend Forwardable
66
+
67
+ def_delegator "@actions", :shift_n
68
+ def_delegator "@actions", :reduce_n
69
+ def_delegator "@actions", :nt_base
70
+
71
+ def should_report_srconflict?
72
+ srconflict_exist? and
73
+ (n_srconflicts() != @grammar.n_expected_srconflicts)
74
+ end
75
+
76
+ def srconflict_exist?
77
+ n_srconflicts() != 0
78
+ end
79
+
80
+ def n_srconflicts
81
+ @n_srconflicts ||= inject(0) {|sum, st| sum + st.n_srconflicts }
82
+ end
83
+
84
+ def rrconflict_exist?
85
+ n_rrconflicts() != 0
86
+ end
87
+
88
+ def n_rrconflicts
89
+ @n_rrconflicts ||= inject(0) {|sum, st| sum + st.n_rrconflicts }
90
+ end
91
+
92
+ def state_transition_table
93
+ @state_transition_table ||= StateTransitionTable.generate(self.dfa)
94
+ end
95
+
96
+ #
97
+ # NFA (Non-deterministic Finite Automaton) Computation
98
+ #
99
+
100
+ public
101
+
102
+ def nfa
103
+ return self if @nfa_computed
104
+ compute_nfa
105
+ @nfa_computed = true
106
+ self
107
+ end
108
+
109
+ private
110
+
111
+ def compute_nfa
112
+ @grammar.init
113
+ # add state 0
114
+ core_to_state [ @grammar[0].ptrs[0] ]
115
+ # generate LALR states
116
+ cur = 0
117
+ @gotos = []
118
+ while cur < @states.size
119
+ generate_states @states[cur] # state is added here
120
+ cur += 1
121
+ end
122
+ @actions.init
123
+ end
124
+
125
+ def generate_states(state)
126
+ puts "dstate: #{state}" if @d_state
127
+
128
+ table = {}
129
+ state.closure.each do |ptr|
130
+ if sym = ptr.dereference
131
+ addsym table, sym, ptr.next
132
+ end
133
+ end
134
+ table.each do |sym, core|
135
+ puts "dstate: sym=#{sym} ncore=#{core}" if @d_state
136
+
137
+ dest = core_to_state(core.to_a)
138
+ state.goto_table[sym] = dest
139
+ id = sym.nonterminal?() ? @gotos.size : nil
140
+ g = Goto.new(id, sym, state, dest)
141
+ @gotos.push g if sym.nonterminal?
142
+ state.gotos[sym] = g
143
+ puts "dstate: #{state.ident} --#{sym}--> #{dest.ident}" if @d_state
144
+
145
+ # check infinite recursion
146
+ if state.ident == dest.ident and state.closure.size == 1
147
+ raise CompileError,
148
+ sprintf("Infinite recursion: state %d, with rule %d",
149
+ state.ident, state.ptrs[0].rule.ident)
150
+ end
151
+ end
152
+ end
153
+
154
+ def addsym(table, sym, ptr)
155
+ unless s = table[sym]
156
+ table[sym] = s = ISet.new
157
+ end
158
+ s.add ptr
159
+ end
160
+
161
+ def core_to_state(core)
162
+ #
163
+ # convert CORE to a State object.
164
+ # If matching state does not exist, create it and add to the table.
165
+ #
166
+
167
+ k = fingerprint(core)
168
+ unless dest = @statecache[k]
169
+ # not registered yet
170
+ dest = State.new(@states.size, core)
171
+ @states.push dest
172
+
173
+ @statecache[k] = dest
174
+
175
+ puts "core_to_state: create state ID #{dest.ident}" if @d_state
176
+ else
177
+ if @d_state
178
+ puts "core_to_state: dest is cached ID #{dest.ident}"
179
+ puts "core_to_state: dest core #{dest.core.join(' ')}"
180
+ end
181
+ end
182
+
183
+ dest
184
+ end
185
+
186
+ def fingerprint(arr)
187
+ arr.map {|i| i.ident }.pack('L*')
188
+ end
189
+
190
+ #
191
+ # DFA (Deterministic Finite Automaton) Generation
192
+ #
193
+
194
+ public
195
+
196
+ def dfa
197
+ return self if @dfa_computed
198
+ nfa
199
+ compute_dfa
200
+ @dfa_computed = true
201
+ self
202
+ end
203
+
204
+ private
205
+
206
+ def compute_dfa
207
+ la = lookahead()
208
+ @states.each do |state|
209
+ state.la = la
210
+ resolve state
211
+ end
212
+ set_accept
213
+ @states.each do |state|
214
+ pack state
215
+ end
216
+ check_useless
217
+ end
218
+
219
+ def lookahead
220
+ #
221
+ # lookahead algorithm ver.3 -- from bison 1.26
222
+ #
223
+
224
+ gotos = @gotos
225
+ if @d_la
226
+ puts "\n--- goto ---"
227
+ gotos.each_with_index {|g, i| print i, ' '; p g }
228
+ end
229
+
230
+ ### initialize_LA()
231
+ ### set_goto_map()
232
+ la_rules = []
233
+ @states.each do |state|
234
+ state.check_la la_rules
235
+ end
236
+
237
+ ### initialize_F()
238
+ f = create_tmap(gotos.size)
239
+ reads = []
240
+ edge = []
241
+ gotos.each do |goto|
242
+ goto.to_state.goto_table.each do |t, st|
243
+ if t.terminal?
244
+ f[goto.ident] |= (1 << t.ident)
245
+ elsif t.nullable?
246
+ edge.push goto.to_state.gotos[t].ident
247
+ end
248
+ end
249
+ if edge.empty?
250
+ reads.push nil
251
+ else
252
+ reads.push edge
253
+ edge = []
254
+ end
255
+ end
256
+ digraph f, reads
257
+ if @d_la
258
+ puts "\n--- F1 (reads) ---"
259
+ print_tab gotos, reads, f
260
+ end
261
+
262
+ ### build_relations()
263
+ ### compute_FOLLOWS
264
+ path = nil
265
+ edge = []
266
+ lookback = Array.new(la_rules.size, nil)
267
+ includes = []
268
+ gotos.each do |goto|
269
+ goto.symbol.heads.each do |ptr|
270
+ path = record_path(goto.from_state, ptr.rule)
271
+ lastgoto = path.last
272
+ st = lastgoto ? lastgoto.to_state : goto.from_state
273
+ if st.conflict?
274
+ addrel lookback, st.rruleid(ptr.rule), goto
275
+ end
276
+ path.reverse_each do |g|
277
+ break if g.symbol.terminal?
278
+ edge.push g.ident
279
+ break unless g.symbol.nullable?
280
+ end
281
+ end
282
+ if edge.empty?
283
+ includes.push nil
284
+ else
285
+ includes.push edge
286
+ edge = []
287
+ end
288
+ end
289
+ includes = transpose(includes)
290
+ digraph f, includes
291
+ if @d_la
292
+ puts "\n--- F2 (includes) ---"
293
+ print_tab gotos, includes, f
294
+ end
295
+
296
+ ### compute_lookaheads
297
+ la = create_tmap(la_rules.size)
298
+ lookback.each_with_index do |arr, i|
299
+ if arr
300
+ arr.each do |g|
301
+ la[i] |= f[g.ident]
302
+ end
303
+ end
304
+ end
305
+ if @d_la
306
+ puts "\n--- LA (lookback) ---"
307
+ print_tab la_rules, lookback, la
308
+ end
309
+
310
+ la
311
+ end
312
+
313
+ def create_tmap(size)
314
+ Array.new(size, 0) # use Integer as bitmap
315
+ end
316
+
317
+ def addrel(tbl, i, item)
318
+ if a = tbl[i]
319
+ a.push item
320
+ else
321
+ tbl[i] = [item]
322
+ end
323
+ end
324
+
325
+ def record_path(begst, rule)
326
+ st = begst
327
+ path = []
328
+ rule.symbols.each do |t|
329
+ goto = st.gotos[t]
330
+ path.push goto
331
+ st = goto.to_state
332
+ end
333
+ path
334
+ end
335
+
336
+ def transpose(rel)
337
+ new = Array.new(rel.size, nil)
338
+ rel.each_with_index do |arr, idx|
339
+ if arr
340
+ arr.each do |i|
341
+ addrel new, i, idx
342
+ end
343
+ end
344
+ end
345
+ new
346
+ end
347
+
348
+ def digraph(map, relation)
349
+ n = relation.size
350
+ index = Array.new(n, nil)
351
+ vertices = []
352
+ @infinity = n + 2
353
+
354
+ index.each_index do |i|
355
+ if not index[i] and relation[i]
356
+ traverse i, index, vertices, map, relation
357
+ end
358
+ end
359
+ end
360
+
361
+ def traverse(i, index, vertices, map, relation)
362
+ vertices.push i
363
+ index[i] = height = vertices.size
364
+
365
+ if rp = relation[i]
366
+ rp.each do |proci|
367
+ unless index[proci]
368
+ traverse proci, index, vertices, map, relation
369
+ end
370
+ if index[i] > index[proci]
371
+ # circulative recursion !!!
372
+ index[i] = index[proci]
373
+ end
374
+ map[i] |= map[proci]
375
+ end
376
+ end
377
+
378
+ if index[i] == height
379
+ while true
380
+ proci = vertices.pop
381
+ index[proci] = @infinity
382
+ break if i == proci
383
+
384
+ map[proci] |= map[i]
385
+ end
386
+ end
387
+ end
388
+
389
+ # for debug
390
+ def print_atab(idx, tab)
391
+ tab.each_with_index do |i,ii|
392
+ printf '%-20s', idx[ii].inspect
393
+ p i
394
+ end
395
+ end
396
+
397
+ def print_tab(idx, rel, tab)
398
+ tab.each_with_index do |bin,i|
399
+ print i, ' ', idx[i].inspect, ' << '; p rel[i]
400
+ print ' '
401
+ each_t(@symboltable, bin) {|t| print ' ', t }
402
+ puts
403
+ end
404
+ end
405
+
406
+ # for debug
407
+ def print_tab_i(idx, rel, tab, i)
408
+ bin = tab[i]
409
+ print i, ' ', idx[i].inspect, ' << '; p rel[i]
410
+ print ' '
411
+ each_t(@symboltable, bin) {|t| print ' ', t }
412
+ end
413
+
414
+ # for debug
415
+ def printb(i)
416
+ each_t(@symboltable, i) do |t|
417
+ print t, ' '
418
+ end
419
+ puts
420
+ end
421
+
422
+ def each_t(tbl, set)
423
+ 0.upto( set.size ) do |i|
424
+ (0..7).each do |ii|
425
+ if set[idx = i * 8 + ii] == 1
426
+ yield tbl[idx]
427
+ end
428
+ end
429
+ end
430
+ end
431
+
432
+ #
433
+ # resolve
434
+ #
435
+
436
+ def resolve(state)
437
+ if state.conflict?
438
+ resolve_rr state, state.ritems
439
+ resolve_sr state, state.stokens
440
+ else
441
+ if state.rrules.empty?
442
+ # shift
443
+ state.stokens.each do |t|
444
+ state.action[t] = @actions.shift(state.goto_table[t])
445
+ end
446
+ else
447
+ # reduce
448
+ state.defact = @actions.reduce(state.rrules[0])
449
+ end
450
+ end
451
+ end
452
+
453
+ def resolve_rr(state, r)
454
+ r.each do |item|
455
+ item.each_la(@symboltable) do |t|
456
+ act = state.action[t]
457
+ if act
458
+ unless act.kind_of?(Reduce)
459
+ raise "racc: fatal: #{act.class} in action table"
460
+ end
461
+ # Cannot resolve R/R conflict (on t).
462
+ # Reduce with upper rule as default.
463
+ state.rr_conflict act.rule, item.rule, t
464
+ else
465
+ # No conflict.
466
+ state.action[t] = @actions.reduce(item.rule)
467
+ end
468
+ end
469
+ end
470
+ end
471
+
472
+ def resolve_sr(state, s)
473
+ s.each do |stok|
474
+ goto = state.goto_table[stok]
475
+ act = state.action[stok]
476
+
477
+ unless act
478
+ # no conflict
479
+ state.action[stok] = @actions.shift(goto)
480
+ else
481
+ unless act.kind_of?(Reduce)
482
+ puts 'DEBUG -------------------------------'
483
+ p stok
484
+ p act
485
+ state.action.each do |k,v|
486
+ print k.inspect, ' ', v.inspect, "\n"
487
+ end
488
+ raise "racc: fatal: #{act.class} in action table"
489
+ end
490
+
491
+ # conflict on stok
492
+
493
+ rtok = act.rule.precedence
494
+ case do_resolve_sr(stok, rtok)
495
+ when :Reduce
496
+ # action is already set
497
+
498
+ when :Shift
499
+ # overwrite
500
+ act.decref
501
+ state.action[stok] = @actions.shift(goto)
502
+
503
+ when :Error
504
+ act.decref
505
+ state.action[stok] = @actions.error
506
+
507
+ when :CantResolve
508
+ # shift as default
509
+ act.decref
510
+ state.action[stok] = @actions.shift(goto)
511
+ state.sr_conflict stok, act.rule
512
+ end
513
+ end
514
+ end
515
+ end
516
+
517
+ ASSOC = {
518
+ :Left => :Reduce,
519
+ :Right => :Shift,
520
+ :Nonassoc => :Error
521
+ }
522
+
523
+ def do_resolve_sr(stok, rtok)
524
+ puts "resolve_sr: s/r conflict: rtok=#{rtok}, stok=#{stok}" if @d_prec
525
+
526
+ unless rtok and rtok.precedence
527
+ puts "resolve_sr: no prec for #{rtok}(R)" if @d_prec
528
+ return :CantResolve
529
+ end
530
+ rprec = rtok.precedence
531
+
532
+ unless stok and stok.precedence
533
+ puts "resolve_sr: no prec for #{stok}(S)" if @d_prec
534
+ return :CantResolve
535
+ end
536
+ sprec = stok.precedence
537
+
538
+ ret = if rprec == sprec
539
+ ASSOC[rtok.assoc] or
540
+ raise "racc: fatal: #{rtok}.assoc is not Left/Right/Nonassoc"
541
+ else
542
+ (rprec > sprec) ? (:Reduce) : (:Shift)
543
+ end
544
+
545
+ puts "resolve_sr: resolved as #{ret.id2name}" if @d_prec
546
+ ret
547
+ end
548
+
549
+ #
550
+ # complete
551
+ #
552
+
553
+ def set_accept
554
+ anch = @symboltable.anchor
555
+ init_state = @states[0].goto_table[@grammar.start]
556
+ targ_state = init_state.action[anch].goto_state
557
+ acc_state = targ_state.action[anch].goto_state
558
+
559
+ acc_state.action.clear
560
+ acc_state.goto_table.clear
561
+ acc_state.defact = @actions.accept
562
+ end
563
+
564
+ def pack(state)
565
+ ### find most frequently used reduce rule
566
+ act = state.action
567
+ arr = Array.new(@grammar.size, 0)
568
+ act.each do |t, a|
569
+ arr[a.ruleid] += 1 if a.kind_of?(Reduce)
570
+ end
571
+ i = arr.max
572
+ s = (i > 0) ? arr.index(i) : nil
573
+
574
+ ### set & delete default action
575
+ if s
576
+ r = @actions.reduce(s)
577
+ if not state.defact or state.defact == r
578
+ act.delete_if {|t, a| a == r }
579
+ state.defact = r
580
+ end
581
+ else
582
+ state.defact ||= @actions.error
583
+ end
584
+ end
585
+
586
+ def check_useless
587
+ used = []
588
+ @actions.each_reduce do |act|
589
+ if not act or act.refn == 0
590
+ act.rule.useless = true
591
+ else
592
+ t = act.rule.target
593
+ used[t.ident] = t
594
+ end
595
+ end
596
+ @symboltable.nt_base.upto(@symboltable.nt_max - 1) do |n|
597
+ unless used[n]
598
+ @symboltable[n].useless = true
599
+ end
600
+ end
601
+ end
602
+
603
+ end # class StateTable
604
+
605
+
606
+ # A LALR state.
607
+ class State
608
+
609
+ def initialize(ident, core)
610
+ @ident = ident
611
+ @core = core
612
+ @goto_table = {}
613
+ @gotos = {}
614
+ @stokens = nil
615
+ @ritems = nil
616
+ @action = {}
617
+ @defact = nil
618
+ @rrconf = nil
619
+ @srconf = nil
620
+
621
+ @closure = make_closure(@core)
622
+ end
623
+
624
+ attr_reader :ident
625
+ alias stateid ident
626
+ alias hash ident
627
+
628
+ attr_reader :core
629
+ attr_reader :closure
630
+
631
+ attr_reader :goto_table
632
+ attr_reader :gotos
633
+
634
+ attr_reader :stokens
635
+ attr_reader :ritems
636
+ attr_reader :rrules
637
+
638
+ attr_reader :action
639
+ attr_accessor :defact # default action
640
+
641
+ attr_reader :rrconf
642
+ attr_reader :srconf
643
+
644
+ def inspect
645
+ "<state #{@ident}>"
646
+ end
647
+
648
+ alias to_s inspect
649
+
650
+ def ==(oth)
651
+ @ident == oth.ident
652
+ end
653
+
654
+ alias eql? ==
655
+
656
+ def make_closure(core)
657
+ set = ISet.new
658
+ core.each do |ptr|
659
+ set.add ptr
660
+ if t = ptr.dereference and t.nonterminal?
661
+ set.update_a t.expand
662
+ end
663
+ end
664
+ set.to_a
665
+ end
666
+
667
+ def check_la(la_rules)
668
+ @conflict = false
669
+ s = []
670
+ r = []
671
+ @closure.each do |ptr|
672
+ if t = ptr.dereference
673
+ if t.terminal?
674
+ s[t.ident] = t
675
+ if t.ident == 1 # $error
676
+ @conflict = true
677
+ end
678
+ end
679
+ else
680
+ r.push ptr.rule
681
+ end
682
+ end
683
+ unless r.empty?
684
+ if not s.empty? or r.size > 1
685
+ @conflict = true
686
+ end
687
+ end
688
+ s.compact!
689
+ @stokens = s
690
+ @rrules = r
691
+
692
+ if @conflict
693
+ @la_rules_i = la_rules.size
694
+ @la_rules = r.map {|i| i.ident }
695
+ la_rules.concat r
696
+ else
697
+ @la_rules_i = @la_rules = nil
698
+ end
699
+ end
700
+
701
+ def conflict?
702
+ @conflict
703
+ end
704
+
705
+ def rruleid(rule)
706
+ if i = @la_rules.index(rule.ident)
707
+ @la_rules_i + i
708
+ else
709
+ puts '/// rruleid'
710
+ p self
711
+ p rule
712
+ p @rrules
713
+ p @la_rules_i
714
+ raise 'racc: fatal: cannot get reduce rule id'
715
+ end
716
+ end
717
+
718
+ def la=(la)
719
+ return unless @conflict
720
+ i = @la_rules_i
721
+ @ritems = r = []
722
+ @rrules.each do |rule|
723
+ r.push Item.new(rule, la[i])
724
+ i += 1
725
+ end
726
+ end
727
+
728
+ def rr_conflict(high, low, ctok)
729
+ c = RRconflict.new(@ident, high, low, ctok)
730
+
731
+ @rrconf ||= {}
732
+ if a = @rrconf[ctok]
733
+ a.push c
734
+ else
735
+ @rrconf[ctok] = [c]
736
+ end
737
+ end
738
+
739
+ def sr_conflict(shift, reduce)
740
+ c = SRconflict.new(@ident, shift, reduce)
741
+
742
+ @srconf ||= {}
743
+ if a = @srconf[shift]
744
+ a.push c
745
+ else
746
+ @srconf[shift] = [c]
747
+ end
748
+ end
749
+
750
+ def n_srconflicts
751
+ @srconf ? @srconf.size : 0
752
+ end
753
+
754
+ def n_rrconflicts
755
+ @rrconf ? @rrconf.size : 0
756
+ end
757
+
758
+ end # class State
759
+
760
+
761
+ #
762
+ # Represents a transition on the grammar.
763
+ # "Real goto" means a transition by nonterminal,
764
+ # but this class treats also terminal's.
765
+ # If one is a terminal transition, .ident returns nil.
766
+ #
767
+ class Goto
768
+ def initialize(ident, sym, from, to)
769
+ @ident = ident
770
+ @symbol = sym
771
+ @from_state = from
772
+ @to_state = to
773
+ end
774
+
775
+ attr_reader :ident
776
+ attr_reader :symbol
777
+ attr_reader :from_state
778
+ attr_reader :to_state
779
+
780
+ def inspect
781
+ "(#{@from_state.ident}-#{@symbol}->#{@to_state.ident})"
782
+ end
783
+ end
784
+
785
+
786
+ # LALR item. A set of rule and its lookahead tokens.
787
+ class Item
788
+ def initialize(rule, la)
789
+ @rule = rule
790
+ @la = la
791
+ end
792
+
793
+ attr_reader :rule
794
+ attr_reader :la
795
+
796
+ def each_la(tbl)
797
+ la = @la
798
+ 0.upto(la.size - 1) do |i|
799
+ (0..7).each do |ii|
800
+ if la[idx = i * 8 + ii] == 1
801
+ yield tbl[idx]
802
+ end
803
+ end
804
+ end
805
+ end
806
+ end
807
+
808
+
809
+ # The table of LALR actions. Actions are either of
810
+ # Shift, Reduce, Accept and Error.
811
+ class ActionTable
812
+
813
+ def initialize(rt, st)
814
+ @grammar = rt
815
+ @statetable = st
816
+
817
+ @reduce = []
818
+ @shift = []
819
+ @accept = nil
820
+ @error = nil
821
+ end
822
+
823
+ def init
824
+ @grammar.each do |rule|
825
+ @reduce.push Reduce.new(rule)
826
+ end
827
+ @statetable.each do |state|
828
+ @shift.push Shift.new(state)
829
+ end
830
+ @accept = Accept.new
831
+ @error = Error.new
832
+ end
833
+
834
+ def reduce_n
835
+ @reduce.size
836
+ end
837
+
838
+ def reduce(i)
839
+ case i
840
+ when Rule then i = i.ident
841
+ when Integer then ;
842
+ else
843
+ raise "racc: fatal: wrong class #{i.class} for reduce"
844
+ end
845
+
846
+ r = @reduce[i] or raise "racc: fatal: reduce action #{i.inspect} not exist"
847
+ r.incref
848
+ r
849
+ end
850
+
851
+ def each_reduce(&block)
852
+ @reduce.each(&block)
853
+ end
854
+
855
+ def shift_n
856
+ @shift.size
857
+ end
858
+
859
+ def shift(i)
860
+ case i
861
+ when State then i = i.ident
862
+ when Integer then ;
863
+ else
864
+ raise "racc: fatal: wrong class #{i.class} for shift"
865
+ end
866
+
867
+ @shift[i] or raise "racc: fatal: shift action #{i} does not exist"
868
+ end
869
+
870
+ def each_shift(&block)
871
+ @shift.each(&block)
872
+ end
873
+
874
+ attr_reader :accept
875
+ attr_reader :error
876
+
877
+ end
878
+
879
+
880
+ class Shift
881
+ def initialize(goto)
882
+ @goto_state = goto
883
+ end
884
+
885
+ attr_reader :goto_state
886
+
887
+ def goto_id
888
+ @goto_state.ident
889
+ end
890
+
891
+ def inspect
892
+ "<shift #{@goto_state.ident}>"
893
+ end
894
+ end
895
+
896
+
897
+ class Reduce
898
+ def initialize(rule)
899
+ @rule = rule
900
+ @refn = 0
901
+ end
902
+
903
+ attr_reader :rule
904
+ attr_reader :refn
905
+
906
+ def ruleid
907
+ @rule.ident
908
+ end
909
+
910
+ def inspect
911
+ "<reduce #{@rule.ident}>"
912
+ end
913
+
914
+ def incref
915
+ @refn += 1
916
+ end
917
+
918
+ def decref
919
+ @refn -= 1
920
+ raise 'racc: fatal: act.refn < 0' if @refn < 0
921
+ end
922
+ end
923
+
924
+ class Accept
925
+ def inspect
926
+ "<accept>"
927
+ end
928
+ end
929
+
930
+ class Error
931
+ def inspect
932
+ "<error>"
933
+ end
934
+ end
935
+
936
+ class SRconflict
937
+ def initialize(sid, shift, reduce)
938
+ @stateid = sid
939
+ @shift = shift
940
+ @reduce = reduce
941
+ end
942
+
943
+ attr_reader :stateid
944
+ attr_reader :shift
945
+ attr_reader :reduce
946
+
947
+ def to_s
948
+ sprintf('state %d: S/R conflict rule %d reduce and shift %s',
949
+ @stateid, @reduce.ruleid, @shift.to_s)
950
+ end
951
+ end
952
+
953
+ class RRconflict
954
+ def initialize(sid, high, low, tok)
955
+ @stateid = sid
956
+ @high_prec = high
957
+ @low_prec = low
958
+ @token = tok
959
+ end
960
+
961
+ attr_reader :stateid
962
+ attr_reader :high_prec
963
+ attr_reader :low_prec
964
+ attr_reader :token
965
+
966
+ def to_s
967
+ sprintf('state %d: R/R conflict with rule %d and %d on %s',
968
+ @stateid, @high_prec.ident, @low_prec.ident, @token.to_s)
969
+ end
970
+ end
971
+
972
+ end