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/sig/lrama/state.rbs
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
module Lrama
|
2
|
+
class State
|
3
|
+
@id: untyped
|
4
|
+
|
5
|
+
@accessing_symbol: untyped
|
6
|
+
|
7
|
+
@kernels: untyped
|
8
|
+
|
9
|
+
@items: Array[States::Item]
|
10
|
+
|
11
|
+
@items_to_state: untyped
|
12
|
+
|
13
|
+
@conflicts: Array[State::ShiftReduceConflict|State::ReduceReduceConflict]
|
14
|
+
|
15
|
+
@resolved_conflicts: untyped
|
16
|
+
|
17
|
+
@default_reduction_rule: untyped
|
18
|
+
|
19
|
+
@closure: untyped
|
20
|
+
|
21
|
+
@nterm_transitions: untyped
|
22
|
+
|
23
|
+
@term_transitions: untyped
|
24
|
+
|
25
|
+
@transitions: Array[[Shift, State]]
|
26
|
+
|
27
|
+
attr_reader id: untyped
|
28
|
+
|
29
|
+
attr_reader accessing_symbol: untyped
|
30
|
+
|
31
|
+
attr_reader kernels: untyped
|
32
|
+
|
33
|
+
attr_reader conflicts: Array[State::ShiftReduceConflict|State::ReduceReduceConflict]
|
34
|
+
|
35
|
+
attr_reader resolved_conflicts: untyped
|
36
|
+
|
37
|
+
attr_reader default_reduction_rule: untyped
|
38
|
+
|
39
|
+
attr_reader closure: untyped
|
40
|
+
|
41
|
+
attr_reader items: Array[States::Item]
|
42
|
+
|
43
|
+
attr_accessor shifts: Array[Shift]
|
44
|
+
|
45
|
+
attr_accessor reduces: untyped
|
46
|
+
|
47
|
+
def initialize: (untyped id, untyped accessing_symbol, Array[States::Item] kernels) -> void
|
48
|
+
|
49
|
+
def closure=: (untyped closure) -> untyped
|
50
|
+
|
51
|
+
def non_default_reduces: () -> untyped
|
52
|
+
|
53
|
+
def compute_shifts_reduces: () -> untyped
|
54
|
+
|
55
|
+
def set_items_to_state: (untyped items, untyped next_state) -> untyped
|
56
|
+
|
57
|
+
def set_look_ahead: (untyped rule, untyped look_ahead) -> untyped
|
58
|
+
|
59
|
+
def nterm_transitions: () -> untyped
|
60
|
+
|
61
|
+
def term_transitions: () -> untyped
|
62
|
+
|
63
|
+
def transitions: () -> Array[[Shift, State]]
|
64
|
+
|
65
|
+
def selected_term_transitions: () -> untyped
|
66
|
+
|
67
|
+
def transition: (untyped sym) -> untyped
|
68
|
+
|
69
|
+
def find_reduce_by_item!: (untyped item) -> untyped
|
70
|
+
|
71
|
+
def default_reduction_rule=: (untyped default_reduction_rule) -> untyped
|
72
|
+
|
73
|
+
def has_conflicts?: () -> untyped
|
74
|
+
|
75
|
+
def sr_conflicts: () -> untyped
|
76
|
+
|
77
|
+
def rr_conflicts: () -> untyped
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
module Lrama
|
2
|
+
class States
|
3
|
+
include Grammar::_DelegatedMethods
|
4
|
+
|
5
|
+
@grammar: untyped
|
6
|
+
|
7
|
+
@warning: untyped
|
8
|
+
|
9
|
+
@trace_state: untyped
|
10
|
+
|
11
|
+
@states: Array[State]
|
12
|
+
|
13
|
+
@direct_read_sets: untyped
|
14
|
+
|
15
|
+
@reads_relation: untyped
|
16
|
+
|
17
|
+
@read_sets: untyped
|
18
|
+
|
19
|
+
@includes_relation: untyped
|
20
|
+
|
21
|
+
@lookback_relation: untyped
|
22
|
+
|
23
|
+
@follow_sets: untyped
|
24
|
+
|
25
|
+
@la: untyped
|
26
|
+
|
27
|
+
extend Forwardable
|
28
|
+
|
29
|
+
include Lrama::Report::Duration
|
30
|
+
|
31
|
+
attr_reader states: Array[State]
|
32
|
+
|
33
|
+
attr_reader reads_relation: untyped
|
34
|
+
|
35
|
+
attr_reader includes_relation: untyped
|
36
|
+
|
37
|
+
attr_reader lookback_relation: untyped
|
38
|
+
|
39
|
+
def initialize: (untyped grammar, untyped warning, ?trace_state: bool) -> void
|
40
|
+
|
41
|
+
def compute: () -> untyped
|
42
|
+
|
43
|
+
def reporter: () -> untyped
|
44
|
+
|
45
|
+
def states_count: () -> untyped
|
46
|
+
|
47
|
+
def direct_read_sets: () -> untyped
|
48
|
+
|
49
|
+
def read_sets: () -> untyped
|
50
|
+
|
51
|
+
def follow_sets: () -> untyped
|
52
|
+
|
53
|
+
def la: () -> untyped
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def sr_conflicts: () -> untyped
|
58
|
+
|
59
|
+
def rr_conflicts: () -> untyped
|
60
|
+
|
61
|
+
def trace_state: () { (untyped) -> untyped } -> (untyped | nil)
|
62
|
+
|
63
|
+
def create_state: (untyped accessing_symbol, untyped kernels, untyped states_created) -> (::Array[untyped | false] | ::Array[untyped | true])
|
64
|
+
|
65
|
+
def setup_state: (untyped state) -> untyped
|
66
|
+
|
67
|
+
def enqueue_state: (untyped states, untyped state) -> untyped
|
68
|
+
|
69
|
+
def compute_lr0_states: () -> untyped
|
70
|
+
|
71
|
+
def nterm_transitions: () -> untyped
|
72
|
+
|
73
|
+
def compute_direct_read_sets: () -> untyped
|
74
|
+
|
75
|
+
def compute_reads_relation: () -> untyped
|
76
|
+
|
77
|
+
def compute_read_sets: () -> untyped
|
78
|
+
|
79
|
+
def transition: (untyped state, untyped symbols) -> untyped
|
80
|
+
|
81
|
+
def compute_includes_relation: () -> untyped
|
82
|
+
|
83
|
+
def compute_lookback_relation: () -> untyped
|
84
|
+
|
85
|
+
def compute_follow_sets: () -> untyped
|
86
|
+
|
87
|
+
def compute_look_ahead_sets: () -> untyped
|
88
|
+
|
89
|
+
def bitmap_to_terms: (untyped bit) -> untyped
|
90
|
+
|
91
|
+
def compute_conflicts: () -> untyped
|
92
|
+
|
93
|
+
def compute_shift_reduce_conflicts: () -> untyped
|
94
|
+
|
95
|
+
def compute_reduce_reduce_conflicts: () -> untyped
|
96
|
+
|
97
|
+
def compute_default_reduction: () -> untyped
|
98
|
+
|
99
|
+
def check_conflicts: () -> untyped
|
100
|
+
end
|
101
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lrama
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuichiro Kaneko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: LALR (1) parser generator written by Ruby
|
14
14
|
email:
|
@@ -21,8 +21,10 @@ files:
|
|
21
21
|
- ".codespellignore"
|
22
22
|
- ".github/dependabot.yml"
|
23
23
|
- ".github/workflows/codespell.yaml"
|
24
|
+
- ".github/workflows/gh-pages.yml"
|
24
25
|
- ".github/workflows/test.yaml"
|
25
26
|
- ".gitignore"
|
27
|
+
- ".rdoc_options"
|
26
28
|
- ".rspec"
|
27
29
|
- Gemfile
|
28
30
|
- LEGAL.md
|
@@ -31,6 +33,11 @@ files:
|
|
31
33
|
- README.md
|
32
34
|
- Rakefile
|
33
35
|
- Steepfile
|
36
|
+
- doc/Index.md
|
37
|
+
- doc/development/compressed_state_table/main.md
|
38
|
+
- doc/development/compressed_state_table/parse.output
|
39
|
+
- doc/development/compressed_state_table/parse.y
|
40
|
+
- doc/development/compressed_state_table/parser.rb
|
34
41
|
- exe/lrama
|
35
42
|
- lib/lrama.rb
|
36
43
|
- lib/lrama/bitmap.rb
|
@@ -108,11 +115,30 @@ files:
|
|
108
115
|
- parser.y
|
109
116
|
- rbs_collection.lock.yaml
|
110
117
|
- rbs_collection.yaml
|
111
|
-
- sig/lrama/bitmap.rbs
|
112
|
-
- sig/lrama/digraph.rbs
|
118
|
+
- sig/generated/lrama/bitmap.rbs
|
119
|
+
- sig/generated/lrama/digraph.rbs
|
120
|
+
- sig/generated/lrama/grammar/binding.rbs
|
121
|
+
- sig/generated/lrama/lexer/grammar_file.rbs
|
122
|
+
- sig/generated/lrama/lexer/location.rbs
|
123
|
+
- sig/generated/lrama/lexer/token.rbs
|
124
|
+
- sig/generated/lrama/lexer/token/char.rbs
|
125
|
+
- sig/generated/lrama/lexer/token/ident.rbs
|
126
|
+
- sig/generated/lrama/lexer/token/instantiate_rule.rbs
|
127
|
+
- sig/generated/lrama/lexer/token/tag.rbs
|
128
|
+
- sig/generated/lrama/lexer/token/user_code.rbs
|
129
|
+
- sig/generated/lrama/logger.rbs
|
130
|
+
- sig/generated/lrama/trace_reporter.rbs
|
131
|
+
- sig/lrama/counterexamples.rbs
|
132
|
+
- sig/lrama/counterexamples/derivation.rbs
|
133
|
+
- sig/lrama/counterexamples/example.rbs
|
134
|
+
- sig/lrama/counterexamples/path.rbs
|
135
|
+
- sig/lrama/counterexamples/production_path.rbs
|
136
|
+
- sig/lrama/counterexamples/start_path.rbs
|
137
|
+
- sig/lrama/counterexamples/state_item.rbs
|
138
|
+
- sig/lrama/counterexamples/transition_path.rbs
|
139
|
+
- sig/lrama/counterexamples/triple.rbs
|
113
140
|
- sig/lrama/grammar.rbs
|
114
141
|
- sig/lrama/grammar/auxiliary.rbs
|
115
|
-
- sig/lrama/grammar/binding.rbs
|
116
142
|
- sig/lrama/grammar/code.rbs
|
117
143
|
- sig/lrama/grammar/code/destructor_code.rbs
|
118
144
|
- sig/lrama/grammar/code/initial_action_code.rbs
|
@@ -136,22 +162,16 @@ files:
|
|
136
162
|
- sig/lrama/grammar/symbols/resolver.rbs
|
137
163
|
- sig/lrama/grammar/type.rbs
|
138
164
|
- sig/lrama/grammar/union.rbs
|
139
|
-
- sig/lrama/lexer/grammar_file.rbs
|
140
|
-
- sig/lrama/lexer/location.rbs
|
141
|
-
- sig/lrama/lexer/token.rbs
|
142
|
-
- sig/lrama/lexer/token/char.rbs
|
143
|
-
- sig/lrama/lexer/token/ident.rbs
|
144
|
-
- sig/lrama/lexer/token/instantiate_rule.rbs
|
145
|
-
- sig/lrama/lexer/token/tag.rbs
|
146
|
-
- sig/lrama/lexer/token/user_code.rbs
|
147
165
|
- sig/lrama/options.rbs
|
148
166
|
- sig/lrama/report/duration.rbs
|
149
167
|
- sig/lrama/report/profile.rbs
|
168
|
+
- sig/lrama/state.rbs
|
150
169
|
- sig/lrama/state/reduce.rbs
|
151
170
|
- sig/lrama/state/reduce_reduce_conflict.rbs
|
152
171
|
- sig/lrama/state/resolved_conflict.rbs
|
153
172
|
- sig/lrama/state/shift.rbs
|
154
173
|
- sig/lrama/state/shift_reduce_conflict.rbs
|
174
|
+
- sig/lrama/states.rbs
|
155
175
|
- sig/lrama/states/item.rbs
|
156
176
|
- sig/lrama/warning.rbs
|
157
177
|
- sig/stdlib/strscan/string_scanner.rbs
|
@@ -164,7 +184,7 @@ licenses:
|
|
164
184
|
metadata:
|
165
185
|
homepage_uri: https://github.com/ruby/lrama
|
166
186
|
source_code_uri: https://github.com/ruby/lrama
|
167
|
-
documentation_uri: https://github.
|
187
|
+
documentation_uri: https://ruby.github.io/lrama/
|
168
188
|
changelog_uri: https://github.com/ruby/lrama/releases
|
169
189
|
bug_tracker_uri: https://github.com/ruby/lrama/issues
|
170
190
|
post_install_message:
|
data/sig/lrama/bitmap.rbs
DELETED
data/sig/lrama/digraph.rbs
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module Lrama
|
2
|
-
class Digraph
|
3
|
-
def initialize: (Array[Integer] sets, Hash[Integer, Array[Integer]] relation, Hash[Integer, Integer] base_function) -> void
|
4
|
-
# X in the paper
|
5
|
-
@sets: Array[Integer]
|
6
|
-
# R in the paper
|
7
|
-
@relation: Hash[Integer, Array[Integer]]
|
8
|
-
# F' in the paper
|
9
|
-
@base_function: Hash[Integer, Integer]
|
10
|
-
# S in the paper
|
11
|
-
@stack: Array[Integer]
|
12
|
-
# N in the paper
|
13
|
-
@h: Hash[Integer, (Integer|Float)?]
|
14
|
-
# F in the paper
|
15
|
-
@result: Hash[Integer, Integer]
|
16
|
-
|
17
|
-
def compute: () -> Hash[Integer, Integer]
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def traverse: (Integer x) -> void
|
22
|
-
end
|
23
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Lrama
|
2
|
-
class Grammar
|
3
|
-
class Binding
|
4
|
-
attr_reader actual_args: Array[Lexer::Token]
|
5
|
-
attr_reader count: Integer
|
6
|
-
|
7
|
-
@required_parameters_count: Integer
|
8
|
-
@parameters: Array[Lexer::Token]
|
9
|
-
@parameter_to_arg: untyped
|
10
|
-
|
11
|
-
def initialize: (Grammar::ParameterizingRule::Rule parameterizing_rule, Array[Lexer::Token] actual_args) -> void
|
12
|
-
def resolve_symbol: (Lexer::Token symbol) -> Lexer::Token
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def parameter_to_arg: (Lexer::Token symbol) -> Lexer::Token?
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Lrama
|
2
|
-
class Lexer
|
3
|
-
class GrammarFile
|
4
|
-
class Text < String
|
5
|
-
end
|
6
|
-
attr_reader path: String
|
7
|
-
attr_reader text: String
|
8
|
-
|
9
|
-
@lines: Array[String]
|
10
|
-
|
11
|
-
def initialize: (String path, String text) -> void
|
12
|
-
|
13
|
-
def ==: (GrammarFile other) -> bool
|
14
|
-
def lines: () -> Array[String]
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Lrama
|
2
|
-
class Lexer
|
3
|
-
class Location
|
4
|
-
attr_reader grammar_file: GrammarFile
|
5
|
-
attr_reader first_line: Integer
|
6
|
-
attr_reader first_column: Integer
|
7
|
-
attr_reader last_line: Integer
|
8
|
-
attr_reader last_column: Integer
|
9
|
-
|
10
|
-
def initialize: (grammar_file: GrammarFile, first_line: Integer, first_column: Integer, last_line: Integer, last_column: Integer) -> void
|
11
|
-
|
12
|
-
def ==: (Location other) -> bool
|
13
|
-
def partial_location: (Integer, Integer) -> Location
|
14
|
-
def generate_error_message: (String) -> String
|
15
|
-
def line_with_carets: () -> String
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def path: () -> String
|
20
|
-
def blanks: () -> String
|
21
|
-
def carets: () -> String
|
22
|
-
def text: () -> String
|
23
|
-
def _text: () -> Array[String]
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|