lrama 0.6.10 → 0.6.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yaml +5 -1
  3. data/Gemfile +2 -2
  4. data/NEWS.md +65 -30
  5. data/Steepfile +3 -0
  6. data/doc/development/compressed_state_table/main.md +635 -0
  7. data/doc/development/compressed_state_table/parse.output +174 -0
  8. data/doc/development/compressed_state_table/parse.y +22 -0
  9. data/doc/development/compressed_state_table/parser.rb +282 -0
  10. data/lib/lrama/bitmap.rb +1 -1
  11. data/lib/lrama/context.rb +3 -3
  12. data/lib/lrama/counterexamples/derivation.rb +6 -5
  13. data/lib/lrama/counterexamples/example.rb +7 -4
  14. data/lib/lrama/counterexamples/path.rb +4 -0
  15. data/lib/lrama/counterexamples.rb +19 -9
  16. data/lib/lrama/grammar/parameterizing_rule/rhs.rb +1 -1
  17. data/lib/lrama/grammar/rule_builder.rb +1 -1
  18. data/lib/lrama/grammar/symbols/resolver.rb +4 -0
  19. data/lib/lrama/grammar.rb +2 -2
  20. data/lib/lrama/lexer/token/user_code.rb +1 -1
  21. data/lib/lrama/lexer.rb +1 -0
  22. data/lib/lrama/parser.rb +520 -487
  23. data/lib/lrama/state/reduce.rb +2 -3
  24. data/lib/lrama/version.rb +1 -1
  25. data/parser.y +38 -27
  26. data/rbs_collection.lock.yaml +10 -2
  27. data/sig/lrama/counterexamples/derivation.rbs +33 -0
  28. data/sig/lrama/counterexamples/example.rbs +45 -0
  29. data/sig/lrama/counterexamples/path.rbs +21 -0
  30. data/sig/lrama/counterexamples/production_path.rbs +11 -0
  31. data/sig/lrama/counterexamples/start_path.rbs +13 -0
  32. data/sig/lrama/counterexamples/state_item.rbs +10 -0
  33. data/sig/lrama/counterexamples/transition_path.rbs +11 -0
  34. data/sig/lrama/counterexamples/triple.rbs +20 -0
  35. data/sig/lrama/counterexamples.rbs +29 -0
  36. data/sig/lrama/grammar/symbol.rbs +1 -1
  37. data/sig/lrama/grammar/symbols/resolver.rbs +3 -3
  38. data/sig/lrama/grammar.rbs +13 -0
  39. data/sig/lrama/state/reduce_reduce_conflict.rbs +2 -2
  40. data/sig/lrama/state.rbs +79 -0
  41. data/sig/lrama/states.rbs +101 -0
  42. metadata +17 -2
@@ -16,7 +16,7 @@ module Lrama
16
16
  return unless user_code
17
17
 
18
18
  resolved = Lexer::Token::UserCode.new(s_value: user_code.s_value, location: user_code.location)
19
- var_to_arg = {}
19
+ var_to_arg = {} #: Hash[String, String]
20
20
  symbols.each do |sym|
21
21
  resolved_sym = bindings.resolve_symbol(sym)
22
22
  if resolved_sym != sym
@@ -67,7 +67,7 @@ module Lrama
67
67
  end
68
68
 
69
69
  def resolve_inline_rules
70
- resolved_builders = []
70
+ resolved_builders = [] #: Array[RuleBuilder]
71
71
  rhs.each_with_index do |token, i|
72
72
  if (inline_rule = @parameterizing_rule_resolver.find_inline(token))
73
73
  inline_rule.rhs_list.each do |inline_rhs|
@@ -57,6 +57,10 @@ module Lrama
57
57
  nterm
58
58
  end
59
59
 
60
+ def find_term_by_s_value(s_value)
61
+ terms.find { |s| s.id.s_value == s_value }
62
+ end
63
+
60
64
  def find_symbol_by_s_value(s_value)
61
65
  symbols.find { |s| s.id.s_value == s_value }
62
66
  end
data/lib/lrama/grammar.rb CHANGED
@@ -30,7 +30,7 @@ module Lrama
30
30
  :after_shift, :before_reduce, :after_reduce, :after_shift_error_token, :after_pop_stack,
31
31
  :symbols_resolver, :types, :rules, :rule_builders, :sym_to_rules, :no_stdlib, :locations
32
32
 
33
- def_delegators "@symbols_resolver", :symbols, :nterms, :terms, :add_nterm, :add_term,
33
+ def_delegators "@symbols_resolver", :symbols, :nterms, :terms, :add_nterm, :add_term, :find_term_by_s_value,
34
34
  :find_symbol_by_number!, :find_symbol_by_id!, :token_to_symbol,
35
35
  :find_symbol_by_s_value!, :fill_symbol_number, :fill_nterm_type,
36
36
  :fill_printer, :fill_destructor, :fill_error_token, :sort_by_number!
@@ -382,7 +382,7 @@ module Lrama
382
382
  end
383
383
 
384
384
  def validate_rule_lhs_is_nterm!
385
- errors = []
385
+ errors = [] #: Array[String]
386
386
 
387
387
  rules.each do |rule|
388
388
  next if rule.lhs.nterm?
@@ -16,7 +16,7 @@ module Lrama
16
16
 
17
17
  def _references
18
18
  scanner = StringScanner.new(s_value)
19
- references = []
19
+ references = [] #: Array[Grammar::Reference]
20
20
 
21
21
  until scanner.eos? do
22
22
  case
data/lib/lrama/lexer.rb CHANGED
@@ -16,6 +16,7 @@ module Lrama
16
16
  %union
17
17
  %token
18
18
  %type
19
+ %nterm
19
20
  %left
20
21
  %right
21
22
  %nonassoc