lrama 0.6.11 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/gh-pages.yml +46 -0
  3. data/.github/workflows/test.yaml +35 -7
  4. data/.gitignore +1 -0
  5. data/.rdoc_options +2 -0
  6. data/Gemfile +4 -2
  7. data/NEWS.md +60 -0
  8. data/README.md +44 -15
  9. data/Rakefile +13 -1
  10. data/Steepfile +2 -0
  11. data/doc/Index.md +58 -0
  12. data/lib/lrama/bitmap.rb +3 -0
  13. data/lib/lrama/command.rb +2 -1
  14. data/lib/lrama/digraph.rb +30 -0
  15. data/lib/lrama/grammar/binding.rb +47 -15
  16. data/lib/lrama/grammar/rule.rb +8 -0
  17. data/lib/lrama/grammar/rule_builder.rb +3 -15
  18. data/lib/lrama/grammar.rb +8 -3
  19. data/lib/lrama/lexer/grammar_file.rb +8 -1
  20. data/lib/lrama/lexer/location.rb +17 -1
  21. data/lib/lrama/lexer/token/char.rb +1 -0
  22. data/lib/lrama/lexer/token/ident.rb +1 -0
  23. data/lib/lrama/lexer/token/instantiate_rule.rb +6 -1
  24. data/lib/lrama/lexer/token/tag.rb +3 -1
  25. data/lib/lrama/lexer/token/user_code.rb +5 -1
  26. data/lib/lrama/lexer/token.rb +14 -2
  27. data/lib/lrama/lexer.rb +4 -5
  28. data/lib/lrama/logger.rb +4 -0
  29. data/lib/lrama/option_parser.rb +10 -8
  30. data/lib/lrama/options.rb +2 -1
  31. data/lib/lrama/parser.rb +10 -4
  32. data/lib/lrama/state.rb +288 -1
  33. data/lib/lrama/states/item.rb +8 -0
  34. data/lib/lrama/states.rb +69 -2
  35. data/lib/lrama/trace_reporter.rb +17 -2
  36. data/lib/lrama/version.rb +1 -1
  37. data/lrama.gemspec +1 -1
  38. data/parser.y +4 -3
  39. data/rbs_collection.lock.yaml +3 -3
  40. data/sig/generated/lrama/bitmap.rbs +11 -0
  41. data/sig/generated/lrama/digraph.rbs +39 -0
  42. data/sig/generated/lrama/grammar/binding.rbs +34 -0
  43. data/sig/generated/lrama/lexer/grammar_file.rbs +28 -0
  44. data/sig/generated/lrama/lexer/location.rbs +52 -0
  45. data/sig/{lrama → generated/lrama}/lexer/token/char.rbs +2 -0
  46. data/sig/{lrama → generated/lrama}/lexer/token/ident.rbs +2 -0
  47. data/sig/{lrama → generated/lrama}/lexer/token/instantiate_rule.rbs +8 -0
  48. data/sig/{lrama → generated/lrama}/lexer/token/tag.rbs +3 -0
  49. data/sig/{lrama → generated/lrama}/lexer/token/user_code.rbs +6 -1
  50. data/sig/{lrama → generated/lrama}/lexer/token.rbs +26 -3
  51. data/sig/generated/lrama/logger.rbs +14 -0
  52. data/sig/generated/lrama/trace_reporter.rbs +25 -0
  53. data/sig/lrama/grammar/rule_builder.rbs +0 -1
  54. data/sig/lrama/options.rbs +1 -0
  55. metadata +19 -14
  56. data/sig/lrama/bitmap.rbs +0 -7
  57. data/sig/lrama/digraph.rbs +0 -23
  58. data/sig/lrama/grammar/binding.rbs +0 -19
  59. data/sig/lrama/lexer/grammar_file.rbs +0 -17
  60. data/sig/lrama/lexer/location.rbs +0 -26
@@ -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,3 +1,5 @@
1
+ # Generated from lib/lrama/lexer/token/char.rb with RBS::Inline
2
+
1
3
  module Lrama
2
4
  class Lexer
3
5
  class Token
