ibex-runtime 0.2.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/LICENSE.txt +21 -0
- data/README.md +337 -0
- data/lib/ibex/runtime/ast_data.rb +23 -0
- data/lib/ibex/runtime/cst/annotation.rb +16 -0
- data/lib/ibex/runtime/cst/cursor.rb +68 -0
- data/lib/ibex/runtime/cst/diff.rb +80 -0
- data/lib/ibex/runtime/cst/editing.rb +56 -0
- data/lib/ibex/runtime/cst/editor.rb +94 -0
- data/lib/ibex/runtime/cst/green/builder.rb +211 -0
- data/lib/ibex/runtime/cst/green/cache.rb +150 -0
- data/lib/ibex/runtime/cst/green/node.rb +78 -0
- data/lib/ibex/runtime/cst/green/token.rb +91 -0
- data/lib/ibex/runtime/cst/green/trivia.rb +36 -0
- data/lib/ibex/runtime/cst/incremental/blender.rb +233 -0
- data/lib/ibex/runtime/cst/incremental/lexed_syntax.rb +28 -0
- data/lib/ibex/runtime/cst/incremental/parse_memo.rb +95 -0
- data/lib/ibex/runtime/cst/incremental/relexer.rb +134 -0
- data/lib/ibex/runtime/cst/incremental/session.rb +229 -0
- data/lib/ibex/runtime/cst/incremental/token_memo.rb +66 -0
- data/lib/ibex/runtime/cst/kind.rb +133 -0
- data/lib/ibex/runtime/cst/parse_result.rb +41 -0
- data/lib/ibex/runtime/cst/rewriter.rb +75 -0
- data/lib/ibex/runtime/cst/serialize.rb +127 -0
- data/lib/ibex/runtime/cst/serialized_tree.rb +44 -0
- data/lib/ibex/runtime/cst/source_text.rb +112 -0
- data/lib/ibex/runtime/cst/syntax_node.rb +432 -0
- data/lib/ibex/runtime/cst/syntax_token.rb +160 -0
- data/lib/ibex/runtime/cst/text_edit.rb +77 -0
- data/lib/ibex/runtime/cst/typed_node.rb +87 -0
- data/lib/ibex/runtime/cst/validator.rb +428 -0
- data/lib/ibex/runtime/cst.rb +38 -0
- data/lib/ibex/runtime/event.rb +44 -0
- data/lib/ibex/runtime/event_jsonl_tracer.rb +37 -0
- data/lib/ibex/runtime/event_sanitizer.rb +273 -0
- data/lib/ibex/runtime/generated_lexer.rb +514 -0
- data/lib/ibex/runtime/jsonl_tracer.rb +75 -0
- data/lib/ibex/runtime/lexer_input.rb +107 -0
- data/lib/ibex/runtime/location_span.rb +114 -0
- data/lib/ibex/runtime/observation.rb +82 -0
- data/lib/ibex/runtime/parser.rb +3027 -0
- data/lib/ibex/runtime/parser_sync_recovery.rb +108 -0
- data/lib/ibex/runtime/repair.rb +126 -0
- data/lib/ibex/runtime/repair_priority_queue.rb +60 -0
- data/lib/ibex/runtime/repair_search.rb +318 -0
- data/lib/ibex/runtime/resource_limits.rb +64 -0
- data/lib/ibex/runtime/table_format.rb +11 -0
- data/lib/ibex/runtime/version.rb +7 -0
- data/lib/ibex/runtime.rb +27 -0
- data/lib/ibex/tables/compact.rb +186 -0
- data/lib/ibex/tables/compact_actions.rb +135 -0
- data/lib/ibex/tables/compact_productions.rb +167 -0
- data/sig/ibex/runtime/ast_data.rbs +12 -0
- data/sig/ibex/runtime/cst/annotation.rbs +13 -0
- data/sig/ibex/runtime/cst/cursor.rbs +34 -0
- data/sig/ibex/runtime/cst/diff.rbs +29 -0
- data/sig/ibex/runtime/cst/editing.rbs +23 -0
- data/sig/ibex/runtime/cst/editor.rbs +43 -0
- data/sig/ibex/runtime/cst/green/builder.rbs +84 -0
- data/sig/ibex/runtime/cst/green/cache.rbs +60 -0
- data/sig/ibex/runtime/cst/green/node.rbs +49 -0
- data/sig/ibex/runtime/cst/green/token.rbs +59 -0
- data/sig/ibex/runtime/cst/green/trivia.rbs +29 -0
- data/sig/ibex/runtime/cst/incremental/blender.rbs +114 -0
- data/sig/ibex/runtime/cst/incremental/lexed_syntax.rbs +20 -0
- data/sig/ibex/runtime/cst/incremental/parse_memo.rbs +59 -0
- data/sig/ibex/runtime/cst/incremental/relexer.rbs +54 -0
- data/sig/ibex/runtime/cst/incremental/session.rbs +89 -0
- data/sig/ibex/runtime/cst/incremental/token_memo.rbs +31 -0
- data/sig/ibex/runtime/cst/kind.rbs +93 -0
- data/sig/ibex/runtime/cst/parse_result.rbs +35 -0
- data/sig/ibex/runtime/cst/rewriter.rbs +31 -0
- data/sig/ibex/runtime/cst/serialize.rbs +39 -0
- data/sig/ibex/runtime/cst/serialized_tree.rbs +34 -0
- data/sig/ibex/runtime/cst/source_text.rbs +51 -0
- data/sig/ibex/runtime/cst/syntax_node.rbs +195 -0
- data/sig/ibex/runtime/cst/syntax_token.rbs +112 -0
- data/sig/ibex/runtime/cst/text_edit.rbs +33 -0
- data/sig/ibex/runtime/cst/typed_node.rbs +50 -0
- data/sig/ibex/runtime/cst/validator.rbs +108 -0
- data/sig/ibex/runtime/cst.rbs +9 -0
- data/sig/ibex/runtime/event.rbs +26 -0
- data/sig/ibex/runtime/event_jsonl_tracer.rbs +25 -0
- data/sig/ibex/runtime/event_sanitizer.rbs +92 -0
- data/sig/ibex/runtime/generated_lexer.rbs +169 -0
- data/sig/ibex/runtime/jsonl_tracer.rbs +42 -0
- data/sig/ibex/runtime/lexer_input.rbs +44 -0
- data/sig/ibex/runtime/location_span.rbs +64 -0
- data/sig/ibex/runtime/observation.rbs +35 -0
- data/sig/ibex/runtime/parser.rbs +926 -0
- data/sig/ibex/runtime/parser_sync_recovery.rbs +60 -0
- data/sig/ibex/runtime/repair.rbs +92 -0
- data/sig/ibex/runtime/repair_priority_queue.rbs +27 -0
- data/sig/ibex/runtime/repair_search.rbs +114 -0
- data/sig/ibex/runtime/resource_limits.rbs +39 -0
- data/sig/ibex/runtime/table_format.rbs +11 -0
- data/sig/ibex/runtime/version.rbs +7 -0
- data/sig/ibex/runtime.rbs +6 -0
- data/sig/ibex/tables/compact.rbs +70 -0
- data/sig/ibex/tables/compact_actions.rbs +57 -0
- data/sig/ibex/tables/compact_productions.rbs +68 -0
- metadata +144 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Generated from lib/ibex/runtime/parser_sync_recovery.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Ibex
|
|
4
|
+
module Runtime
|
|
5
|
+
# Panic-mode synchronization used only when yacc's explicit `error` token
|
|
6
|
+
# cannot be shifted. Included by Parser to share its table and event paths.
|
|
7
|
+
module ParserSyncRecovery
|
|
8
|
+
ERROR_ACTION: [ :error ]
|
|
9
|
+
|
|
10
|
+
private def parser_tables: () -> Hash[Symbol, untyped]
|
|
11
|
+
|
|
12
|
+
private def table_lookup: (untyped, Integer, Integer) -> untyped
|
|
13
|
+
|
|
14
|
+
private def default_action: (Integer) -> untyped
|
|
15
|
+
|
|
16
|
+
private def token_to_str: (untyped) -> String
|
|
17
|
+
|
|
18
|
+
private def trace: (String) -> void
|
|
19
|
+
|
|
20
|
+
private def continue_recovery: () -> untyped
|
|
21
|
+
|
|
22
|
+
private def reject_recovery_eof: () -> [ :done, nil ]
|
|
23
|
+
|
|
24
|
+
private def finish_recovery: (untyped, untyped, untyped, untyped, Integer, Array[untyped], Hash[String, untyped]?, String, Array[Proc]?) -> [ :continue ]
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
# @rbs () -> bool
|
|
29
|
+
def sync_recovery_configured?: () -> bool
|
|
30
|
+
|
|
31
|
+
# @rbs () -> bool
|
|
32
|
+
def sync_recovery_active?: () -> bool
|
|
33
|
+
|
|
34
|
+
# @rbs (Hash[Symbol, untyped] context, Hash[String, untyped]? token_data,
|
|
35
|
+
# Array[Proc]? observers) -> untyped
|
|
36
|
+
def begin_sync_recovery: (Hash[Symbol, untyped] context, Hash[String, untyped]? token_data, Array[Proc]? observers) -> untyped
|
|
37
|
+
|
|
38
|
+
# @rbs () -> untyped
|
|
39
|
+
def continue_sync_recovery: () -> untyped
|
|
40
|
+
|
|
41
|
+
# @rbs (untyped token_id) -> bool
|
|
42
|
+
def sync_token?: (untyped token_id) -> bool
|
|
43
|
+
|
|
44
|
+
# @rbs () -> bool
|
|
45
|
+
def synchronize_for_current_token: () -> bool
|
|
46
|
+
|
|
47
|
+
# @rbs (Integer state, Integer token_id) -> untyped
|
|
48
|
+
def sync_action: (Integer state, Integer token_id) -> untyped
|
|
49
|
+
|
|
50
|
+
# @rbs () -> [:continue]
|
|
51
|
+
def finish_sync_recovery: () -> [ :continue ]
|
|
52
|
+
|
|
53
|
+
# @rbs () -> [:done, nil]
|
|
54
|
+
def reject_sync_recovery_eof: () -> [ :done, nil ]
|
|
55
|
+
|
|
56
|
+
# @rbs () -> void
|
|
57
|
+
def clear_sync_recovery: () -> void
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Generated from lib/ibex/runtime/repair.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Ibex
|
|
4
|
+
module Runtime
|
|
5
|
+
# Explicit bounded cost and search policy for automatic token repair.
|
|
6
|
+
class RepairPolicy
|
|
7
|
+
attr_reader insert_cost: Integer
|
|
8
|
+
|
|
9
|
+
attr_reader delete_cost: Integer
|
|
10
|
+
|
|
11
|
+
attr_reader replace_cost: Integer
|
|
12
|
+
|
|
13
|
+
attr_reader max_cost: Integer
|
|
14
|
+
|
|
15
|
+
attr_reader max_configurations: Integer
|
|
16
|
+
|
|
17
|
+
attr_reader max_lookahead: Integer
|
|
18
|
+
|
|
19
|
+
attr_reader success_shifts: Integer
|
|
20
|
+
|
|
21
|
+
attr_reader max_stack: Integer
|
|
22
|
+
|
|
23
|
+
# @rbs (?insert_cost: Integer, ?delete_cost: Integer, ?replace_cost: Integer, ?max_cost: Integer,
|
|
24
|
+
# ?max_configurations: Integer, ?max_lookahead: Integer, ?success_shifts: Integer,
|
|
25
|
+
# ?max_stack: Integer) -> void
|
|
26
|
+
def initialize: (?insert_cost: Integer, ?delete_cost: Integer, ?replace_cost: Integer, ?max_cost: Integer, ?max_configurations: Integer, ?max_lookahead: Integer, ?success_shifts: Integer, ?max_stack: Integer) -> void
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# One immutable insertion, deletion, or replacement.
|
|
30
|
+
class RepairEdit
|
|
31
|
+
KINDS: Array[Symbol]
|
|
32
|
+
|
|
33
|
+
attr_reader kind: Symbol
|
|
34
|
+
|
|
35
|
+
attr_reader position: Integer
|
|
36
|
+
|
|
37
|
+
attr_reader token_id: Integer
|
|
38
|
+
|
|
39
|
+
attr_reader token_name: String
|
|
40
|
+
|
|
41
|
+
attr_reader cost: Integer
|
|
42
|
+
|
|
43
|
+
# @rbs (kind: Symbol, position: Integer, token_id: Integer, token_name: String, cost: Integer) -> void
|
|
44
|
+
def initialize: (kind: Symbol, position: Integer, token_id: Integer, token_name: String, cost: Integer) -> void
|
|
45
|
+
|
|
46
|
+
# @rbs () -> Hash[Symbol, untyped]
|
|
47
|
+
def to_h: () -> Hash[Symbol, untyped]
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Deterministically selected repair.
|
|
51
|
+
class RepairPlan
|
|
52
|
+
attr_reader edits: Array[RepairEdit]
|
|
53
|
+
|
|
54
|
+
attr_reader cost: Integer
|
|
55
|
+
|
|
56
|
+
attr_reader configurations: Integer
|
|
57
|
+
|
|
58
|
+
# @rbs (edits: Array[RepairEdit], configurations: Integer) -> void
|
|
59
|
+
def initialize: (edits: Array[RepairEdit], configurations: Integer) -> void
|
|
60
|
+
|
|
61
|
+
# @rbs () -> Hash[Symbol, untyped]
|
|
62
|
+
def to_h: () -> Hash[Symbol, untyped]
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Internal normalized input record retained while repair looks ahead.
|
|
66
|
+
class RepairInput
|
|
67
|
+
attr_reader token_id: Integer
|
|
68
|
+
|
|
69
|
+
attr_reader token_name: String
|
|
70
|
+
|
|
71
|
+
attr_reader value: untyped
|
|
72
|
+
|
|
73
|
+
attr_reader location: untyped
|
|
74
|
+
|
|
75
|
+
# @rbs (token_id: Integer, token_name: String, value: untyped, location: untyped) -> void
|
|
76
|
+
def initialize: (token_id: Integer, token_name: String, value: untyped, location: untyped) -> void
|
|
77
|
+
|
|
78
|
+
# @rbs () -> bool
|
|
79
|
+
def eof?: () -> bool
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Internal result of simulating reductions followed by one table action.
|
|
83
|
+
class RepairAdvance
|
|
84
|
+
attr_reader status: :shift | :accept
|
|
85
|
+
|
|
86
|
+
attr_reader stack: Array[Integer]
|
|
87
|
+
|
|
88
|
+
# @rbs (status: :shift | :accept, stack: Array[Integer]) -> void
|
|
89
|
+
def initialize: (status: :shift | :accept, stack: Array[Integer]) -> void
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Generated from lib/ibex/runtime/repair_priority_queue.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Ibex
|
|
4
|
+
module Runtime
|
|
5
|
+
# Minimal binary heap ordered by an immutable Array priority.
|
|
6
|
+
class RepairPriorityQueue
|
|
7
|
+
@entries: Array[[ Array[untyped], untyped ]]
|
|
8
|
+
|
|
9
|
+
# @rbs () -> void
|
|
10
|
+
def initialize: () -> void
|
|
11
|
+
|
|
12
|
+
# @rbs () -> bool
|
|
13
|
+
def empty?: () -> bool
|
|
14
|
+
|
|
15
|
+
# @rbs (Array[untyped] priority, untyped value) -> void
|
|
16
|
+
def push: (Array[untyped] priority, untyped value) -> void
|
|
17
|
+
|
|
18
|
+
# @rbs () -> [Array[untyped], untyped]?
|
|
19
|
+
def pop: () -> [ Array[untyped], untyped ]?
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
# @rbs ([Array[untyped], untyped] left, [Array[untyped], untyped] right) -> Integer
|
|
24
|
+
def compare: ([ Array[untyped], untyped ] left, [ Array[untyped], untyped ] right) -> Integer
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Generated from lib/ibex/runtime/repair_search.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Ibex
|
|
4
|
+
module Runtime
|
|
5
|
+
# Bounded Dijkstra search over LR state stacks. Semantic actions never run.
|
|
6
|
+
# rubocop:disable Metrics/ClassLength -- queue policy and LR transitions form one bounded search invariant.
|
|
7
|
+
class RepairSearch
|
|
8
|
+
NEED_INPUT: Object
|
|
9
|
+
|
|
10
|
+
LIMIT: Object
|
|
11
|
+
|
|
12
|
+
class Configuration < Struct[untyped]
|
|
13
|
+
attr_accessor stack(): untyped
|
|
14
|
+
|
|
15
|
+
attr_accessor input_index(): untyped
|
|
16
|
+
|
|
17
|
+
attr_accessor shifts(): untyped
|
|
18
|
+
|
|
19
|
+
attr_accessor cost(): untyped
|
|
20
|
+
|
|
21
|
+
attr_accessor edits(): untyped
|
|
22
|
+
|
|
23
|
+
attr_accessor goal(): untyped
|
|
24
|
+
|
|
25
|
+
def self.new: (?stack: untyped, ?input_index: untyped, ?shifts: untyped, ?cost: untyped, ?edits: untyped, ?goal: untyped) -> instance
|
|
26
|
+
| ({ ?stack: untyped, ?input_index: untyped, ?shifts: untyped, ?cost: untyped, ?edits: untyped, ?goal: untyped }) -> instance
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
@candidate_ids: Array[Integer]
|
|
30
|
+
|
|
31
|
+
@best: Hash[Array[untyped], Array[untyped]]
|
|
32
|
+
|
|
33
|
+
@heap: RepairPriorityQueue
|
|
34
|
+
|
|
35
|
+
@configurations: Integer
|
|
36
|
+
|
|
37
|
+
@complete: bool
|
|
38
|
+
|
|
39
|
+
@tokens: Array[RepairInput]
|
|
40
|
+
|
|
41
|
+
@policy: RepairPolicy
|
|
42
|
+
|
|
43
|
+
@tables: Hash[Symbol, untyped]
|
|
44
|
+
|
|
45
|
+
# @rbs (Hash[Symbol, untyped] tables, RepairPolicy policy, Array[RepairInput] tokens,
|
|
46
|
+
# complete: bool) -> void
|
|
47
|
+
def initialize: (Hash[Symbol, untyped] tables, RepairPolicy policy, Array[RepairInput] tokens, complete: bool) -> void
|
|
48
|
+
|
|
49
|
+
# @rbs (Array[Integer] state_stack) -> (RepairPlan | Object | nil)
|
|
50
|
+
def search: (Array[Integer] state_stack) -> (RepairPlan | Object | nil)
|
|
51
|
+
|
|
52
|
+
private
|
|
53
|
+
|
|
54
|
+
# @rbs (Configuration configuration) -> (RepairPlan | Object | nil)
|
|
55
|
+
def visit: (Configuration configuration) -> (RepairPlan | Object | nil)
|
|
56
|
+
|
|
57
|
+
# @rbs (Configuration configuration) -> (RepairPlan | Object | nil)
|
|
58
|
+
def expand: (Configuration configuration) -> (RepairPlan | Object | nil)
|
|
59
|
+
|
|
60
|
+
# @rbs (Configuration configuration, RepairInput current) -> (RepairPlan | Object | nil)
|
|
61
|
+
def expand_edits: (Configuration configuration, RepairInput current) -> (RepairPlan | Object | nil)
|
|
62
|
+
|
|
63
|
+
# @rbs (Configuration configuration, :insert | :replace kind)
|
|
64
|
+
# -> (RepairPlan | Object | nil)
|
|
65
|
+
def expand_candidates: (Configuration configuration, :insert | :replace kind) -> (RepairPlan | Object | nil)
|
|
66
|
+
|
|
67
|
+
# @rbs (Configuration configuration, :insert | :replace kind, Integer token_id, Integer cost) -> Object?
|
|
68
|
+
def expand_candidate: (Configuration configuration, :insert | :replace kind, Integer token_id, Integer cost) -> Object?
|
|
69
|
+
|
|
70
|
+
# @rbs (Configuration configuration, Symbol kind, Integer token_id, Integer cost) -> Array[RepairEdit]
|
|
71
|
+
def candidate_edits: (Configuration configuration, Symbol kind, Integer token_id, Integer cost) -> Array[RepairEdit]
|
|
72
|
+
|
|
73
|
+
# @rbs (Configuration configuration, RepairInput current) -> void
|
|
74
|
+
def push_delete: (Configuration configuration, RepairInput current) -> void
|
|
75
|
+
|
|
76
|
+
# @rbs (Array[Integer] stack, Integer token_id) -> (RepairAdvance | Object | nil)
|
|
77
|
+
def advance: (Array[Integer] stack, Integer token_id) -> (RepairAdvance | Object | nil)
|
|
78
|
+
|
|
79
|
+
# @rbs (Array[Integer] states, Integer production_id) -> Array[Integer]?
|
|
80
|
+
def apply_reduction: (Array[Integer] states, Integer production_id) -> Array[Integer]?
|
|
81
|
+
|
|
82
|
+
# @rbs (Integer state, Integer token_id) -> untyped
|
|
83
|
+
def action_for: (Integer state, Integer token_id) -> untyped
|
|
84
|
+
|
|
85
|
+
# @rbs (untyped table, Integer row, Integer column) -> untyped
|
|
86
|
+
def table_lookup: (untyped table, Integer row, Integer column) -> untyped
|
|
87
|
+
|
|
88
|
+
# @rbs (Configuration source, ?stack: Array[Integer], ?input_index: Integer, ?shifts: Integer,
|
|
89
|
+
# ?cost: Integer, ?edits: Array[RepairEdit], ?goal: bool) -> Configuration
|
|
90
|
+
def configuration_with: (Configuration source, ?stack: Array[Integer], ?input_index: Integer, ?shifts: Integer, ?cost: Integer, ?edits: Array[RepairEdit], ?goal: bool) -> Configuration
|
|
91
|
+
|
|
92
|
+
# @rbs (Array[RepairEdit] edits) -> RepairPlan
|
|
93
|
+
def plan: (Array[RepairEdit] edits) -> RepairPlan
|
|
94
|
+
|
|
95
|
+
# @rbs (Integer token_id) -> String
|
|
96
|
+
def token_name: (Integer token_id) -> String
|
|
97
|
+
|
|
98
|
+
# @rbs (Configuration configuration) -> void
|
|
99
|
+
def push: (Configuration configuration) -> void
|
|
100
|
+
|
|
101
|
+
# @rbs () -> (Configuration | Object)
|
|
102
|
+
def pop: () -> (Configuration | Object)
|
|
103
|
+
|
|
104
|
+
# @rbs (Configuration configuration) -> Array[untyped]
|
|
105
|
+
def priority_for: (Configuration configuration) -> Array[untyped]
|
|
106
|
+
|
|
107
|
+
# Prefer punctuation edits when equal-cost repairs are otherwise
|
|
108
|
+
# ambiguous; inventing or discarding a word-like token is more likely to
|
|
109
|
+
# fabricate or lose an application semantic value.
|
|
110
|
+
# @rbs (RepairEdit edit) -> Integer
|
|
111
|
+
def semantic_value_risk: (RepairEdit edit) -> Integer
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Generated from lib/ibex/runtime/resource_limits.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Ibex
|
|
4
|
+
module Runtime
|
|
5
|
+
# Immutable per-parser-session resource budgets.
|
|
6
|
+
class ResourceLimits
|
|
7
|
+
DEFAULT_MAX_STACK_DEPTH: Integer
|
|
8
|
+
|
|
9
|
+
DEFAULT_MAX_RECOVERY_ATTEMPTS: Integer
|
|
10
|
+
|
|
11
|
+
DEFAULT_MAX_INCREMENTAL_DECOMPOSED_NODES: Integer
|
|
12
|
+
|
|
13
|
+
DEFAULT_MAX_SESSION_MEMO_BYTES: Integer
|
|
14
|
+
|
|
15
|
+
attr_reader max_stack_depth: Integer
|
|
16
|
+
|
|
17
|
+
attr_reader max_recovery_attempts: Integer
|
|
18
|
+
|
|
19
|
+
attr_reader max_incremental_decomposed_nodes: Integer
|
|
20
|
+
|
|
21
|
+
attr_reader max_session_memo_bytes: Integer
|
|
22
|
+
|
|
23
|
+
# @rbs (?max_stack_depth: Integer, ?max_recovery_attempts: Integer,
|
|
24
|
+
# ?max_incremental_decomposed_nodes: Integer, ?max_session_memo_bytes: Integer) -> void
|
|
25
|
+
def initialize: (?max_stack_depth: Integer, ?max_recovery_attempts: Integer, ?max_incremental_decomposed_nodes: Integer, ?max_session_memo_bytes: Integer) -> void
|
|
26
|
+
|
|
27
|
+
# @rbs () -> Hash[Symbol, Integer]
|
|
28
|
+
def to_h: () -> Hash[Symbol, Integer]
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
# @rbs (Integer value, Symbol name) -> void
|
|
33
|
+
def validate_positive_integer: (Integer value, Symbol name) -> void
|
|
34
|
+
|
|
35
|
+
# @rbs (Integer value, Symbol name) -> void
|
|
36
|
+
def validate_nonnegative_integer: (Integer value, Symbol name) -> void
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Generated from lib/ibex/runtime/table_format.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Ibex
|
|
4
|
+
module Runtime
|
|
5
|
+
# Current parser-table shape emitted by the generator.
|
|
6
|
+
PARSER_TABLE_FORMAT_VERSION: Integer
|
|
7
|
+
|
|
8
|
+
# Parser-table shapes this runtime can execute.
|
|
9
|
+
SUPPORTED_PARSER_TABLE_FORMAT_VERSIONS: Array[Integer]
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Generated from lib/ibex/tables/compact.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Ibex
|
|
4
|
+
module Tables
|
|
5
|
+
# Encodes nonnegative integer arrays into compact generated-source
|
|
6
|
+
# literals. Zero represents nil; positive values are offset by one.
|
|
7
|
+
module PackedIntegers
|
|
8
|
+
# @rbs (Array[Integer?] values) -> String
|
|
9
|
+
def self?.encode: (Array[Integer?] values) -> String
|
|
10
|
+
|
|
11
|
+
# @rbs (String source) -> Array[Integer?]
|
|
12
|
+
def self?.decode: (String source) -> Array[Integer?]
|
|
13
|
+
|
|
14
|
+
# @rbs (String source) -> Array[Integer]
|
|
15
|
+
def self?.decode_required: (String source) -> Array[Integer]
|
|
16
|
+
|
|
17
|
+
# Zigzag-encode signed values after reserving zero for nil.
|
|
18
|
+
# @rbs (Array[Integer?] values) -> String
|
|
19
|
+
def self?.encode_signed: (Array[Integer?] values) -> String
|
|
20
|
+
|
|
21
|
+
# @rbs (String source) -> Array[Integer?]
|
|
22
|
+
def self?.decode_signed: (String source) -> Array[Integer?]
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Sparse table represented by per-row offsets and ownership checks.
|
|
26
|
+
class Compact
|
|
27
|
+
DENSE_CELL_LIMIT: Integer
|
|
28
|
+
|
|
29
|
+
attr_reader offsets: Array[Integer]
|
|
30
|
+
|
|
31
|
+
attr_reader values: Array[untyped]
|
|
32
|
+
|
|
33
|
+
attr_reader checks: Array[Integer?]
|
|
34
|
+
|
|
35
|
+
attr_reader row_count: Integer
|
|
36
|
+
|
|
37
|
+
attr_reader dense_values: Array[untyped]?
|
|
38
|
+
|
|
39
|
+
attr_reader dense_width: Integer?
|
|
40
|
+
|
|
41
|
+
# @rbs (Array[Hash[Integer, untyped]] rows, ?dense: bool) -> Compact
|
|
42
|
+
def self.build: (Array[Hash[Integer, untyped]] rows, ?dense: bool) -> Compact
|
|
43
|
+
|
|
44
|
+
# @rbs (String offsets, String values, String checks, row_count: Integer,
|
|
45
|
+
# ?dense_width: Integer?) -> Compact
|
|
46
|
+
def self.packed: (String offsets, String values, String checks, row_count: Integer, ?dense_width: Integer?) -> Compact
|
|
47
|
+
|
|
48
|
+
# @rbs (Array[Integer] columns, Array[Integer?] checks, Hash[Array[Integer], Integer] next_offsets) -> Integer
|
|
49
|
+
private def self.find_offset: (Array[Integer] columns, Array[Integer?] checks, Hash[Array[Integer], Integer] next_offsets) -> Integer
|
|
50
|
+
|
|
51
|
+
# @rbs (offsets: Array[Integer], values: Array[untyped], checks: Array[Integer?],
|
|
52
|
+
# row_count: Integer, ?dense_width: Integer?) -> void
|
|
53
|
+
def self?.initialize: (offsets: Array[Integer], values: Array[untyped], checks: Array[Integer?], row_count: Integer, ?dense_width: Integer?) -> void
|
|
54
|
+
|
|
55
|
+
# Keep predicate dispatch out of this lookup because every parser action
|
|
56
|
+
# and goto crosses it.
|
|
57
|
+
# rubocop:disable Style/NumericPredicate
|
|
58
|
+
# @rbs (Integer row, Integer column) -> untyped
|
|
59
|
+
def self?.lookup: (Integer row, Integer column) -> untyped
|
|
60
|
+
|
|
61
|
+
# @rbs (Integer row) -> Hash[Integer, untyped]
|
|
62
|
+
def self?.row: (Integer row) -> Hash[Integer, untyped]
|
|
63
|
+
|
|
64
|
+
private
|
|
65
|
+
|
|
66
|
+
# @rbs (Integer? dense_width) -> Array[untyped]?
|
|
67
|
+
def self?.dense_layout: (Integer? dense_width) -> Array[untyped]?
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Generated from lib/ibex/tables/compact_actions.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Ibex
|
|
4
|
+
module Tables
|
|
5
|
+
# Compact action table with an integer-coded hot representation and a
|
|
6
|
+
# compatible decoded lookup surface for the generic runtime.
|
|
7
|
+
class CompactActions < Compact
|
|
8
|
+
ACCEPT_CODE: Integer
|
|
9
|
+
|
|
10
|
+
ERROR_CODE: Integer
|
|
11
|
+
|
|
12
|
+
SHIFT_BASE: Integer
|
|
13
|
+
|
|
14
|
+
REDUCE_BASE: Integer
|
|
15
|
+
|
|
16
|
+
LEGACY_ERROR_CODE: Integer
|
|
17
|
+
|
|
18
|
+
LEGACY_SHIFT_BASE: Integer
|
|
19
|
+
|
|
20
|
+
LEGACY_REDUCE_BASE: Integer
|
|
21
|
+
|
|
22
|
+
attr_reader codes: Array[Integer?]
|
|
23
|
+
|
|
24
|
+
attr_reader dense_codes: Array[Integer?]?
|
|
25
|
+
|
|
26
|
+
attr_reader column_count: Integer?
|
|
27
|
+
|
|
28
|
+
# @rbs (Array[Hash[Integer, untyped]] rows) -> CompactActions
|
|
29
|
+
def self.build: (Array[Hash[Integer, untyped]] rows) -> CompactActions
|
|
30
|
+
|
|
31
|
+
# @rbs (String offsets, String codes, String checks, row_count: Integer,
|
|
32
|
+
# ?encoding: Symbol, ?column_count: Integer?) -> CompactActions
|
|
33
|
+
def self.packed: (String offsets, String codes, String checks, row_count: Integer, ?encoding: Symbol, ?column_count: Integer?) -> CompactActions
|
|
34
|
+
|
|
35
|
+
# @rbs (untyped action) -> Integer?
|
|
36
|
+
def self.pack: (untyped action) -> Integer?
|
|
37
|
+
|
|
38
|
+
# @rbs (Integer? code) -> untyped
|
|
39
|
+
def self.unpack: (Integer? code) -> untyped
|
|
40
|
+
|
|
41
|
+
# Convert codes emitted before signed compact actions without changing
|
|
42
|
+
# their generated table literals.
|
|
43
|
+
# @rbs (Integer? code) -> Integer?
|
|
44
|
+
def self.legacy_to_signed: (Integer? code) -> Integer?
|
|
45
|
+
|
|
46
|
+
# @rbs (offsets: Array[Integer], codes: Array[Integer?], checks: Array[Integer?],
|
|
47
|
+
# row_count: Integer, ?encoding: Symbol, ?column_count: Integer?) -> void
|
|
48
|
+
def initialize: (offsets: Array[Integer], codes: Array[Integer?], checks: Array[Integer?], row_count: Integer, ?encoding: Symbol, ?column_count: Integer?) -> void
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
|
|
52
|
+
# @rbs (Array[Integer] offsets, Array[Integer?] codes, Array[Integer?] checks,
|
|
53
|
+
# Integer row_count, Integer? column_count) -> Array[Integer?]?
|
|
54
|
+
def dense_action_layout: (Array[Integer] offsets, Array[Integer?] codes, Array[Integer?] checks, Integer row_count, Integer? column_count) -> Array[Integer?]?
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Generated from lib/ibex/tables/compact_productions.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Ibex
|
|
4
|
+
module Tables
|
|
5
|
+
# Production metadata with parallel primitive arrays for the direct parser
|
|
6
|
+
# and a compatible Array-of-Hash surface for generic runtime consumers.
|
|
7
|
+
class CompactProductions < Array[Hash[Symbol, untyped]]
|
|
8
|
+
VALUES_ACTION: Integer
|
|
9
|
+
|
|
10
|
+
BORROWED_VALUES_ACTION: Integer
|
|
11
|
+
|
|
12
|
+
LOCATION_ACTION: Integer
|
|
13
|
+
|
|
14
|
+
COMPOSITION_ACTION: Integer
|
|
15
|
+
|
|
16
|
+
POSITIONAL_ACTION: Integer
|
|
17
|
+
|
|
18
|
+
VALID_FLAGS: Integer
|
|
19
|
+
|
|
20
|
+
CORE_FIELDS: Array[Symbol]
|
|
21
|
+
|
|
22
|
+
attr_reader lhs_ids: Array[Integer]
|
|
23
|
+
|
|
24
|
+
attr_reader lengths: Array[Integer]
|
|
25
|
+
|
|
26
|
+
attr_reader actions: Array[Symbol?]
|
|
27
|
+
|
|
28
|
+
attr_reader flags: Array[Integer]
|
|
29
|
+
|
|
30
|
+
# @rbs (Array[Hash[Symbol, untyped]] productions) -> CompactProductions
|
|
31
|
+
def self.build: (Array[Hash[Symbol, untyped]] productions) -> CompactProductions
|
|
32
|
+
|
|
33
|
+
# @rbs (String lhs_ids, String lengths, String flags,
|
|
34
|
+
# ?metadata: Hash[Integer, Hash[Symbol, untyped]]) -> CompactProductions
|
|
35
|
+
def self.packed: (String lhs_ids, String lengths, String flags, ?metadata: Hash[Integer, Hash[Symbol, untyped]]) -> CompactProductions
|
|
36
|
+
|
|
37
|
+
# @rbs (Hash[Symbol, untyped] production) -> Integer
|
|
38
|
+
private def self.flags_for: (Hash[Symbol, untyped] production) -> Integer
|
|
39
|
+
|
|
40
|
+
# @rbs (lhs_ids: Array[Integer], lengths: Array[Integer], actions: Array[Symbol?],
|
|
41
|
+
# flags: Array[Integer], ?metadata: Hash[Integer, Hash[Symbol, untyped]]) -> void
|
|
42
|
+
def initialize: (lhs_ids: Array[Integer], lengths: Array[Integer], actions: Array[Symbol?], flags: Array[Integer], ?metadata: Hash[Integer, Hash[Symbol, untyped]]) -> void
|
|
43
|
+
|
|
44
|
+
# @rbs () -> bool
|
|
45
|
+
def direct_values?: () -> bool
|
|
46
|
+
|
|
47
|
+
private
|
|
48
|
+
|
|
49
|
+
# @rbs (untyped value, String name) -> Integer
|
|
50
|
+
def nonnegative_integer!: (untyped value, String name) -> Integer
|
|
51
|
+
|
|
52
|
+
# @rbs (untyped value) -> Symbol?
|
|
53
|
+
def action!: (untyped value) -> Symbol?
|
|
54
|
+
|
|
55
|
+
# @rbs (untyped value) -> Integer
|
|
56
|
+
def flags!: (untyped value) -> Integer
|
|
57
|
+
|
|
58
|
+
# @rbs () -> void
|
|
59
|
+
def validate_markers!: () -> void
|
|
60
|
+
|
|
61
|
+
# @rbs (Hash[Integer, Hash[Symbol, untyped]] metadata, Integer size) -> void
|
|
62
|
+
def validate_metadata!: (Hash[Integer, Hash[Symbol, untyped]] metadata, Integer size) -> void
|
|
63
|
+
|
|
64
|
+
# @rbs (Integer index, Hash[Symbol, untyped]? metadata) -> Hash[Symbol, untyped]
|
|
65
|
+
def decode: (Integer index, Hash[Symbol, untyped]? metadata) -> Hash[Symbol, untyped]
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|