ibex 0.1.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 +7 -0
- data/.rubocop.yml +43 -0
- data/CHANGELOG.md +30 -0
- data/LICENSE.txt +21 -0
- data/README.md +194 -0
- data/Rakefile +25 -0
- data/Steepfile +10 -0
- data/docs/architecture.md +99 -0
- data/docs/compat-notes.md +37 -0
- data/docs/grammar-reference.md +127 -0
- data/docs/lexer-coverage.md +14 -0
- data/docs/phase10-extensions.md +27 -0
- data/docs/racc-migration.md +47 -0
- data/exe/ibex +6 -0
- data/gemfiles/Gemfile +7 -0
- data/gemfiles/Gemfile.lock +98 -0
- data/lib/ibex/analysis/sets.rb +194 -0
- data/lib/ibex/analysis.rb +8 -0
- data/lib/ibex/cli/counterexample_options.rb +38 -0
- data/lib/ibex/cli/outputs.rb +88 -0
- data/lib/ibex/cli.rb +333 -0
- data/lib/ibex/codegen/dot.rb +52 -0
- data/lib/ibex/codegen/html.rb +110 -0
- data/lib/ibex/codegen/rbs.rb +54 -0
- data/lib/ibex/codegen/report.rb +149 -0
- data/lib/ibex/codegen/ruby.rb +235 -0
- data/lib/ibex/codegen/symbol_labels.rb +18 -0
- data/lib/ibex/error.rb +7 -0
- data/lib/ibex/frontend/action_scanner.rb +266 -0
- data/lib/ibex/frontend/ast.rb +146 -0
- data/lib/ibex/frontend/bootstrap_parser.rb +163 -0
- data/lib/ibex/frontend/dsl.rb +196 -0
- data/lib/ibex/frontend/generated_parser.rb +434 -0
- data/lib/ibex/frontend/generated_parser_base.rb +273 -0
- data/lib/ibex/frontend/grammar.y +156 -0
- data/lib/ibex/frontend/lexer.rb +165 -0
- data/lib/ibex/frontend/parser/declarations.rb +163 -0
- data/lib/ibex/frontend/parser/rules.rb +154 -0
- data/lib/ibex/frontend/parser.rb +23 -0
- data/lib/ibex/frontend/regenerator.rb +41 -0
- data/lib/ibex/frontend/source_cursor.rb +94 -0
- data/lib/ibex/frontend/token_adapter/declaration_state.rb +248 -0
- data/lib/ibex/frontend/token_adapter/delimiter_tracker.rb +37 -0
- data/lib/ibex/frontend/token_adapter/rule_state.rb +162 -0
- data/lib/ibex/frontend/token_adapter.rb +108 -0
- data/lib/ibex/frontend.rb +28 -0
- data/lib/ibex/ir/automaton_ir.rb +109 -0
- data/lib/ibex/ir/grammar_ir.rb +192 -0
- data/lib/ibex/ir/serialize.rb +154 -0
- data/lib/ibex/ir.rb +53 -0
- data/lib/ibex/lalr/builder.rb +270 -0
- data/lib/ibex/lalr/conflict.rb +120 -0
- data/lib/ibex/lalr/conflict_search.rb +332 -0
- data/lib/ibex/lalr/conflict_search_limits.rb +39 -0
- data/lib/ibex/lalr/counterexample.rb +138 -0
- data/lib/ibex/lalr/default_reductions.rb +67 -0
- data/lib/ibex/lalr.rb +27 -0
- data/lib/ibex/normalize/declarations.rb +60 -0
- data/lib/ibex/normalize/diagnostics.rb +99 -0
- data/lib/ibex/normalize/expander.rb +218 -0
- data/lib/ibex/normalize/expression.rb +54 -0
- data/lib/ibex/normalize.rb +166 -0
- data/lib/ibex/runtime/parser.rb +360 -0
- data/lib/ibex/runtime.rb +8 -0
- data/lib/ibex/tables.rb +125 -0
- data/lib/ibex/version.rb +6 -0
- data/lib/ibex.rb +23 -0
- data/sig/ibex/analysis/sets.rbs +72 -0
- data/sig/ibex/analysis.rbs +6 -0
- data/sig/ibex/cli/counterexample_options.rbs +16 -0
- data/sig/ibex/cli/outputs.rbs +31 -0
- data/sig/ibex/cli.rbs +108 -0
- data/sig/ibex/codegen/dot.rbs +19 -0
- data/sig/ibex/codegen/html.rbs +35 -0
- data/sig/ibex/codegen/rbs.rbs +31 -0
- data/sig/ibex/codegen/report.rbs +39 -0
- data/sig/ibex/codegen/ruby.rbs +92 -0
- data/sig/ibex/codegen/symbol_labels.rbs +11 -0
- data/sig/ibex/error.rbs +7 -0
- data/sig/ibex/frontend/action_scanner.rbs +74 -0
- data/sig/ibex/frontend/ast.rbs +223 -0
- data/sig/ibex/frontend/bootstrap_parser.rbs +80 -0
- data/sig/ibex/frontend/dsl.rbs +124 -0
- data/sig/ibex/frontend/generated_parser.rbs +163 -0
- data/sig/ibex/frontend/generated_parser_base.rbs +114 -0
- data/sig/ibex/frontend/lexer.rbs +61 -0
- data/sig/ibex/frontend/parser/declarations.rbs +56 -0
- data/sig/ibex/frontend/parser/rules.rbs +48 -0
- data/sig/ibex/frontend/parser.rbs +16 -0
- data/sig/ibex/frontend/regenerator.rbs +16 -0
- data/sig/ibex/frontend/source_cursor.rbs +73 -0
- data/sig/ibex/frontend/token_adapter/declaration_state.rbs +97 -0
- data/sig/ibex/frontend/token_adapter/delimiter_tracker.rbs +25 -0
- data/sig/ibex/frontend/token_adapter/rule_state.rbs +77 -0
- data/sig/ibex/frontend/token_adapter.rbs +67 -0
- data/sig/ibex/frontend.rbs +15 -0
- data/sig/ibex/ir/automaton_ir.rbs +77 -0
- data/sig/ibex/ir/grammar_ir.rbs +143 -0
- data/sig/ibex/ir/serialize.rbs +50 -0
- data/sig/ibex/ir.rbs +43 -0
- data/sig/ibex/lalr/builder.rbs +85 -0
- data/sig/ibex/lalr/conflict.rbs +47 -0
- data/sig/ibex/lalr/conflict_search.rbs +131 -0
- data/sig/ibex/lalr/conflict_search_limits.rbs +29 -0
- data/sig/ibex/lalr/counterexample.rbs +53 -0
- data/sig/ibex/lalr/default_reductions.rbs +20 -0
- data/sig/ibex/lalr.rbs +23 -0
- data/sig/ibex/normalize/declarations.rbs +20 -0
- data/sig/ibex/normalize/diagnostics.rbs +32 -0
- data/sig/ibex/normalize/expander.rbs +66 -0
- data/sig/ibex/normalize/expression.rbs +21 -0
- data/sig/ibex/normalize.rbs +96 -0
- data/sig/ibex/runtime/parser.rbs +167 -0
- data/sig/ibex/runtime.rbs +6 -0
- data/sig/ibex/tables.rbs +50 -0
- data/sig/ibex/version.rbs +6 -0
- data/sig/ibex.rbs +6 -0
- metadata +161 -0
data/sig/ibex/cli.rbs
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Generated from lib/ibex/cli.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Ibex
|
|
4
|
+
interface _CLIOutput
|
|
5
|
+
def puts: (*untyped) -> untyped
|
|
6
|
+
|
|
7
|
+
def write: (String) -> untyped
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
type cli_options = { emit: String, mode: Symbol, table: Symbol, line_convert: bool, ?line_convert_all: bool, counterexample_max_tokens: Integer, counterexample_max_configurations: Integer, ?from: String, ?algorithm: Symbol, ?warnings: Array[Symbol], ?output: String, ?embedded: bool, ?debug: bool, ?verbose: bool, ?rbs: String | true, ?dot: String, ?html: String, ?log_file: String, ?executable: String, ?frozen: bool, ?omit_actions: bool, ?superclass: String, ?check_only: bool, ?status: bool, ?profile: bool, ?debug_flags: String, ?version: bool, ?runtime_version: bool, ?copyright: bool, ?help: bool }
|
|
11
|
+
|
|
12
|
+
# Command-line pipeline coordinator.
|
|
13
|
+
# rubocop:disable Metrics/ClassLength -- inline type contracts add lines without adding runtime responsibilities.
|
|
14
|
+
class CLI
|
|
15
|
+
include CLICounterexampleOptions
|
|
16
|
+
|
|
17
|
+
include CLIOutputs
|
|
18
|
+
|
|
19
|
+
@options: cli_options
|
|
20
|
+
|
|
21
|
+
@stderr: _CLIOutput
|
|
22
|
+
|
|
23
|
+
@stdout: _CLIOutput
|
|
24
|
+
|
|
25
|
+
# @rbs (Array[String] arguments, ?stdout: _CLIOutput, ?stderr: _CLIOutput) -> Integer
|
|
26
|
+
def self.start: (Array[String] arguments, ?stdout: _CLIOutput, ?stderr: _CLIOutput) -> Integer
|
|
27
|
+
|
|
28
|
+
# @rbs (stdout: _CLIOutput, stderr: _CLIOutput) -> void
|
|
29
|
+
def initialize: (stdout: _CLIOutput, stderr: _CLIOutput) -> void
|
|
30
|
+
|
|
31
|
+
# @rbs (Array[String] arguments) -> Integer
|
|
32
|
+
def run: (Array[String] arguments) -> Integer
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
# @rbs () -> OptionParser
|
|
37
|
+
def option_parser: () -> OptionParser
|
|
38
|
+
|
|
39
|
+
# @rbs (OptionParser options) -> void
|
|
40
|
+
def add_pipeline_options: (OptionParser options) -> void
|
|
41
|
+
|
|
42
|
+
# @rbs (OptionParser options) -> void
|
|
43
|
+
def add_output_options: (OptionParser options) -> void
|
|
44
|
+
|
|
45
|
+
# @rbs (OptionParser options) -> void
|
|
46
|
+
def add_compatibility_options: (OptionParser options) -> void
|
|
47
|
+
|
|
48
|
+
# @rbs (OptionParser options) -> void
|
|
49
|
+
def add_information_options: (OptionParser options) -> void
|
|
50
|
+
|
|
51
|
+
# @rbs (OptionParser parser) -> Integer?
|
|
52
|
+
def informational_result: (OptionParser parser) -> Integer?
|
|
53
|
+
|
|
54
|
+
# @rbs (Array[String] remaining) -> String
|
|
55
|
+
def input_path: (Array[String] remaining) -> String
|
|
56
|
+
|
|
57
|
+
# @rbs (String path) -> Integer
|
|
58
|
+
def process_grammar: (String path) -> Integer
|
|
59
|
+
|
|
60
|
+
# @rbs (String path) -> Integer
|
|
61
|
+
def process_ir: (String path) -> Integer
|
|
62
|
+
|
|
63
|
+
# @rbs (IR::Grammar grammar, String path) -> Integer
|
|
64
|
+
def dispatch_grammar: (IR::Grammar grammar, String path) -> Integer
|
|
65
|
+
|
|
66
|
+
# @rbs (IR::Automaton automaton, String path) -> Integer
|
|
67
|
+
def dispatch_automaton: (IR::Automaton automaton, String path) -> Integer
|
|
68
|
+
|
|
69
|
+
# @rbs () -> Integer
|
|
70
|
+
def print_version: () -> Integer
|
|
71
|
+
|
|
72
|
+
# @rbs (OptionParser parser) -> Integer
|
|
73
|
+
def print_help: (OptionParser parser) -> Integer
|
|
74
|
+
|
|
75
|
+
# @rbs () -> Integer
|
|
76
|
+
def print_copyright: () -> Integer
|
|
77
|
+
|
|
78
|
+
# @rbs (Frontend::AST::Root ast) -> Integer
|
|
79
|
+
def emit_ast: (Frontend::AST::Root ast) -> Integer
|
|
80
|
+
|
|
81
|
+
# @rbs (IR::Grammar grammar) -> Integer
|
|
82
|
+
def emit_grammar: (IR::Grammar grammar) -> Integer
|
|
83
|
+
|
|
84
|
+
# @rbs (IR::Grammar grammar, String input_path) -> Integer
|
|
85
|
+
def emit_automaton: (IR::Grammar grammar, String input_path) -> Integer
|
|
86
|
+
|
|
87
|
+
# @rbs (IR::Grammar grammar, String input_path) -> Integer
|
|
88
|
+
def emit_ruby: (IR::Grammar grammar, String input_path) -> Integer
|
|
89
|
+
|
|
90
|
+
# @rbs (IR::Automaton automaton, String input_path) -> Integer
|
|
91
|
+
def generate_ruby: (IR::Automaton automaton, String input_path) -> Integer
|
|
92
|
+
|
|
93
|
+
# @rbs (IR::Automaton automaton, String output_path) -> void
|
|
94
|
+
def write_rbs: (IR::Automaton automaton, String output_path) -> void
|
|
95
|
+
|
|
96
|
+
# @rbs (IR::Automaton automaton, String input_path) -> Integer
|
|
97
|
+
def emit_loaded_automaton: (IR::Automaton automaton, String input_path) -> Integer
|
|
98
|
+
|
|
99
|
+
# @rbs (IR::Grammar grammar, String input_path) -> IR::Automaton
|
|
100
|
+
def build_automaton: (IR::Grammar grammar, String input_path) -> IR::Automaton
|
|
101
|
+
|
|
102
|
+
# @rbs (IR::Automaton automaton, String input_path) -> void
|
|
103
|
+
def prepare_loaded_automaton: (IR::Automaton automaton, String input_path) -> void
|
|
104
|
+
|
|
105
|
+
# @rbs (IR::Automaton automaton) -> void
|
|
106
|
+
def write_visualizations: (IR::Automaton automaton) -> void
|
|
107
|
+
end
|
|
108
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Generated from lib/ibex/codegen/dot.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Ibex
|
|
4
|
+
module Codegen
|
|
5
|
+
# Renders Graphviz DOT from Automaton IR.
|
|
6
|
+
module Dot
|
|
7
|
+
private def escape: (String value) -> String
|
|
8
|
+
|
|
9
|
+
private def self.escape: (String value) -> String
|
|
10
|
+
|
|
11
|
+
private def symbol_name: (Hash[Integer, String] labels, Integer id) -> String
|
|
12
|
+
|
|
13
|
+
private def self.symbol_name: (Hash[Integer, String] labels, Integer id) -> String
|
|
14
|
+
|
|
15
|
+
# @rbs (IR::Automaton automaton) -> String
|
|
16
|
+
def self?.render: (IR::Automaton automaton) -> String
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Generated from lib/ibex/codegen/html.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Ibex
|
|
4
|
+
module Codegen
|
|
5
|
+
# Renders a self-contained navigable automaton report.
|
|
6
|
+
module HTML
|
|
7
|
+
private def state_sections: (IR::Automaton automaton, IR::Grammar grammar, Hash[Integer, String] labels) -> String
|
|
8
|
+
|
|
9
|
+
private def self.state_sections: (IR::Automaton automaton, IR::Grammar grammar, Hash[Integer, String] labels) -> String
|
|
10
|
+
|
|
11
|
+
private def item_html: (IR::AutomatonItem item, IR::Grammar grammar, Hash[Integer, String] labels) -> String
|
|
12
|
+
|
|
13
|
+
private def self.item_html: (IR::AutomatonItem item, IR::Grammar grammar, Hash[Integer, String] labels) -> String
|
|
14
|
+
|
|
15
|
+
private def rule_sections: (IR::Grammar grammar, Hash[Integer, String] labels) -> String
|
|
16
|
+
|
|
17
|
+
private def self.rule_sections: (IR::Grammar grammar, Hash[Integer, String] labels) -> String
|
|
18
|
+
|
|
19
|
+
private def conflict_sections: (IR::Automaton automaton) -> String
|
|
20
|
+
|
|
21
|
+
private def self.conflict_sections: (IR::Automaton automaton) -> String
|
|
22
|
+
|
|
23
|
+
private def escape: (String value) -> String
|
|
24
|
+
|
|
25
|
+
private def self.escape: (String value) -> String
|
|
26
|
+
|
|
27
|
+
private def symbol_name: (Hash[Integer, String] labels, Integer id) -> String
|
|
28
|
+
|
|
29
|
+
private def self.symbol_name: (Hash[Integer, String] labels, Integer id) -> String
|
|
30
|
+
|
|
31
|
+
# @rbs (IR::Automaton automaton) -> String
|
|
32
|
+
def self?.render: (IR::Automaton automaton) -> String
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Generated from lib/ibex/codegen/rbs.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Ibex
|
|
4
|
+
module Codegen
|
|
5
|
+
# Generates an RBS declaration for the public surface of a generated parser.
|
|
6
|
+
class RBS
|
|
7
|
+
@automaton: IR::Automaton
|
|
8
|
+
|
|
9
|
+
@grammar: IR::Grammar
|
|
10
|
+
|
|
11
|
+
@superclass: String
|
|
12
|
+
|
|
13
|
+
# @rbs (IR::Automaton automaton, ?superclass: String?) -> void
|
|
14
|
+
def initialize: (IR::Automaton automaton, ?superclass: String?) -> void
|
|
15
|
+
|
|
16
|
+
# @rbs () -> String
|
|
17
|
+
def generate: () -> String
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
# @rbs (Array[String] lines) -> void
|
|
22
|
+
def append_contract: (Array[String] lines) -> void
|
|
23
|
+
|
|
24
|
+
# @rbs () -> [Array[String], String]
|
|
25
|
+
def class_parts: () -> [ Array[String], String ]
|
|
26
|
+
|
|
27
|
+
# @rbs () -> String
|
|
28
|
+
def grammar_digest_comment: () -> String
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Generated from lib/ibex/codegen/report.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Ibex
|
|
4
|
+
module Codegen
|
|
5
|
+
# Renders a human-readable state and conflict report from Automaton IR.
|
|
6
|
+
module Report
|
|
7
|
+
private def append_state: (Array[String] lines, IR::AutomatonState state, IR::Grammar grammar, Array[IR::counterexample] examples, Hash[Integer, String] labels) -> void
|
|
8
|
+
|
|
9
|
+
private def self.append_state: (Array[String] lines, IR::AutomatonState state, IR::Grammar grammar, Array[IR::counterexample] examples, Hash[Integer, String] labels) -> void
|
|
10
|
+
|
|
11
|
+
private def append_counterexample: (Array[String] lines, IR::counterexample example, IR::Grammar grammar, Hash[Integer, String] labels) -> void
|
|
12
|
+
|
|
13
|
+
private def self.append_counterexample: (Array[String] lines, IR::counterexample example, IR::Grammar grammar, Hash[Integer, String] labels) -> void
|
|
14
|
+
|
|
15
|
+
private def append_tree: (Array[String] lines, untyped tree, String indentation, IR::Grammar grammar, Hash[Integer, String] labels) -> void
|
|
16
|
+
|
|
17
|
+
private def self.append_tree: (Array[String] lines, untyped tree, String indentation, IR::Grammar grammar, Hash[Integer, String] labels) -> void
|
|
18
|
+
|
|
19
|
+
private def format_item: (IR::AutomatonItem item, IR::Grammar grammar, Hash[Integer, String] labels) -> String
|
|
20
|
+
|
|
21
|
+
private def self.format_item: (IR::AutomatonItem item, IR::Grammar grammar, Hash[Integer, String] labels) -> String
|
|
22
|
+
|
|
23
|
+
private def format_action: (IR::parser_action action) -> String
|
|
24
|
+
|
|
25
|
+
private def self.format_action: (IR::parser_action action) -> String
|
|
26
|
+
|
|
27
|
+
private def symbol_name: (Hash[Integer, String] labels, Integer id) -> String
|
|
28
|
+
|
|
29
|
+
private def self.symbol_name: (Hash[Integer, String] labels, Integer id) -> String
|
|
30
|
+
|
|
31
|
+
private def tree_label: (IR::Grammar grammar, Hash[Integer, String] labels, untyped value) -> untyped
|
|
32
|
+
|
|
33
|
+
private def self.tree_label: (IR::Grammar grammar, Hash[Integer, String] labels, untyped value) -> untyped
|
|
34
|
+
|
|
35
|
+
# @rbs (IR::Automaton automaton, ?max_tokens: Integer, ?max_configurations: Integer) -> String
|
|
36
|
+
def self?.render: (IR::Automaton automaton, ?max_tokens: Integer, ?max_configurations: Integer) -> String
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Generated from lib/ibex/codegen/ruby.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Ibex
|
|
4
|
+
module Codegen
|
|
5
|
+
# Generates a standalone Ruby parser class from Automaton IR.
|
|
6
|
+
class Ruby
|
|
7
|
+
@executable: String?
|
|
8
|
+
|
|
9
|
+
@superclass: String
|
|
10
|
+
|
|
11
|
+
@omit_action_call: bool
|
|
12
|
+
|
|
13
|
+
@debug: bool
|
|
14
|
+
|
|
15
|
+
@line_convert_all: bool
|
|
16
|
+
|
|
17
|
+
@line_convert: bool
|
|
18
|
+
|
|
19
|
+
@embedded: bool
|
|
20
|
+
|
|
21
|
+
@table_format: Symbol
|
|
22
|
+
|
|
23
|
+
@grammar: IR::Grammar
|
|
24
|
+
|
|
25
|
+
@automaton: IR::Automaton
|
|
26
|
+
|
|
27
|
+
# @rbs (IR::Automaton automaton, ?table: Symbol | String, ?embedded: bool, ?line_convert: bool,
|
|
28
|
+
# ?line_convert_all: bool, ?debug: bool, ?omit_action_call: bool?, ?superclass: String?,
|
|
29
|
+
# ?executable: String?) -> void
|
|
30
|
+
def initialize: (IR::Automaton automaton, ?table: Symbol | String, ?embedded: bool, ?line_convert: bool, ?line_convert_all: bool, ?debug: bool, ?omit_action_call: bool?, ?superclass: String?, ?executable: String?) -> void
|
|
31
|
+
|
|
32
|
+
# @rbs () -> String
|
|
33
|
+
def generate: () -> String
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
# @rbs (Array[String] lines) -> void
|
|
38
|
+
def append_runtime: (Array[String] lines) -> void
|
|
39
|
+
|
|
40
|
+
# @rbs (String relative_path) -> String
|
|
41
|
+
def embedded_source: (String relative_path) -> String
|
|
42
|
+
|
|
43
|
+
# @rbs (Array[String] lines) -> void
|
|
44
|
+
def append_tables: (Array[String] lines) -> void
|
|
45
|
+
|
|
46
|
+
# @rbs (untyped table) -> String
|
|
47
|
+
def table_literal: (untyped table) -> String
|
|
48
|
+
|
|
49
|
+
# @rbs () -> String
|
|
50
|
+
def token_ids_literal: () -> String
|
|
51
|
+
|
|
52
|
+
# @rbs (IR::GrammarSymbol terminal) -> String
|
|
53
|
+
def external_token_expression: (IR::GrammarSymbol terminal) -> String
|
|
54
|
+
|
|
55
|
+
# @rbs () -> String
|
|
56
|
+
def token_names_literal: () -> String
|
|
57
|
+
|
|
58
|
+
# @rbs () -> String
|
|
59
|
+
def productions_literal: () -> String
|
|
60
|
+
|
|
61
|
+
# @rbs (Array[String] lines) -> void
|
|
62
|
+
def append_actions: (Array[String] lines) -> void
|
|
63
|
+
|
|
64
|
+
# @rbs (Array[String] lines, IR::Production production) -> void
|
|
65
|
+
def append_action_constant: (Array[String] lines, IR::Production production) -> void
|
|
66
|
+
|
|
67
|
+
# @rbs (Array[String] lines, IR::Production production) -> void
|
|
68
|
+
def append_action_method: (Array[String] lines, IR::Production production) -> void
|
|
69
|
+
|
|
70
|
+
# @rbs (Array[String] lines, IR::Action? action) -> void
|
|
71
|
+
def append_named_bindings: (Array[String] lines, IR::Action? action) -> void
|
|
72
|
+
|
|
73
|
+
# @rbs (Array[String] lines, IR::Production production) -> void
|
|
74
|
+
def append_semantic_code: (Array[String] lines, IR::Production production) -> void
|
|
75
|
+
|
|
76
|
+
# @rbs (IR::Production production) -> bool
|
|
77
|
+
def action_method?: (IR::Production production) -> bool
|
|
78
|
+
|
|
79
|
+
# @rbs (Array[String] lines, String name, ?indent: Integer) -> void
|
|
80
|
+
def append_user_code: (Array[String] lines, String name, ?indent: Integer) -> void
|
|
81
|
+
|
|
82
|
+
# @rbs (String name) -> bool
|
|
83
|
+
def map_user_code?: (String name) -> bool
|
|
84
|
+
|
|
85
|
+
# @rbs () -> [Array[String], String]
|
|
86
|
+
def class_parts: () -> [ Array[String], String ]
|
|
87
|
+
|
|
88
|
+
# @rbs () -> String
|
|
89
|
+
def grammar_digest_comment: () -> String
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Generated from lib/ibex/codegen/symbol_labels.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Ibex
|
|
4
|
+
module Codegen
|
|
5
|
+
# Builds human-facing symbol labels without changing Grammar IR identities.
|
|
6
|
+
module SymbolLabels
|
|
7
|
+
# @rbs (IR::Grammar grammar) -> Hash[Integer, String]
|
|
8
|
+
def self.build: (IR::Grammar grammar) -> Hash[Integer, String]
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
data/sig/ibex/error.rbs
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Generated from lib/ibex/frontend/action_scanner.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Ibex
|
|
4
|
+
module Frontend
|
|
5
|
+
# Extracts a balanced Ruby action while ignoring braces inside literals.
|
|
6
|
+
class ActionScanner
|
|
7
|
+
type heredoc = { identifier: String, indented: bool, length: Integer, location: Location }
|
|
8
|
+
|
|
9
|
+
PAIRED_DELIMITERS: Hash[String, String]
|
|
10
|
+
|
|
11
|
+
REGEX_PREFIXES: String
|
|
12
|
+
|
|
13
|
+
@pending_heredocs: Array[heredoc]
|
|
14
|
+
|
|
15
|
+
@cursor: SourceCursor
|
|
16
|
+
|
|
17
|
+
# @rbs (SourceCursor cursor) -> void
|
|
18
|
+
def initialize: (SourceCursor cursor) -> void
|
|
19
|
+
|
|
20
|
+
# @rbs () -> Token
|
|
21
|
+
def scan: () -> Token
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
# @rbs (Integer depth) -> void
|
|
26
|
+
def scan_code: (Integer depth) -> void
|
|
27
|
+
|
|
28
|
+
# @rbs () -> void
|
|
29
|
+
def scan_special_character: () -> void
|
|
30
|
+
|
|
31
|
+
# @rbs (String quote) -> void
|
|
32
|
+
def scan_quoted: (String quote) -> void
|
|
33
|
+
|
|
34
|
+
# @rbs () -> void
|
|
35
|
+
def scan_interpolation: () -> void
|
|
36
|
+
|
|
37
|
+
# @rbs () -> void
|
|
38
|
+
def scan_percent_literal: () -> void
|
|
39
|
+
|
|
40
|
+
# @rbs (String opener, String closer) -> void
|
|
41
|
+
def scan_delimited: (String opener, String closer) -> void
|
|
42
|
+
|
|
43
|
+
# @rbs () -> bool
|
|
44
|
+
def regexp_start?: () -> bool
|
|
45
|
+
|
|
46
|
+
# @rbs () -> void
|
|
47
|
+
def scan_regexp: () -> void
|
|
48
|
+
|
|
49
|
+
# @rbs () -> void
|
|
50
|
+
def scan_comment: () -> void
|
|
51
|
+
|
|
52
|
+
# @rbs () -> void
|
|
53
|
+
def scan_character_literal: () -> void
|
|
54
|
+
|
|
55
|
+
# @rbs () -> void
|
|
56
|
+
def scan_heredoc: () -> void
|
|
57
|
+
|
|
58
|
+
# @rbs () -> heredoc?
|
|
59
|
+
def heredoc_opener: () -> heredoc?
|
|
60
|
+
|
|
61
|
+
# @rbs (String prefix, String quote) -> [String, Integer]?
|
|
62
|
+
def quoted_heredoc_identifier: (String prefix, String quote) -> [ String, Integer ]?
|
|
63
|
+
|
|
64
|
+
# @rbs (String prefix) -> [String?, Integer]
|
|
65
|
+
def bare_heredoc_identifier: (String prefix) -> [ String?, Integer ]
|
|
66
|
+
|
|
67
|
+
# @rbs () -> void
|
|
68
|
+
def scan_pending_heredocs: () -> void
|
|
69
|
+
|
|
70
|
+
# @rbs (heredoc heredoc) -> void
|
|
71
|
+
def scan_heredoc_body: (heredoc heredoc) -> void
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# Generated from lib/ibex/frontend/ast.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Ibex
|
|
4
|
+
module Frontend
|
|
5
|
+
# Grammar frontend node types.
|
|
6
|
+
module AST
|
|
7
|
+
type declaration = Tokens | Precedence | Options | Expect | Start | Convert
|
|
8
|
+
|
|
9
|
+
type item = SymbolReference | InlineAction | Optional | Star | Plus | Group | SeparatedList
|
|
10
|
+
|
|
11
|
+
type user_code = Hash[String, Array[UserCode]]
|
|
12
|
+
|
|
13
|
+
# Adds deterministic, recursively serializable hashes to Struct nodes.
|
|
14
|
+
# @rbs module-self Struct[untyped]
|
|
15
|
+
module Node : Struct[untyped]
|
|
16
|
+
def to_h: () -> untyped
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def serialize: (untyped value) -> untyped
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
class Root < Struct[String | String? | Array[declaration] | Array[Rule] | user_code | Location]
|
|
24
|
+
attr_accessor class_name(): String
|
|
25
|
+
|
|
26
|
+
attr_accessor superclass(): String?
|
|
27
|
+
|
|
28
|
+
attr_accessor declarations(): Array[declaration]
|
|
29
|
+
|
|
30
|
+
attr_accessor rules(): Array[Rule]
|
|
31
|
+
|
|
32
|
+
attr_accessor user_code(): user_code
|
|
33
|
+
|
|
34
|
+
attr_accessor loc(): Location
|
|
35
|
+
|
|
36
|
+
def self.new: (?class_name: String, ?superclass: String?, ?declarations: Array[declaration], ?rules: Array[Rule], ?user_code: user_code, ?loc: Location) -> instance
|
|
37
|
+
| ({ ?class_name: String, ?superclass: String?, ?declarations: Array[declaration], ?rules: Array[Rule], ?user_code: user_code, ?loc: Location }) -> instance
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
class Tokens < Struct[Array[String] | Location]
|
|
41
|
+
attr_accessor names(): Array[String]
|
|
42
|
+
|
|
43
|
+
attr_accessor loc(): Location
|
|
44
|
+
|
|
45
|
+
def self.new: (?names: Array[String], ?loc: Location) -> instance
|
|
46
|
+
| ({ ?names: Array[String], ?loc: Location }) -> instance
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
class Precedence < Struct[Symbol | Array[PrecedenceLevel] | Location]
|
|
50
|
+
attr_accessor direction(): Symbol
|
|
51
|
+
|
|
52
|
+
attr_accessor levels(): Array[PrecedenceLevel]
|
|
53
|
+
|
|
54
|
+
attr_accessor loc(): Location
|
|
55
|
+
|
|
56
|
+
def self.new: (?direction: Symbol, ?levels: Array[PrecedenceLevel], ?loc: Location) -> instance
|
|
57
|
+
| ({ ?direction: Symbol, ?levels: Array[PrecedenceLevel], ?loc: Location }) -> instance
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
class PrecedenceLevel < Struct[Symbol | Array[String] | Location]
|
|
61
|
+
attr_accessor associativity(): Symbol
|
|
62
|
+
|
|
63
|
+
attr_accessor symbols(): Array[String]
|
|
64
|
+
|
|
65
|
+
attr_accessor loc(): Location
|
|
66
|
+
|
|
67
|
+
def self.new: (?associativity: Symbol, ?symbols: Array[String], ?loc: Location) -> instance
|
|
68
|
+
| ({ ?associativity: Symbol, ?symbols: Array[String], ?loc: Location }) -> instance
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
class Options < Struct[Array[String] | Location]
|
|
72
|
+
attr_accessor names(): Array[String]
|
|
73
|
+
|
|
74
|
+
attr_accessor loc(): Location
|
|
75
|
+
|
|
76
|
+
def self.new: (?names: Array[String], ?loc: Location) -> instance
|
|
77
|
+
| ({ ?names: Array[String], ?loc: Location }) -> instance
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
class Expect < Struct[Integer | Location]
|
|
81
|
+
attr_accessor conflicts(): Integer
|
|
82
|
+
|
|
83
|
+
attr_accessor loc(): Location
|
|
84
|
+
|
|
85
|
+
def self.new: (?conflicts: Integer, ?loc: Location) -> instance
|
|
86
|
+
| ({ ?conflicts: Integer, ?loc: Location }) -> instance
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
class Start < Struct[String | Location]
|
|
90
|
+
attr_accessor name(): String
|
|
91
|
+
|
|
92
|
+
attr_accessor loc(): Location
|
|
93
|
+
|
|
94
|
+
def self.new: (?name: String, ?loc: Location) -> instance
|
|
95
|
+
| ({ ?name: String, ?loc: Location }) -> instance
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
class Convert < Struct[Array[Conversion] | Location]
|
|
99
|
+
attr_accessor pairs(): Array[Conversion]
|
|
100
|
+
|
|
101
|
+
attr_accessor loc(): Location
|
|
102
|
+
|
|
103
|
+
def self.new: (?pairs: Array[Conversion], ?loc: Location) -> instance
|
|
104
|
+
| ({ ?pairs: Array[Conversion], ?loc: Location }) -> instance
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
class Conversion < Struct[String | Location]
|
|
108
|
+
attr_accessor name(): String
|
|
109
|
+
|
|
110
|
+
attr_accessor expression(): String
|
|
111
|
+
|
|
112
|
+
attr_accessor loc(): Location
|
|
113
|
+
|
|
114
|
+
def self.new: (?name: String, ?expression: String, ?loc: Location) -> instance
|
|
115
|
+
| ({ ?name: String, ?expression: String, ?loc: Location }) -> instance
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
class Rule < Struct[String | Array[Alternative] | Location]
|
|
119
|
+
attr_accessor lhs(): String
|
|
120
|
+
|
|
121
|
+
attr_accessor alternatives(): Array[Alternative]
|
|
122
|
+
|
|
123
|
+
attr_accessor loc(): Location
|
|
124
|
+
|
|
125
|
+
def self.new: (?lhs: String, ?alternatives: Array[Alternative], ?loc: Location) -> instance
|
|
126
|
+
| ({ ?lhs: String, ?alternatives: Array[Alternative], ?loc: Location }) -> instance
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
class Alternative < Struct[Array[item] | InlineAction? | String? | Location]
|
|
130
|
+
attr_accessor items(): Array[item]
|
|
131
|
+
|
|
132
|
+
attr_accessor action(): InlineAction?
|
|
133
|
+
|
|
134
|
+
attr_accessor precedence(): String?
|
|
135
|
+
|
|
136
|
+
attr_accessor loc(): Location
|
|
137
|
+
|
|
138
|
+
def self.new: (?items: Array[item], ?action: InlineAction?, ?precedence: String?, ?loc: Location) -> instance
|
|
139
|
+
| ({ ?items: Array[item], ?action: InlineAction?, ?precedence: String?, ?loc: Location }) -> instance
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
class SymbolReference < Struct[String | String? | Location]
|
|
143
|
+
attr_accessor name(): String
|
|
144
|
+
|
|
145
|
+
attr_accessor named_reference(): String?
|
|
146
|
+
|
|
147
|
+
attr_accessor loc(): Location
|
|
148
|
+
|
|
149
|
+
def self.new: (?name: String, ?named_reference: String?, ?loc: Location) -> instance
|
|
150
|
+
| ({ ?name: String, ?named_reference: String?, ?loc: Location }) -> instance
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
class InlineAction < Struct[String | Location]
|
|
154
|
+
attr_accessor code(): String
|
|
155
|
+
|
|
156
|
+
attr_accessor loc(): Location
|
|
157
|
+
|
|
158
|
+
def self.new: (?code: String, ?loc: Location) -> instance
|
|
159
|
+
| ({ ?code: String, ?loc: Location }) -> instance
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
class Optional < Struct[item | Location]
|
|
163
|
+
attr_accessor item(): item
|
|
164
|
+
|
|
165
|
+
attr_accessor loc(): Location
|
|
166
|
+
|
|
167
|
+
def self.new: (?item: item, ?loc: Location) -> instance
|
|
168
|
+
| ({ ?item: item, ?loc: Location }) -> instance
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
class Star < Struct[item | Location]
|
|
172
|
+
attr_accessor item(): item
|
|
173
|
+
|
|
174
|
+
attr_accessor loc(): Location
|
|
175
|
+
|
|
176
|
+
def self.new: (?item: item, ?loc: Location) -> instance
|
|
177
|
+
| ({ ?item: item, ?loc: Location }) -> instance
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
class Plus < Struct[item | Location]
|
|
181
|
+
attr_accessor item(): item
|
|
182
|
+
|
|
183
|
+
attr_accessor loc(): Location
|
|
184
|
+
|
|
185
|
+
def self.new: (?item: item, ?loc: Location) -> instance
|
|
186
|
+
| ({ ?item: item, ?loc: Location }) -> instance
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
class Group < Struct[Array[Array[item]] | Location]
|
|
190
|
+
attr_accessor alternatives(): Array[Array[item]]
|
|
191
|
+
|
|
192
|
+
attr_accessor loc(): Location
|
|
193
|
+
|
|
194
|
+
def self.new: (?alternatives: Array[Array[item]], ?loc: Location) -> instance
|
|
195
|
+
| ({ ?alternatives: Array[Array[item]], ?loc: Location }) -> instance
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
class SeparatedList < Struct[item | bool | Location]
|
|
199
|
+
attr_accessor item(): item
|
|
200
|
+
|
|
201
|
+
attr_accessor separator(): item
|
|
202
|
+
|
|
203
|
+
attr_accessor nonempty(): bool
|
|
204
|
+
|
|
205
|
+
attr_accessor loc(): Location
|
|
206
|
+
|
|
207
|
+
def self.new: (?item: item, ?separator: item, ?nonempty: bool, ?loc: Location) -> instance
|
|
208
|
+
| ({ ?item: item, ?separator: item, ?nonempty: bool, ?loc: Location }) -> instance
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
class UserCode < Struct[String | Location]
|
|
212
|
+
attr_accessor name(): String
|
|
213
|
+
|
|
214
|
+
attr_accessor code(): String
|
|
215
|
+
|
|
216
|
+
attr_accessor loc(): Location
|
|
217
|
+
|
|
218
|
+
def self.new: (?name: String, ?code: String, ?loc: Location) -> instance
|
|
219
|
+
| ({ ?name: String, ?code: String, ?loc: Location }) -> instance
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
end
|