@@ -1,3 +1,5 @@
1
+ # Generated from lib/lrama/lexer/token/ident.rb with RBS::Inline
2
+
1
3
  module Lrama
2
4
  class Lexer
3
5
  class Token
@@ -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,7 +1,10 @@
1
+ # Generated from lib/lrama/lexer/token/tag.rb with RBS::Inline
2
+
1
3
  module Lrama
2
4
  class Lexer
3
5
  class Token
4
6
  class Tag < Token
7
+ # @rbs () -> String
5
8
  def member: () -> String
6
9
  end
7
10
  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
- attr_accessor alias_name: String
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
- alias line first_line
19
- alias column first_column
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
@@ -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?
@@ -1,6 +1,7 @@
1
1
  module Lrama
2
2
  class Options
3
3
  attr_accessor skeleton: String
4
+ attr_accessor define: Hash[String, String]
4
5
  attr_accessor header: bool
5
6
  attr_accessor header_file: String?
6
7
  attr_accessor report_file: String?
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.6.11
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: 2024-12-23 00:00:00.000000000 Z
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,7 @@ files:
31
33
  - README.md
32
34
  - Rakefile
33
35
  - Steepfile
36
+ - doc/Index.md
34
37
  - doc/development/compressed_state_table/main.md
35
38
  - doc/development/compressed_state_table/parse.output
36
39
  - doc/development/compressed_state_table/parse.y
@@ -112,7 +115,19 @@ files:
112
115
  - parser.y
113
116
  - rbs_collection.lock.yaml
114
117
  - rbs_collection.yaml
115
- - sig/lrama/bitmap.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
116
131
  - sig/lrama/counterexamples.rbs
117
132
  - sig/lrama/counterexamples/derivation.rbs
118
133
  - sig/lrama/counterexamples/example.rbs
@@ -122,10 +137,8 @@ files:
122
137
  - sig/lrama/counterexamples/state_item.rbs
123
138
  - sig/lrama/counterexamples/transition_path.rbs
124
139
  - sig/lrama/counterexamples/triple.rbs
125
- - sig/lrama/digraph.rbs
126
140
  - sig/lrama/grammar.rbs
127
141
  - sig/lrama/grammar/auxiliary.rbs
128
- - sig/lrama/grammar/binding.rbs
129
142
  - sig/lrama/grammar/code.rbs
130
143
  - sig/lrama/grammar/code/destructor_code.rbs
131
144
  - sig/lrama/grammar/code/initial_action_code.rbs
@@ -149,14 +162,6 @@ files:
149
162
  - sig/lrama/grammar/symbols/resolver.rbs
150
163
  - sig/lrama/grammar/type.rbs
151
164
  - sig/lrama/grammar/union.rbs
152
- - sig/lrama/lexer/grammar_file.rbs
153
- - sig/lrama/lexer/location.rbs
154
- - sig/lrama/lexer/token.rbs
155
- - sig/lrama/lexer/token/char.rbs
156
- - sig/lrama/lexer/token/ident.rbs
157
- - sig/lrama/lexer/token/instantiate_rule.rbs
158
- - sig/lrama/lexer/token/tag.rbs
159
- - sig/lrama/lexer/token/user_code.rbs
160
165
  - sig/lrama/options.rbs
161
166
  - sig/lrama/report/duration.rbs
162
167
  - sig/lrama/report/profile.rbs
@@ -179,7 +184,7 @@ licenses:
179
184
  metadata:
180
185
  homepage_uri: https://github.com/ruby/lrama
181
186
  source_code_uri: https://github.com/ruby/lrama
182
- documentation_uri: https://github.com/ruby/lrama
187
+ documentation_uri: https://ruby.github.io/lrama/
183
188
  changelog_uri: https://github.com/ruby/lrama/releases
184
189
  bug_tracker_uri: https://github.com/ruby/lrama/issues
185
190
  post_install_message:
data/sig/lrama/bitmap.rbs DELETED
@@ -1,7 +0,0 @@
1
- module Lrama
2
- module Bitmap
3
- def self.from_array: (Array[int] ary) -> Integer
4
-
5
- def self.to_array: (Integer int) -> Array[Integer]
6
- end
7
- end
@@ -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