lrama 0.6.10 → 0.7.0
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.
- checksums.yaml +4 -4
- data/.github/workflows/gh-pages.yml +46 -0
- data/.github/workflows/test.yaml +40 -8
- data/.gitignore +1 -0
- data/.rdoc_options +2 -0
- data/Gemfile +4 -2
- data/NEWS.md +125 -30
- data/README.md +44 -15
- data/Rakefile +13 -1
- data/Steepfile +5 -0
- data/doc/Index.md +58 -0
- data/doc/development/compressed_state_table/main.md +635 -0
- data/doc/development/compressed_state_table/parse.output +174 -0
- data/doc/development/compressed_state_table/parse.y +22 -0
- data/doc/development/compressed_state_table/parser.rb +282 -0
- data/lib/lrama/bitmap.rb +4 -1
- data/lib/lrama/command.rb +2 -1
- data/lib/lrama/context.rb +3 -3
- data/lib/lrama/counterexamples/derivation.rb +6 -5
- data/lib/lrama/counterexamples/example.rb +7 -4
- data/lib/lrama/counterexamples/path.rb +4 -0
- data/lib/lrama/counterexamples.rb +19 -9
- data/lib/lrama/digraph.rb +30 -0
- data/lib/lrama/grammar/binding.rb +47 -15
- data/lib/lrama/grammar/parameterizing_rule/rhs.rb +1 -1
- data/lib/lrama/grammar/rule.rb +8 -0
- data/lib/lrama/grammar/rule_builder.rb +4 -16
- data/lib/lrama/grammar/symbols/resolver.rb +4 -0
- data/lib/lrama/grammar.rb +10 -5
- data/lib/lrama/lexer/grammar_file.rb +8 -1
- data/lib/lrama/lexer/location.rb +17 -1
- data/lib/lrama/lexer/token/char.rb +1 -0
- data/lib/lrama/lexer/token/ident.rb +1 -0
- data/lib/lrama/lexer/token/instantiate_rule.rb +6 -1
- data/lib/lrama/lexer/token/tag.rb +3 -1
- data/lib/lrama/lexer/token/user_code.rb +6 -2
- data/lib/lrama/lexer/token.rb +14 -2
- data/lib/lrama/lexer.rb +5 -5
- data/lib/lrama/logger.rb +4 -0
- data/lib/lrama/option_parser.rb +10 -8
- data/lib/lrama/options.rb +2 -1
- data/lib/lrama/parser.rb +529 -490
- data/lib/lrama/state/reduce.rb +2 -3
- data/lib/lrama/state.rb +288 -1
- data/lib/lrama/states/item.rb +8 -0
- data/lib/lrama/states.rb +69 -2
- data/lib/lrama/trace_reporter.rb +17 -2
- data/lib/lrama/version.rb +1 -1
- data/lrama.gemspec +1 -1
- data/parser.y +42 -30
- data/rbs_collection.lock.yaml +10 -2
- data/sig/generated/lrama/bitmap.rbs +11 -0
- data/sig/generated/lrama/digraph.rbs +39 -0
- data/sig/generated/lrama/grammar/binding.rbs +34 -0
- data/sig/generated/lrama/lexer/grammar_file.rbs +28 -0
- data/sig/generated/lrama/lexer/location.rbs +52 -0
- data/sig/{lrama → generated/lrama}/lexer/token/char.rbs +2 -0
- data/sig/{lrama → generated/lrama}/lexer/token/ident.rbs +2 -0
- data/sig/{lrama → generated/lrama}/lexer/token/instantiate_rule.rbs +8 -0
- data/sig/{lrama → generated/lrama}/lexer/token/tag.rbs +3 -0
- data/sig/{lrama → generated/lrama}/lexer/token/user_code.rbs +6 -1
- data/sig/{lrama → generated/lrama}/lexer/token.rbs +26 -3
- data/sig/generated/lrama/logger.rbs +14 -0
- data/sig/generated/lrama/trace_reporter.rbs +25 -0
- data/sig/lrama/counterexamples/derivation.rbs +33 -0
- data/sig/lrama/counterexamples/example.rbs +45 -0
- data/sig/lrama/counterexamples/path.rbs +21 -0
- data/sig/lrama/counterexamples/production_path.rbs +11 -0
- data/sig/lrama/counterexamples/start_path.rbs +13 -0
- data/sig/lrama/counterexamples/state_item.rbs +10 -0
- data/sig/lrama/counterexamples/transition_path.rbs +11 -0
- data/sig/lrama/counterexamples/triple.rbs +20 -0
- data/sig/lrama/counterexamples.rbs +29 -0
- data/sig/lrama/grammar/rule_builder.rbs +0 -1
- data/sig/lrama/grammar/symbol.rbs +1 -1
- data/sig/lrama/grammar/symbols/resolver.rbs +3 -3
- data/sig/lrama/grammar.rbs +13 -0
- data/sig/lrama/options.rbs +1 -0
- data/sig/lrama/state/reduce_reduce_conflict.rbs +2 -2
- data/sig/lrama/state.rbs +79 -0
- data/sig/lrama/states.rbs +101 -0
- metadata +34 -14
- data/sig/lrama/bitmap.rbs +0 -7
- data/sig/lrama/digraph.rbs +0 -23
- data/sig/lrama/grammar/binding.rbs +0 -19
- data/sig/lrama/lexer/grammar_file.rbs +0 -17
- data/sig/lrama/lexer/location.rbs +0 -26
data/rbs_collection.lock.yaml
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
---
|
2
2
|
path: ".gem_rbs_collection"
|
3
3
|
gems:
|
4
|
+
- name: diff-lcs
|
5
|
+
version: '1.5'
|
6
|
+
source:
|
7
|
+
type: git
|
8
|
+
name: ruby/gem_rbs_collection
|
9
|
+
revision: 7651e7b92c15bd5b4bc11fd3dd455be0ea571fd0
|
10
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
11
|
+
repo_dir: gems
|
4
12
|
- name: erb
|
5
13
|
version: '0'
|
6
14
|
source:
|
@@ -18,7 +26,7 @@ gems:
|
|
18
26
|
source:
|
19
27
|
type: git
|
20
28
|
name: ruby/gem_rbs_collection
|
21
|
-
revision:
|
29
|
+
revision: 7651e7b92c15bd5b4bc11fd3dd455be0ea571fd0
|
22
30
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
23
31
|
repo_dir: gems
|
24
32
|
- name: stackprof
|
@@ -26,7 +34,7 @@ gems:
|
|
26
34
|
source:
|
27
35
|
type: git
|
28
36
|
name: ruby/gem_rbs_collection
|
29
|
-
revision:
|
37
|
+
revision: 7651e7b92c15bd5b4bc11fd3dd455be0ea571fd0
|
30
38
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
31
39
|
repo_dir: gems
|
32
40
|
- name: strscan
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Generated from lib/lrama/bitmap.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Lrama
|
4
|
+
module Bitmap
|
5
|
+
# @rbs (Array[Integer] ary) -> Integer
|
6
|
+
def self.from_array: (Array[Integer] ary) -> Integer
|
7
|
+
|
8
|
+
# @rbs (Integer int) -> Array[Integer]
|
9
|
+
def self.to_array: (Integer int) -> Array[Integer]
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Generated from lib/lrama/digraph.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Lrama
|
4
|
+
# Algorithm Digraph of https://dl.acm.org/doi/pdf/10.1145/69622.357187 (P. 625)
|
5
|
+
#
|
6
|
+
# @rbs generic X < Object -- Type of a member of `sets`
|
7
|
+
# @rbs generic Y < _Or -- Type of sets assigned to a member of `sets`
|
8
|
+
class Digraph[X < Object, Y < _Or]
|
9
|
+
interface _Or
|
10
|
+
def |: (self) -> self
|
11
|
+
end
|
12
|
+
|
13
|
+
@sets: Array[X]
|
14
|
+
|
15
|
+
@relation: Hash[X, Array[X]]
|
16
|
+
|
17
|
+
@base_function: Hash[X, Y]
|
18
|
+
|
19
|
+
@stack: Array[X]
|
20
|
+
|
21
|
+
@h: Hash[X, (Integer | Float)?]
|
22
|
+
|
23
|
+
@result: Hash[X, Y]
|
24
|
+
|
25
|
+
# @rbs sets: Array[X]
|
26
|
+
# @rbs relation: Hash[X, Array[X]]
|
27
|
+
# @rbs base_function: Hash[X, Y]
|
28
|
+
# @rbs return: void
|
29
|
+
def initialize: (Array[X] sets, Hash[X, Array[X]] relation, Hash[X, Y] base_function) -> void
|
30
|
+
|
31
|
+
# @rbs () -> Hash[X, Y]
|
32
|
+
def compute: () -> Hash[X, Y]
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
# @rbs (X x) -> void
|
37
|
+
def traverse: (X x) -> void
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Generated from lib/lrama/grammar/binding.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Lrama
|
4
|
+
class Grammar
|
5
|
+
class Binding
|
6
|
+
@actual_args: Array[Lexer::Token]
|
7
|
+
|
8
|
+
@param_to_arg: Hash[String, Lexer::Token]
|
9
|
+
|
10
|
+
# @rbs (Array[Lexer::Token] params, Array[Lexer::Token] actual_args) -> void
|
11
|
+
def initialize: (Array[Lexer::Token] params, Array[Lexer::Token] actual_args) -> void
|
12
|
+
|
13
|
+
# @rbs (Lexer::Token sym) -> Lexer::Token
|
14
|
+
def resolve_symbol: (Lexer::Token sym) -> Lexer::Token
|
15
|
+
|
16
|
+
# @rbs (Lexer::Token::InstantiateRule token) -> String
|
17
|
+
def concatenated_args_str: (Lexer::Token::InstantiateRule token) -> String
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
# @rbs (Array[Lexer::Token] params, Array[Lexer::Token] actual_args) -> Hash[String, Lexer::Token]
|
22
|
+
def map_params_to_args: (Array[Lexer::Token] params, Array[Lexer::Token] actual_args) -> Hash[String, Lexer::Token]
|
23
|
+
|
24
|
+
# @rbs (Lexer::Token::InstantiateRule sym) -> Array[Lexer::Token]
|
25
|
+
def resolved_args: (Lexer::Token::InstantiateRule sym) -> Array[Lexer::Token]
|
26
|
+
|
27
|
+
# @rbs (Lexer::Token sym) -> Lexer::Token
|
28
|
+
def param_to_arg: (Lexer::Token sym) -> Lexer::Token
|
29
|
+
|
30
|
+
# @rbs (Lexer::Token::InstantiateRule token) -> Array[String]
|
31
|
+
def token_to_args_s_values: (Lexer::Token::InstantiateRule token) -> Array[String]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Generated from lib/lrama/lexer/grammar_file.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Lrama
|
4
|
+
class Lexer
|
5
|
+
class GrammarFile
|
6
|
+
class Text < String
|
7
|
+
# @rbs () -> String
|
8
|
+
def inspect: () -> String
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_reader path: String
|
12
|
+
|
13
|
+
attr_reader text: String
|
14
|
+
|
15
|
+
# @rbs (String path, String text) -> void
|
16
|
+
def initialize: (String path, String text) -> void
|
17
|
+
|
18
|
+
# @rbs () -> String
|
19
|
+
def inspect: () -> String
|
20
|
+
|
21
|
+
# @rbs (GrammarFile other) -> bool
|
22
|
+
def ==: (GrammarFile other) -> bool
|
23
|
+
|
24
|
+
# @rbs () -> Array[String]
|
25
|
+
def lines: () -> Array[String]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Generated from lib/lrama/lexer/location.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Lrama
|
4
|
+
class Lexer
|
5
|
+
class Location
|
6
|
+
attr_reader grammar_file: GrammarFile
|
7
|
+
|
8
|
+
attr_reader first_line: Integer
|
9
|
+
|
10
|
+
attr_reader first_column: Integer
|
11
|
+
|
12
|
+
attr_reader last_line: Integer
|
13
|
+
|
14
|
+
attr_reader last_column: Integer
|
15
|
+
|
16
|
+
# @rbs (grammar_file: GrammarFile, first_line: Integer, first_column: Integer, last_line: Integer, last_column: Integer) -> void
|
17
|
+
def initialize: (grammar_file: GrammarFile, first_line: Integer, first_column: Integer, last_line: Integer, last_column: Integer) -> void
|
18
|
+
|
19
|
+
# @rbs (Location other) -> bool
|
20
|
+
def ==: (Location other) -> bool
|
21
|
+
|
22
|
+
# @rbs (Integer left, Integer right) -> Location
|
23
|
+
def partial_location: (Integer left, Integer right) -> Location
|
24
|
+
|
25
|
+
# @rbs () -> String
|
26
|
+
def to_s: () -> String
|
27
|
+
|
28
|
+
# @rbs (String error_message) -> String
|
29
|
+
def generate_error_message: (String error_message) -> String
|
30
|
+
|
31
|
+
# @rbs () -> String
|
32
|
+
def line_with_carets: () -> String
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
# @rbs () -> String
|
37
|
+
def path: () -> String
|
38
|
+
|
39
|
+
# @rbs () -> String
|
40
|
+
def blanks: () -> String
|
41
|
+
|
42
|
+
# @rbs () -> String
|
43
|
+
def carets: () -> String
|
44
|
+
|
45
|
+
# @rbs () -> String
|
46
|
+
def text: () -> String
|
47
|
+
|
48
|
+
# @rbs () -> Array[String]
|
49
|
+
def _text: () -> Array[String]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -1,12 +1,20 @@
|
|
1
|
+
# Generated from lib/lrama/lexer/token/instantiate_rule.rb with RBS::Inline
|
2
|
+
|
1
3
|
module Lrama
|
2
4
|
class Lexer
|
3
5
|
class Token
|
4
6
|
class InstantiateRule < Token
|
5
7
|
attr_reader args: Array[Lexer::Token]
|
8
|
+
|
6
9
|
attr_reader lhs_tag: Lexer::Token::Tag?
|
7
10
|
|
11
|
+
# @rbs (s_value: String, ?alias_name: String, ?location: Location, ?args: Array[Lexer::Token], ?lhs_tag: Lexer::Token::Tag?) -> void
|
8
12
|
def initialize: (s_value: String, ?alias_name: String, ?location: Location, ?args: Array[Lexer::Token], ?lhs_tag: Lexer::Token::Tag?) -> void
|
13
|
+
|
14
|
+
# @rbs () -> String
|
9
15
|
def rule_name: () -> String
|
16
|
+
|
17
|
+
# @rbs () -> Integer
|
10
18
|
def args_count: () -> Integer
|
11
19
|
end
|
12
20
|
end
|
@@ -1,15 +1,20 @@
|
|
1
|
+
# Generated from lib/lrama/lexer/token/user_code.rb with RBS::Inline
|
2
|
+
|
1
3
|
module Lrama
|
2
4
|
class Lexer
|
3
5
|
class Token
|
4
6
|
class UserCode < Token
|
5
7
|
attr_accessor tag: Lexer::Token::Tag
|
6
|
-
@references: Array[Lrama::Grammar::Reference]
|
7
8
|
|
9
|
+
# @rbs () -> Array[Lrama::Grammar::Reference]
|
8
10
|
def references: () -> Array[Lrama::Grammar::Reference]
|
9
11
|
|
10
12
|
private
|
11
13
|
|
14
|
+
# @rbs () -> Array[Lrama::Grammar::Reference]
|
12
15
|
def _references: () -> Array[Lrama::Grammar::Reference]
|
16
|
+
|
17
|
+
# @rbs (StringScanner scanner) -> Lrama::Grammar::Reference?
|
13
18
|
def scan_reference: (StringScanner scanner) -> Lrama::Grammar::Reference?
|
14
19
|
end
|
15
20
|
end
|
@@ -1,22 +1,45 @@
|
|
1
|
+
# Generated from lib/lrama/lexer/token.rb with RBS::Inline
|
2
|
+
|
1
3
|
module Lrama
|
2
4
|
class Lexer
|
3
5
|
class Token
|
4
6
|
attr_reader s_value: String
|
5
|
-
|
7
|
+
|
6
8
|
attr_reader location: Location
|
9
|
+
|
10
|
+
attr_accessor alias_name: String
|
11
|
+
|
7
12
|
attr_accessor referred: bool
|
8
13
|
|
14
|
+
# @rbs (s_value: String, ?alias_name: String, ?location: Location) -> void
|
9
15
|
def initialize: (s_value: String, ?alias_name: String, ?location: Location) -> void
|
10
16
|
|
17
|
+
# @rbs () -> String
|
11
18
|
def to_s: () -> String
|
19
|
+
|
20
|
+
# @rbs (String string) -> bool
|
12
21
|
def referred_by?: (String string) -> bool
|
22
|
+
|
23
|
+
# @rbs (Token other) -> bool
|
13
24
|
def ==: (Token other) -> bool
|
25
|
+
|
26
|
+
# @rbs () -> Integer
|
14
27
|
def first_line: () -> Integer
|
28
|
+
|
29
|
+
alias line first_line
|
30
|
+
|
31
|
+
# @rbs () -> Integer
|
15
32
|
def first_column: () -> Integer
|
33
|
+
|
34
|
+
alias column first_column
|
35
|
+
|
36
|
+
# @rbs () -> Integer
|
16
37
|
def last_line: () -> Integer
|
38
|
+
|
39
|
+
# @rbs () -> Integer
|
17
40
|
def last_column: () -> Integer
|
18
|
-
|
19
|
-
|
41
|
+
|
42
|
+
# @rbs (Lrama::Grammar::Reference ref, String message) -> bot
|
20
43
|
def invalid_ref: (Lrama::Grammar::Reference ref, String message) -> bot
|
21
44
|
end
|
22
45
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Generated from lib/lrama/logger.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Lrama
|
4
|
+
class Logger
|
5
|
+
# @rbs (IO out) -> void
|
6
|
+
def initialize: (IO out) -> void
|
7
|
+
|
8
|
+
# @rbs (String message) -> void
|
9
|
+
def warn: (String message) -> void
|
10
|
+
|
11
|
+
# @rbs (String message) -> void
|
12
|
+
def error: (String message) -> void
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Generated from lib/lrama/trace_reporter.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Lrama
|
4
|
+
class TraceReporter
|
5
|
+
# @rbs (Lrama::Grammar grammar) -> void
|
6
|
+
def initialize: (Lrama::Grammar grammar) -> void
|
7
|
+
|
8
|
+
# @rbs (**Hash[Symbol, bool] options) -> void
|
9
|
+
def report: (**Hash[Symbol, bool] options) -> void
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
# @rbs rules: (bool rules, bool actions, bool only_explicit_rules, **untyped _) -> void
|
14
|
+
def _report: (?rules: untyped, ?actions: untyped, ?only_explicit_rules: untyped, **untyped _) -> untyped
|
15
|
+
|
16
|
+
# @rbs () -> void
|
17
|
+
def report_rules: () -> void
|
18
|
+
|
19
|
+
# @rbs () -> void
|
20
|
+
def report_only_explicit_rules: () -> void
|
21
|
+
|
22
|
+
# @rbs () -> void
|
23
|
+
def report_actions: () -> void
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Lrama
|
2
|
+
class Counterexamples
|
3
|
+
class Derivation
|
4
|
+
@item: States::Item
|
5
|
+
|
6
|
+
@left: Derivation?
|
7
|
+
|
8
|
+
@right: Derivation?
|
9
|
+
|
10
|
+
attr_reader item: States::Item
|
11
|
+
|
12
|
+
attr_reader left: Derivation?
|
13
|
+
|
14
|
+
attr_reader right: Derivation?
|
15
|
+
|
16
|
+
attr_writer right: Derivation?
|
17
|
+
|
18
|
+
def initialize: (States::Item item, Derivation? left, ?Derivation? right) -> void
|
19
|
+
|
20
|
+
def to_s: () -> ::String
|
21
|
+
|
22
|
+
alias inspect to_s
|
23
|
+
|
24
|
+
def render_strings_for_report: () -> Array[String]
|
25
|
+
|
26
|
+
def render_for_report: () -> String
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def _render_for_report: (Derivation derivation, Integer offset, Array[String] strings, Integer index) -> Integer
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Lrama
|
2
|
+
class Counterexamples
|
3
|
+
class Example
|
4
|
+
@path1: ::Array[StartPath | TransitionPath | ProductionPath]
|
5
|
+
|
6
|
+
@path2: ::Array[StartPath | TransitionPath | ProductionPath]
|
7
|
+
|
8
|
+
@conflict: (State::ShiftReduceConflict | State::ReduceReduceConflict)
|
9
|
+
|
10
|
+
@conflict_symbol: Grammar::Symbol
|
11
|
+
|
12
|
+
@counterexamples: Counterexamples
|
13
|
+
|
14
|
+
@derivations1: Derivation
|
15
|
+
|
16
|
+
@derivations2: Derivation
|
17
|
+
|
18
|
+
attr_reader path1: ::Array[StartPath | TransitionPath | ProductionPath]
|
19
|
+
|
20
|
+
attr_reader path2: ::Array[StartPath | TransitionPath | ProductionPath]
|
21
|
+
|
22
|
+
attr_reader conflict: (State::ShiftReduceConflict | State::ReduceReduceConflict)
|
23
|
+
|
24
|
+
attr_reader conflict_symbol: Grammar::Symbol
|
25
|
+
|
26
|
+
def initialize: (::Array[StartPath | TransitionPath | ProductionPath]? path1, ::Array[StartPath | TransitionPath | ProductionPath]? path2, (State::ShiftReduceConflict | State::ReduceReduceConflict) conflict, Grammar::Symbol conflict_symbol, Counterexamples counterexamples) -> void
|
27
|
+
|
28
|
+
def type: () -> (:shift_reduce | :reduce_reduce)
|
29
|
+
|
30
|
+
def path1_item: () -> States::Item
|
31
|
+
|
32
|
+
def path2_item: () -> States::Item
|
33
|
+
|
34
|
+
def derivations1: () -> Derivation
|
35
|
+
|
36
|
+
def derivations2: () -> Derivation
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def _derivations: (::Array[StartPath | TransitionPath | ProductionPath] paths) -> Derivation
|
41
|
+
|
42
|
+
def find_derivation_for_symbol: (StateItem state_item, Grammar::Symbol sym) -> Derivation?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Lrama
|
2
|
+
class Counterexamples
|
3
|
+
class Path
|
4
|
+
@from_state_item: StateItem?
|
5
|
+
|
6
|
+
@to_state_item: StateItem
|
7
|
+
|
8
|
+
def initialize: (StateItem? from_state_item, StateItem to_state_item) -> void
|
9
|
+
|
10
|
+
def from: () -> StateItem?
|
11
|
+
|
12
|
+
def to: () -> StateItem
|
13
|
+
|
14
|
+
def to_s: () -> ::String
|
15
|
+
|
16
|
+
alias inspect to_s
|
17
|
+
|
18
|
+
def type: -> bot
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Lrama
|
2
|
+
class Counterexamples
|
3
|
+
class Triple
|
4
|
+
attr_accessor s: State
|
5
|
+
attr_accessor itm: States::Item
|
6
|
+
attr_accessor l: Set[Grammar::Symbol]
|
7
|
+
|
8
|
+
alias state s
|
9
|
+
alias item itm
|
10
|
+
alias precise_lookahead_set l
|
11
|
+
|
12
|
+
def initialize: (State s, States::Item itm, Set[Grammar::Symbol] l) -> void
|
13
|
+
|
14
|
+
def state_item: () -> StateItem
|
15
|
+
def inspect: () -> ::String
|
16
|
+
|
17
|
+
alias to_s inspect
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Lrama
|
2
|
+
class Counterexamples
|
3
|
+
@states: States
|
4
|
+
@transitions: Hash[[StateItem, Grammar::Symbol], StateItem]
|
5
|
+
@reverse_transitions: Hash[[StateItem, Grammar::Symbol], Set[StateItem]]
|
6
|
+
@productions: Hash[StateItem, Set[States::Item]]
|
7
|
+
@reverse_productions: Hash[[State, Grammar::Symbol], Set[States::Item]]
|
8
|
+
|
9
|
+
attr_reader transitions: Hash[[StateItem, Grammar::Symbol], StateItem]
|
10
|
+
attr_reader productions: Hash[StateItem, Set[States::Item]]
|
11
|
+
|
12
|
+
def initialize: (States states) -> void
|
13
|
+
def to_s: () -> "#<Counterexamples>"
|
14
|
+
alias inspect to_s
|
15
|
+
def compute: (State conflict_state) -> Array[Example]
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def setup_transitions: () -> void
|
20
|
+
def setup_productions: () -> void
|
21
|
+
def shift_reduce_example: (State conflict_state, State::ShiftReduceConflict conflict) -> Example
|
22
|
+
def reduce_reduce_examples: (State conflict_state, State::ReduceReduceConflict conflict) -> Example
|
23
|
+
def find_shift_conflict_shortest_path: (::Array[StartPath|TransitionPath|ProductionPath]? reduce_path, State conflict_state, States::Item conflict_item) -> ::Array[StartPath|TransitionPath|ProductionPath]
|
24
|
+
def find_shift_conflict_shortest_state_items: (::Array[StartPath|TransitionPath|ProductionPath]? reduce_path, State conflict_state, States::Item conflict_item) -> Array[StateItem]
|
25
|
+
def build_paths_from_state_items: (Array[StateItem] state_items) -> ::Array[StartPath|TransitionPath|ProductionPath]
|
26
|
+
def shortest_path: (State conflict_state, States::Item conflict_reduce_item, Grammar::Symbol conflict_term) -> ::Array[StartPath|TransitionPath|ProductionPath]?
|
27
|
+
def follow_l: (States::Item item, Set[Grammar::Symbol] current_l) -> Set[Grammar::Symbol]
|
28
|
+
end
|
29
|
+
end
|
@@ -37,7 +37,6 @@ module Lrama
|
|
37
37
|
def preprocess_references: () -> void
|
38
38
|
def build_rules: () -> void
|
39
39
|
def process_rhs: () -> void
|
40
|
-
def lhs_s_value: (Lexer::Token::InstantiateRule token, Grammar::Binding bindings) -> String
|
41
40
|
def resolve_inline: () -> void
|
42
41
|
def resolve_inline_rhs: (RuleBuilder rule_builder, Grammar::ParameterizingRule::Rhs inline_rhs, Integer index, ?Binding bindings) -> void
|
43
42
|
def replace_inline_user_code: (Grammar::ParameterizingRule::Rhs inline_rhs, Integer index) -> Lexer::Token::UserCode?
|
@@ -13,7 +13,7 @@ module Lrama
|
|
13
13
|
attr_accessor destructor: Destructor?
|
14
14
|
attr_accessor error_token: ErrorToken
|
15
15
|
|
16
|
-
attr_accessor first_set: Set[
|
16
|
+
attr_accessor first_set: Set[Grammar::Symbol]
|
17
17
|
attr_accessor first_set_bitmap: Integer
|
18
18
|
attr_writer eof_symbol: bool
|
19
19
|
attr_writer error_symbol: bool
|
@@ -14,8 +14,8 @@ module Lrama
|
|
14
14
|
def sort_by_number!: () -> Array[Grammar::Symbol]
|
15
15
|
def add_term: (id: Lexer::Token, ?alias_name: String?, ?tag: Lexer::Token::Tag?, ?token_id: Integer?, ?replace: bool) -> Grammar::Symbol
|
16
16
|
def add_nterm: (id: Lexer::Token, ?alias_name: String?, ?tag: Lexer::Token::Tag?) -> Grammar::Symbol
|
17
|
-
def find_symbol_by_s_value: (
|
18
|
-
def find_symbol_by_s_value!: (
|
17
|
+
def find_symbol_by_s_value: (::String s_value) -> Grammar::Symbol?
|
18
|
+
def find_symbol_by_s_value!: (::String s_value) -> Grammar::Symbol
|
19
19
|
def find_symbol_by_id: (Lexer::Token id) -> Grammar::Symbol?
|
20
20
|
def find_symbol_by_id!: (Lexer::Token id) -> Grammar::Symbol
|
21
21
|
def find_symbol_by_token_id: (Integer token_id) -> Grammar::Symbol?
|
@@ -47,7 +47,7 @@ module Lrama
|
|
47
47
|
def find_symbol_by_number!: (Integer number) -> Grammar::Symbol
|
48
48
|
def find_symbol_by_id!: (Lexer::Token id) -> Grammar::Symbol
|
49
49
|
def token_to_symbol: (Lexer::Token token) -> Grammar::Symbol
|
50
|
-
def find_symbol_by_s_value!: (
|
50
|
+
def find_symbol_by_s_value!: (::String s_value) -> Grammar::Symbol
|
51
51
|
def fill_nterm_type: (Array[Grammar::Type] types) -> void
|
52
52
|
def fill_symbol_number: () -> void
|
53
53
|
def fill_printer: (Array[Grammar::Printer] printers) -> void
|
data/sig/lrama/grammar.rbs
CHANGED
@@ -91,5 +91,18 @@ module Lrama
|
|
91
91
|
def fill_sym_to_rules: () -> Array[Rule]
|
92
92
|
def validate_rule_lhs_is_nterm!: () -> void
|
93
93
|
def set_locations: () -> void
|
94
|
+
|
95
|
+
interface _DelegatedMethods
|
96
|
+
def rules: () -> Array[Rule]
|
97
|
+
def accept_symbol: () -> Grammar::Symbol
|
98
|
+
def eof_symbol: () -> Grammar::Symbol
|
99
|
+
def undef_symbol: () -> Grammar::Symbol
|
100
|
+
|
101
|
+
# delegate to @symbols_resolver
|
102
|
+
def symbols: () -> Array[Grammar::Symbol]
|
103
|
+
def terms: () -> Array[Grammar::Symbol]
|
104
|
+
def nterms: () -> Array[Grammar::Symbol]
|
105
|
+
def find_symbol_by_s_value!: (::String s_value) -> Grammar::Symbol
|
106
|
+
end
|
94
107
|
end
|
95
108
|
end
|
data/sig/lrama/options.rbs
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module Lrama
|
2
2
|
class State
|
3
3
|
class ReduceReduceConflict
|
4
|
-
attr_accessor symbols: Array[Grammar::Symbol
|
4
|
+
attr_accessor symbols: Array[Grammar::Symbol]
|
5
5
|
attr_accessor reduce1: State::Reduce
|
6
6
|
attr_accessor reduce2: State::Reduce
|
7
7
|
|
8
|
-
def initialize: (?symbols: Array[Grammar::Symbol
|
8
|
+
def initialize: (?symbols: Array[Grammar::Symbol], ?reduce1: State::Reduce, ?reduce2: State::Reduce) -> void
|
9
9
|
|
10
10
|
def type: () -> :reduce_reduce
|
11
11
|
end
|