ibex-runtime 0.2.0 → 0.4.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/README.md +100 -272
- data/lib/ibex/runtime/cst/green/node.rb +1 -1
- data/lib/ibex/runtime/cst/green/token.rb +1 -1
- data/lib/ibex/runtime/cst/green/trivia.rb +1 -1
- data/lib/ibex/runtime/cst/incremental/blender.rb +1 -1
- data/lib/ibex/runtime/cst/incremental/lexed_syntax.rb +2 -2
- data/lib/ibex/runtime/cst/incremental/parse_memo.rb +2 -2
- data/lib/ibex/runtime/cst/incremental/relexer.rb +3 -0
- data/lib/ibex/runtime/cst/incremental/session.rb +26 -2
- data/lib/ibex/runtime/cst/parse_result.rb +7 -7
- data/lib/ibex/runtime/cst/serialize.rb +6 -3
- data/lib/ibex/runtime/cst/syntax_node.rb +4 -4
- data/lib/ibex/runtime/cst/syntax_token.rb +5 -5
- data/lib/ibex/runtime/cst/typed_node.rb +1 -1
- data/lib/ibex/runtime/cst/validator.rb +40 -30
- data/lib/ibex/runtime/embedded_source.rb +98 -0
- data/lib/ibex/runtime/event.rb +7 -4
- data/lib/ibex/runtime/event_jsonl_tracer.rb +1 -1
- data/lib/ibex/runtime/event_sanitizer.rb +32 -26
- data/lib/ibex/runtime/generated_lexer.rb +23 -16
- data/lib/ibex/runtime/lexer_input.rb +1 -1
- data/lib/ibex/runtime/location_span.rb +15 -15
- data/lib/ibex/runtime/observation.rb +1 -1
- data/lib/ibex/runtime/parser.rb +309 -191
- data/lib/ibex/runtime/parser_sync_recovery.rb +19 -15
- data/lib/ibex/runtime/repair.rb +36 -5
- data/lib/ibex/runtime/repair_priority_queue.rb +10 -6
- data/lib/ibex/runtime/repair_search.rb +92 -29
- data/lib/ibex/runtime/syntax_repair.rb +490 -0
- data/lib/ibex/runtime/syntax_session.rb +416 -0
- data/lib/ibex/runtime/table_format.rb +1 -1
- data/lib/ibex/runtime/version.rb +1 -1
- data/lib/ibex/runtime.rb +2 -1
- data/lib/ibex/tables/compact.rb +16 -12
- data/lib/ibex/tables/compact_actions.rb +45 -33
- data/lib/ibex/tables/compact_productions.rb +18 -15
- data/sig/ibex/runtime/cst/green/node.rbs +2 -2
- data/sig/ibex/runtime/cst/green/token.rbs +2 -2
- data/sig/ibex/runtime/cst/green/trivia.rbs +2 -2
- data/sig/ibex/runtime/cst/incremental/blender.rbs +2 -2
- data/sig/ibex/runtime/cst/incremental/lexed_syntax.rbs +3 -3
- data/sig/ibex/runtime/cst/incremental/parse_memo.rbs +4 -4
- data/sig/ibex/runtime/cst/incremental/session.rbs +8 -2
- data/sig/ibex/runtime/cst/parse_result.rbs +9 -9
- data/sig/ibex/runtime/cst/serialize.rbs +8 -6
- data/sig/ibex/runtime/cst/syntax_node.rbs +6 -6
- data/sig/ibex/runtime/cst/syntax_token.rbs +10 -10
- data/sig/ibex/runtime/cst/typed_node.rbs +2 -2
- data/sig/ibex/runtime/cst/validator.rbs +46 -42
- data/sig/ibex/runtime/embedded_source.rbs +21 -0
- data/sig/ibex/runtime/event.rbs +7 -5
- data/sig/ibex/runtime/event_jsonl_tracer.rbs +1 -1
- data/sig/ibex/runtime/event_sanitizer.rbs +50 -44
- data/sig/ibex/runtime/generated_lexer.rbs +31 -24
- data/sig/ibex/runtime/lexer_input.rbs +2 -2
- data/sig/ibex/runtime/location_span.rbs +28 -28
- data/sig/ibex/runtime/observation.rbs +2 -2
- data/sig/ibex/runtime/parser.rbs +266 -252
- data/sig/ibex/runtime/parser_sync_recovery.rbs +15 -15
- data/sig/ibex/runtime/repair.rbs +28 -8
- data/sig/ibex/runtime/repair_priority_queue.rbs +9 -7
- data/sig/ibex/runtime/repair_search.rbs +38 -19
- data/sig/ibex/runtime/syntax_repair.rbs +177 -0
- data/sig/ibex/runtime/syntax_session.rbs +186 -0
- data/sig/ibex/tables/compact.rbs +12 -12
- data/sig/ibex/tables/compact_actions.rbs +10 -17
- data/sig/ibex/tables/compact_productions.rbs +19 -19
- metadata +12 -6
- data/lib/ibex/runtime/jsonl_tracer.rb +0 -75
- data/sig/ibex/runtime/jsonl_tracer.rbs +0 -42
|
@@ -5,7 +5,7 @@ module Ibex
|
|
|
5
5
|
module Tables
|
|
6
6
|
# Production metadata with parallel primitive arrays for the direct parser
|
|
7
7
|
# and a compatible Array-of-Hash surface for generic runtime consumers.
|
|
8
|
-
class CompactProductions < Array #[Hash[Symbol,
|
|
8
|
+
class CompactProductions < Array #[Hash[Symbol, Object?]]
|
|
9
9
|
VALUES_ACTION = 1 #: Integer
|
|
10
10
|
BORROWED_VALUES_ACTION = 2 #: Integer
|
|
11
11
|
LOCATION_ACTION = 4 #: Integer
|
|
@@ -24,17 +24,20 @@ module Ibex
|
|
|
24
24
|
attr_reader :flags #: Array[Integer]
|
|
25
25
|
|
|
26
26
|
class << self
|
|
27
|
-
# @rbs (Array[Hash[Symbol,
|
|
27
|
+
# @rbs (Array[Hash[Symbol, Object?]] productions) -> CompactProductions
|
|
28
28
|
def build(productions)
|
|
29
29
|
lhs_ids = [] #: Array[Integer]
|
|
30
30
|
lengths = [] #: Array[Integer]
|
|
31
31
|
actions = [] #: Array[Symbol?]
|
|
32
32
|
flags = [] #: Array[Integer]
|
|
33
|
-
metadata = {} #: Hash[Integer, Hash[Symbol,
|
|
33
|
+
metadata = {} #: Hash[Integer, Hash[Symbol, Object?]]
|
|
34
34
|
productions.each_with_index do |production, index|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
lhs = production.fetch(:lhs) #: Integer
|
|
36
|
+
length = production.fetch(:length) #: Integer
|
|
37
|
+
action = production[:action] #: Symbol?
|
|
38
|
+
lhs_ids << lhs
|
|
39
|
+
lengths << length
|
|
40
|
+
actions << action
|
|
38
41
|
flags << flags_for(production)
|
|
39
42
|
extra = production.except(
|
|
40
43
|
:lhs, :length, :action, :values_action, :borrowed_values_action, :location_action, :composition_action
|
|
@@ -45,7 +48,7 @@ module Ibex
|
|
|
45
48
|
end
|
|
46
49
|
|
|
47
50
|
# @rbs (String lhs_ids, String lengths, String flags,
|
|
48
|
-
# ?metadata: Hash[Integer, Hash[Symbol,
|
|
51
|
+
# ?metadata: Hash[Integer, Hash[Symbol, Object?]]) -> CompactProductions
|
|
49
52
|
def packed(lhs_ids, lengths, flags, metadata: {})
|
|
50
53
|
decoded_flags = PackedIntegers.decode_required(flags)
|
|
51
54
|
actions = decoded_flags.each_index.map do |index|
|
|
@@ -62,7 +65,7 @@ module Ibex
|
|
|
62
65
|
|
|
63
66
|
private
|
|
64
67
|
|
|
65
|
-
# @rbs (Hash[Symbol,
|
|
68
|
+
# @rbs (Hash[Symbol, Object?] production) -> Integer
|
|
66
69
|
def flags_for(production)
|
|
67
70
|
value = 0
|
|
68
71
|
value |= VALUES_ACTION if production[:values_action] == true
|
|
@@ -74,7 +77,7 @@ module Ibex
|
|
|
74
77
|
end
|
|
75
78
|
|
|
76
79
|
# @rbs (lhs_ids: Array[Integer], lengths: Array[Integer], actions: Array[Symbol?],
|
|
77
|
-
# flags: Array[Integer], ?metadata: Hash[Integer, Hash[Symbol,
|
|
80
|
+
# flags: Array[Integer], ?metadata: Hash[Integer, Hash[Symbol, Object?]]) -> void
|
|
78
81
|
def initialize(lhs_ids:, lengths:, actions:, flags:, metadata: {})
|
|
79
82
|
size = lhs_ids.length
|
|
80
83
|
unless lengths.length == size && actions.length == size && flags.length == size
|
|
@@ -98,21 +101,21 @@ module Ibex
|
|
|
98
101
|
|
|
99
102
|
private
|
|
100
103
|
|
|
101
|
-
# @rbs (
|
|
104
|
+
# @rbs (Object? value, String name) -> Integer
|
|
102
105
|
def nonnegative_integer!(value, name)
|
|
103
106
|
return value if value.is_a?(Integer) && !value.negative?
|
|
104
107
|
|
|
105
108
|
raise ArgumentError, "compact production #{name} must be a nonnegative Integer"
|
|
106
109
|
end
|
|
107
110
|
|
|
108
|
-
# @rbs (
|
|
111
|
+
# @rbs (Object? value) -> Symbol?
|
|
109
112
|
def action!(value)
|
|
110
113
|
return value if value.nil? || value.is_a?(Symbol)
|
|
111
114
|
|
|
112
115
|
raise ArgumentError, "compact production action must be a Symbol or nil"
|
|
113
116
|
end
|
|
114
117
|
|
|
115
|
-
# @rbs (
|
|
118
|
+
# @rbs (Object? value) -> Integer
|
|
116
119
|
def flags!(value)
|
|
117
120
|
return value if value.is_a?(Integer) && !value.negative? && value.nobits?(~VALID_FLAGS)
|
|
118
121
|
|
|
@@ -135,7 +138,7 @@ module Ibex
|
|
|
135
138
|
end
|
|
136
139
|
end
|
|
137
140
|
|
|
138
|
-
# @rbs (Hash[Integer, Hash[Symbol,
|
|
141
|
+
# @rbs (Hash[Integer, Hash[Symbol, Object?]] metadata, Integer size) -> void
|
|
139
142
|
def validate_metadata!(metadata, size)
|
|
140
143
|
metadata.each do |index, entry|
|
|
141
144
|
unless index.is_a?(Integer) && index.between?(0, size - 1) && entry.is_a?(Hash)
|
|
@@ -147,9 +150,9 @@ module Ibex
|
|
|
147
150
|
end
|
|
148
151
|
end
|
|
149
152
|
|
|
150
|
-
# @rbs (Integer index, Hash[Symbol,
|
|
153
|
+
# @rbs (Integer index, Hash[Symbol, Object?]? metadata) -> Hash[Symbol, Object?]
|
|
151
154
|
def decode(index, metadata)
|
|
152
|
-
entry = {} #: Hash[Symbol,
|
|
155
|
+
entry = {} #: Hash[Symbol, Object?]
|
|
153
156
|
entry[:lhs] = @lhs_ids[index]
|
|
154
157
|
entry[:length] = @lengths[index]
|
|
155
158
|
entry[:action] = @actions[index]
|
|
@@ -64,8 +64,8 @@ module Ibex
|
|
|
64
64
|
def initialize: (old_root: SyntaxNode, parse_memo: ParseMemo, lexed: LexedSyntax, edits: Array[TextEdit], max_decomposed_nodes: Integer, ?enabled: bool) -> void
|
|
65
65
|
|
|
66
66
|
# Return the next token or a whole nonterminal valid in the current LR state.
|
|
67
|
-
# @rbs (Integer state) -> (Array[
|
|
68
|
-
def next_for_state: (Integer state) -> (Array[
|
|
67
|
+
# @rbs (Integer state) -> (Array[Object?] | ReusableSubtree | false)
|
|
68
|
+
def next_for_state: (Integer state) -> (Array[Object?] | ReusableSubtree | false)
|
|
69
69
|
|
|
70
70
|
# @rbs () -> Integer
|
|
71
71
|
def token_count: () -> Integer
|
|
@@ -5,12 +5,12 @@ module Ibex
|
|
|
5
5
|
module CST
|
|
6
6
|
# One complete generated-lexer pass, including the explicit EOF token.
|
|
7
7
|
class LexedSyntax
|
|
8
|
-
attr_reader raw_tokens: Array[Array[
|
|
8
|
+
attr_reader raw_tokens: Array[Array[Object?]]
|
|
9
9
|
|
|
10
10
|
attr_reader memo: TokenMemo
|
|
11
11
|
|
|
12
|
-
# @rbs (raw_tokens: Array[Array[
|
|
13
|
-
def initialize: (raw_tokens: Array[Array[
|
|
12
|
+
# @rbs (raw_tokens: Array[Array[Object?]], memo: TokenMemo) -> void
|
|
13
|
+
def initialize: (raw_tokens: Array[Array[Object?]], memo: TokenMemo) -> void
|
|
14
14
|
|
|
15
15
|
# @rbs (TokenMemo replacement) -> LexedSyntax
|
|
16
16
|
def with_memo: (TokenMemo replacement) -> LexedSyntax
|
|
@@ -27,14 +27,14 @@ module Ibex
|
|
|
27
27
|
# @rbs (Integer preorder_index, GreenNode | GreenToken element) -> Array[Integer?]
|
|
28
28
|
def slice: (Integer preorder_index, GreenNode | GreenToken element) -> Array[Integer?]
|
|
29
29
|
|
|
30
|
-
# @rbs (Hash[Symbol,
|
|
31
|
-
def compatible?: (Hash[Symbol,
|
|
30
|
+
# @rbs (Hash[Symbol, String | Integer] tables) -> bool
|
|
31
|
+
def compatible?: (Hash[Symbol, String | Integer] tables) -> bool
|
|
32
32
|
|
|
33
33
|
# @rbs () -> Integer
|
|
34
34
|
def estimated_bytes: () -> Integer
|
|
35
35
|
|
|
36
|
-
# @rbs () -> Hash[String,
|
|
37
|
-
def to_h: () -> Hash[String,
|
|
36
|
+
# @rbs () -> Hash[String, Integer | Array[Integer?]]
|
|
37
|
+
def to_h: () -> Hash[String, Integer | Array[Integer?]]
|
|
38
38
|
|
|
39
39
|
# Lightweight construction tree flattened once when a parse completes.
|
|
40
40
|
class Entry
|
|
@@ -31,8 +31,9 @@ module Ibex
|
|
|
31
31
|
|
|
32
32
|
@resource_limits: ResourceLimits
|
|
33
33
|
|
|
34
|
-
# @rbs (Class parser_class, SourceText source_text, ?resource_limits: ResourceLimits?,
|
|
35
|
-
|
|
34
|
+
# @rbs (Class parser_class, SourceText source_text, ?resource_limits: ResourceLimits?,
|
|
35
|
+
# ?blender: bool, ?event_observer: Proc?) -> void
|
|
36
|
+
def initialize: (Class parser_class, SourceText source_text, ?resource_limits: ResourceLimits?, ?blender: bool, ?event_observer: Proc?) -> void
|
|
36
37
|
|
|
37
38
|
# Apply edits expressed against the current source and return syntax only.
|
|
38
39
|
# @rbs (Array[TextEdit] edits) -> SyntaxResult
|
|
@@ -45,6 +46,11 @@ module Ibex
|
|
|
45
46
|
# @rbs (Observation::Subscription subscription) -> bool
|
|
46
47
|
def unobserve: (Observation::Subscription subscription) -> bool
|
|
47
48
|
|
|
49
|
+
# Whether the last completed edit discarded all incremental reuse and
|
|
50
|
+
# reparsed the current source from a fresh token stream.
|
|
51
|
+
# @rbs () -> bool
|
|
52
|
+
def last_full_fallback?: () -> bool
|
|
53
|
+
|
|
48
54
|
private
|
|
49
55
|
|
|
50
56
|
# @rbs (Array[TextEdit] edits) -> SyntaxResult
|
|
@@ -5,31 +5,31 @@ module Ibex
|
|
|
5
5
|
module CST
|
|
6
6
|
# Immutable result returned by syntax-aware parser entry points.
|
|
7
7
|
class ParseResult
|
|
8
|
-
attr_reader value:
|
|
8
|
+
attr_reader value: Object
|
|
9
9
|
|
|
10
10
|
attr_reader syntax_root: SyntaxNode
|
|
11
11
|
|
|
12
|
-
attr_reader diagnostics: Array[
|
|
12
|
+
attr_reader diagnostics: Array[Object]
|
|
13
13
|
|
|
14
|
-
# @rbs (value:
|
|
15
|
-
def initialize: (value:
|
|
14
|
+
# @rbs (value: Object, syntax_root: SyntaxNode, diagnostics: Array[Object]) -> void
|
|
15
|
+
def initialize: (value: Object, syntax_root: SyntaxNode, diagnostics: Array[Object]) -> void
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
# Syntax-only result used by incremental sessions.
|
|
19
19
|
class SyntaxResult
|
|
20
20
|
attr_reader syntax_root: SyntaxNode
|
|
21
21
|
|
|
22
|
-
attr_reader diagnostics: Array[
|
|
22
|
+
attr_reader diagnostics: Array[Object]
|
|
23
23
|
|
|
24
24
|
attr_reader reused_ratio: Float
|
|
25
25
|
|
|
26
|
-
# @rbs (syntax_root: SyntaxNode, diagnostics: Array[
|
|
27
|
-
def initialize: (syntax_root: SyntaxNode, diagnostics: Array[
|
|
26
|
+
# @rbs (syntax_root: SyntaxNode, diagnostics: Array[Object], reused_ratio: Float) -> void
|
|
27
|
+
def initialize: (syntax_root: SyntaxNode, diagnostics: Array[Object], reused_ratio: Float) -> void
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
ParseResult:
|
|
31
|
+
ParseResult: singleton(CST::ParseResult)
|
|
32
32
|
|
|
33
|
-
SyntaxResult:
|
|
33
|
+
SyntaxResult: singleton(CST::SyntaxResult)
|
|
34
34
|
end
|
|
35
35
|
end
|
|
@@ -8,6 +8,8 @@ module Ibex
|
|
|
8
8
|
|
|
9
9
|
# Stable JSON serialization for `ibex_cst` schema version 1.
|
|
10
10
|
module Serialize
|
|
11
|
+
type json_value = String | Integer | bool | nil | Array[json_value] | Hash[String, json_value]
|
|
12
|
+
|
|
11
13
|
SCHEMA_VERSION: Integer
|
|
12
14
|
|
|
13
15
|
# @rbs (SyntaxNode | SerializedTree value, ?grammar_digest: String?, ?table_format: Integer?,
|
|
@@ -22,14 +24,14 @@ module Ibex
|
|
|
22
24
|
# state_count: Integer?, production_count: Integer?, memo: ParseMemo?) -> SerializedTree
|
|
23
25
|
def self?.serialization_tree: (SyntaxNode | SerializedTree value, grammar_digest: String?, table_format: Integer?, state_count: Integer?, production_count: Integer?, memo: ParseMemo?) -> SerializedTree
|
|
24
26
|
|
|
25
|
-
# @rbs (Kind kinds) -> Hash[String,
|
|
26
|
-
def self?.kinds_document: (Kind kinds) -> Hash[String,
|
|
27
|
+
# @rbs (Kind kinds) -> Hash[String, json_value]
|
|
28
|
+
def self?.kinds_document: (Kind kinds) -> Hash[String, json_value]
|
|
27
29
|
|
|
28
|
-
# @rbs (GreenNode | GreenToken element) -> Hash[String,
|
|
29
|
-
def self?.element_document: (GreenNode | GreenToken element) -> Hash[String,
|
|
30
|
+
# @rbs (GreenNode | GreenToken element) -> Hash[String, json_value]
|
|
31
|
+
def self?.element_document: (GreenNode | GreenToken element) -> Hash[String, json_value]
|
|
30
32
|
|
|
31
|
-
# @rbs (GreenTrivia trivia) -> Array[
|
|
32
|
-
def self?.trivia_document: (GreenTrivia trivia) -> Array[
|
|
33
|
+
# @rbs (GreenTrivia trivia) -> Array[json_value]
|
|
34
|
+
def self?.trivia_document: (GreenTrivia trivia) -> Array[json_value]
|
|
33
35
|
|
|
34
36
|
# @rbs (String text) -> (String | Hash[String, String])
|
|
35
37
|
def self?.encode_text: (String text) -> (String | Hash[String, String])
|
|
@@ -155,17 +155,17 @@ module Ibex
|
|
|
155
155
|
# @rbs (SyntaxNode other) -> bool
|
|
156
156
|
def same_node?: (SyntaxNode other) -> bool
|
|
157
157
|
|
|
158
|
-
# @rbs (
|
|
159
|
-
def ==: (
|
|
158
|
+
# @rbs (Object? other) -> bool
|
|
159
|
+
def ==: (Object? other) -> bool
|
|
160
160
|
|
|
161
161
|
# @rbs () -> Array[element]
|
|
162
162
|
def deconstruct: () -> Array[element]
|
|
163
163
|
|
|
164
|
-
# @rbs (Array[Symbol]?) -> Hash[Symbol,
|
|
165
|
-
def deconstruct_keys: (Array[Symbol]?) -> Hash[Symbol,
|
|
164
|
+
# @rbs (Array[Symbol]?) -> Hash[Symbol, Object?]
|
|
165
|
+
def deconstruct_keys: (Array[Symbol]?) -> Hash[Symbol, Object?]
|
|
166
166
|
|
|
167
|
-
# @rbs () -> Hash[Symbol,
|
|
168
|
-
def to_h: () -> Hash[Symbol,
|
|
167
|
+
# @rbs () -> Hash[Symbol, Object?]
|
|
168
|
+
def to_h: () -> Hash[Symbol, Object?]
|
|
169
169
|
|
|
170
170
|
# @rbs (Integer source_offset) -> element?
|
|
171
171
|
def child_covering_offset: (Integer source_offset) -> element?
|
|
@@ -40,8 +40,8 @@ module Ibex
|
|
|
40
40
|
# @rbs () -> Array[GreenTrivia]
|
|
41
41
|
def leading_trivia: () -> Array[GreenTrivia]
|
|
42
42
|
|
|
43
|
-
# @rbs () -> Array[
|
|
44
|
-
def children: () -> Array[
|
|
43
|
+
# @rbs () -> Array[Object?]
|
|
44
|
+
def children: () -> Array[Object?]
|
|
45
45
|
|
|
46
46
|
# @rbs () -> String
|
|
47
47
|
def full_text: () -> String
|
|
@@ -90,17 +90,17 @@ module Ibex
|
|
|
90
90
|
# @rbs (SyntaxToken other) -> bool
|
|
91
91
|
def same_node?: (SyntaxToken other) -> bool
|
|
92
92
|
|
|
93
|
-
# @rbs (
|
|
94
|
-
def ==: (
|
|
93
|
+
# @rbs (Object? other) -> bool
|
|
94
|
+
def ==: (Object? other) -> bool
|
|
95
95
|
|
|
96
|
-
# @rbs () -> Array[
|
|
97
|
-
def deconstruct: () -> Array[
|
|
96
|
+
# @rbs () -> Array[Object?]
|
|
97
|
+
def deconstruct: () -> Array[Object?]
|
|
98
98
|
|
|
99
|
-
# @rbs (Array[Symbol]?) -> Hash[Symbol,
|
|
100
|
-
def deconstruct_keys: (Array[Symbol]?) -> Hash[Symbol,
|
|
99
|
+
# @rbs (Array[Symbol]?) -> Hash[Symbol, Object?]
|
|
100
|
+
def deconstruct_keys: (Array[Symbol]?) -> Hash[Symbol, Object?]
|
|
101
101
|
|
|
102
|
-
# @rbs () -> Hash[Symbol,
|
|
103
|
-
def to_h: () -> Hash[Symbol,
|
|
102
|
+
# @rbs () -> Hash[Symbol, Object?]
|
|
103
|
+
def to_h: () -> Hash[Symbol, Object?]
|
|
104
104
|
|
|
105
105
|
private
|
|
106
106
|
|
|
@@ -30,8 +30,8 @@ module Ibex
|
|
|
30
30
|
# @rbs () -> Array[element]
|
|
31
31
|
def deconstruct: () -> Array[element]
|
|
32
32
|
|
|
33
|
-
# @rbs (Array[Symbol]?) -> Hash[Symbol,
|
|
34
|
-
def deconstruct_keys: (Array[Symbol]?) -> Hash[Symbol,
|
|
33
|
+
# @rbs (Array[Symbol]?) -> Hash[Symbol, Object?]
|
|
34
|
+
def deconstruct_keys: (Array[Symbol]?) -> Hash[Symbol, Object?]
|
|
35
35
|
|
|
36
36
|
# @rbs () -> String
|
|
37
37
|
def to_source: () -> String
|
|
@@ -3,18 +3,22 @@
|
|
|
3
3
|
module Ibex
|
|
4
4
|
module Runtime
|
|
5
5
|
module CST
|
|
6
|
+
type json_value = String | Integer | Float | bool | nil | Array[json_value] | Hash[String, json_value]
|
|
7
|
+
|
|
8
|
+
type json_object = Hash[String, json_value]
|
|
9
|
+
|
|
6
10
|
# Structured failure raised for an invalid or incompatible CST document.
|
|
7
11
|
class ValidationError < StandardError
|
|
8
12
|
attr_reader code: Symbol
|
|
9
13
|
|
|
10
14
|
attr_reader path: String
|
|
11
15
|
|
|
12
|
-
attr_reader expected:
|
|
16
|
+
attr_reader expected: json_value
|
|
13
17
|
|
|
14
|
-
attr_reader actual:
|
|
18
|
+
attr_reader actual: json_value
|
|
15
19
|
|
|
16
|
-
# @rbs (code: Symbol, path: String, message: String, ?expected:
|
|
17
|
-
def initialize: (code: Symbol, path: String, message: String, ?expected:
|
|
20
|
+
# @rbs (code: Symbol, path: String, message: String, ?expected: json_value, ?actual: json_value) -> void
|
|
21
|
+
def initialize: (code: Symbol, path: String, message: String, ?expected: json_value, ?actual: json_value) -> void
|
|
18
22
|
end
|
|
19
23
|
|
|
20
24
|
# Validates schema-v1 CST documents while rebuilding all derived Green data.
|
|
@@ -30,27 +34,27 @@ module Ibex
|
|
|
30
34
|
# ?production_count: Integer?) -> SerializedTree
|
|
31
35
|
def self?.validate: (String source, ?grammar_digest: String?, ?state_count: Integer?, ?production_count: Integer?) -> SerializedTree
|
|
32
36
|
|
|
33
|
-
# @rbs (
|
|
34
|
-
def self?.load_kinds: (
|
|
37
|
+
# @rbs (json_value value) -> Kind
|
|
38
|
+
def self?.load_kinds: (json_value value) -> Kind
|
|
35
39
|
|
|
36
|
-
# @rbs (
|
|
40
|
+
# @rbs (json_value value, GreenNode root, String digest, Integer state_count, Integer production_count,
|
|
37
41
|
# expected_state_count: Integer?, expected_production_count: Integer?) -> ParseMemo?
|
|
38
|
-
def self?.load_memo: (
|
|
42
|
+
def self?.load_memo: (json_value value, GreenNode root, String digest, Integer state_count, Integer production_count, expected_state_count: Integer?, expected_production_count: Integer?) -> ParseMemo?
|
|
39
43
|
|
|
40
|
-
# @rbs (
|
|
41
|
-
def self?.load_memo_states: (
|
|
44
|
+
# @rbs (json_value value, Integer state_count) -> Array[Integer?]
|
|
45
|
+
def self?.load_memo_states: (json_value value, Integer state_count) -> Array[Integer?]
|
|
42
46
|
|
|
43
47
|
# @rbs (Array[Integer?] states, GreenNode root) -> void
|
|
44
48
|
def self?.validate_memo_length!: (Array[Integer?] states, GreenNode root) -> void
|
|
45
49
|
|
|
46
|
-
# @rbs (
|
|
47
|
-
def self?.load_element: (
|
|
50
|
+
# @rbs (json_value value, Kind kinds, String path) -> (GreenNode | GreenToken)
|
|
51
|
+
def self?.load_element: (json_value value, Kind kinds, String path) -> (GreenNode | GreenToken)
|
|
48
52
|
|
|
49
|
-
# @rbs (
|
|
50
|
-
def self?.load_trivia: (
|
|
53
|
+
# @rbs (json_value value, Kind kinds, String path) -> Array[GreenTrivia]
|
|
54
|
+
def self?.load_trivia: (json_value value, Kind kinds, String path) -> Array[GreenTrivia]
|
|
51
55
|
|
|
52
|
-
# @rbs (
|
|
53
|
-
def self?.decode_text: (
|
|
56
|
+
# @rbs (json_value value, String path) -> String
|
|
57
|
+
def self?.decode_text: (json_value value, String path) -> String
|
|
54
58
|
|
|
55
59
|
# @rbs (GreenNode | GreenToken element, String path) -> void
|
|
56
60
|
def self?.validate_derived!: (GreenNode | GreenToken element, String path) -> void
|
|
@@ -58,35 +62,35 @@ module Ibex
|
|
|
58
62
|
# @rbs (Integer kind, Kind kinds, String path) -> void
|
|
59
63
|
def self?.validate_kind!: (Integer kind, Kind kinds, String path) -> void
|
|
60
64
|
|
|
61
|
-
# @rbs (
|
|
62
|
-
def self?.object!: (
|
|
65
|
+
# @rbs (json_value value, String path) -> json_object
|
|
66
|
+
def self?.object!: (json_value value, String path) -> json_object
|
|
63
67
|
|
|
64
|
-
# @rbs (
|
|
65
|
-
def self?.array!: (
|
|
68
|
+
# @rbs (json_value value, String path) -> Array[json_value]
|
|
69
|
+
def self?.array!: (json_value value, String path) -> Array[json_value]
|
|
66
70
|
|
|
67
|
-
# @rbs (
|
|
68
|
-
def self?.string!: (
|
|
71
|
+
# @rbs (json_value value, String path) -> String
|
|
72
|
+
def self?.string!: (json_value value, String path) -> String
|
|
69
73
|
|
|
70
|
-
# @rbs (
|
|
71
|
-
def self?.nonnegative_integer!: (
|
|
74
|
+
# @rbs (json_value value, String path) -> Integer
|
|
75
|
+
def self?.nonnegative_integer!: (json_value value, String path) -> Integer
|
|
72
76
|
|
|
73
|
-
# @rbs (
|
|
74
|
-
def self?.positive_integer!: (
|
|
77
|
+
# @rbs (json_value value, String path) -> Integer
|
|
78
|
+
def self?.positive_integer!: (json_value value, String path) -> Integer
|
|
75
79
|
|
|
76
|
-
# @rbs (
|
|
77
|
-
def self?.trivia_policy!: (
|
|
80
|
+
# @rbs (json_value value, String path) -> Symbol
|
|
81
|
+
def self?.trivia_policy!: (json_value value, String path) -> Symbol
|
|
78
82
|
|
|
79
|
-
# @rbs (
|
|
80
|
-
def self?.flags!: (
|
|
83
|
+
# @rbs (json_value value, String path) -> Integer
|
|
84
|
+
def self?.flags!: (json_value value, String path) -> Integer
|
|
81
85
|
|
|
82
|
-
# @rbs (
|
|
83
|
-
def self?.integer_pair!: (
|
|
86
|
+
# @rbs (json_value value, String path) -> Array[Integer]
|
|
87
|
+
def self?.integer_pair!: (json_value value, String path) -> Array[Integer]
|
|
84
88
|
|
|
85
|
-
# @rbs (
|
|
86
|
-
def self?.string_integer_map!: (
|
|
89
|
+
# @rbs (json_value value, String path) -> Hash[String, Integer]
|
|
90
|
+
def self?.string_integer_map!: (json_value value, String path) -> Hash[String, Integer]
|
|
87
91
|
|
|
88
|
-
# @rbs (
|
|
89
|
-
def self?.integer_integer_map!: (
|
|
92
|
+
# @rbs (json_value value, String path) -> Hash[Integer, Integer]
|
|
93
|
+
def self?.integer_integer_map!: (json_value value, String path) -> Hash[Integer, Integer]
|
|
90
94
|
|
|
91
95
|
# @rbs (Kind::metadata metadata) -> void
|
|
92
96
|
def self?.validate_kind_metadata!: (Kind::metadata metadata) -> void
|
|
@@ -94,14 +98,14 @@ module Ibex
|
|
|
94
98
|
# @rbs (Array[Integer] range, Integer limit, String path) -> void
|
|
95
99
|
def self?.validate_kind_range!: (Array[Integer] range, Integer limit, String path) -> void
|
|
96
100
|
|
|
97
|
-
# @rbs (
|
|
98
|
-
def self?.exact_keys!: (
|
|
101
|
+
# @rbs (json_object value, Array[String] expected, String path) -> void
|
|
102
|
+
def self?.exact_keys!: (json_object value, Array[String] expected, String path) -> void
|
|
99
103
|
|
|
100
|
-
# @rbs (
|
|
101
|
-
def self?.value!: (
|
|
104
|
+
# @rbs (json_object value, String key, json_value expected, String path) -> void
|
|
105
|
+
def self?.value!: (json_object value, String key, json_value expected, String path) -> void
|
|
102
106
|
|
|
103
|
-
# @rbs (Symbol code, String path, String message, ?expected:
|
|
104
|
-
def self?.fail_validation: (Symbol code, String path, String message, ?expected:
|
|
107
|
+
# @rbs (Symbol code, String path, String message, ?expected: json_value, ?actual: json_value) -> bot
|
|
108
|
+
def self?.fail_validation: (Symbol code, String path, String message, ?expected: json_value, ?actual: json_value) -> bot
|
|
105
109
|
end
|
|
106
110
|
end
|
|
107
111
|
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Generated from lib/ibex/runtime/embedded_source.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Ibex
|
|
4
|
+
module Runtime
|
|
5
|
+
# Assembles the installed runtime into one dependency-free Ruby source.
|
|
6
|
+
module EmbeddedSource
|
|
7
|
+
FILES: Array[String]
|
|
8
|
+
|
|
9
|
+
REQUIRE_RELATIVE: ::Regexp
|
|
10
|
+
|
|
11
|
+
# @rbs () -> String
|
|
12
|
+
def self.render: () -> String
|
|
13
|
+
|
|
14
|
+
# @rbs (Array[String] paths) -> void
|
|
15
|
+
def self.validate_manifest!: (Array[String] paths) -> void
|
|
16
|
+
|
|
17
|
+
# @rbs (String path) -> String
|
|
18
|
+
def self.source: (String path) -> String
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
data/sig/ibex/runtime/event.rbs
CHANGED
|
@@ -4,6 +4,8 @@ module Ibex
|
|
|
4
4
|
module Runtime
|
|
5
5
|
# One immutable versioned parser observation.
|
|
6
6
|
class Event
|
|
7
|
+
type json_value = String | Integer | Float | bool | nil | Array[json_value] | Hash[String, json_value]
|
|
8
|
+
|
|
7
9
|
SCHEMA_VERSION: Integer
|
|
8
10
|
|
|
9
11
|
IDENTIFIER: String
|
|
@@ -14,13 +16,13 @@ module Ibex
|
|
|
14
16
|
|
|
15
17
|
attr_reader sequence: Integer
|
|
16
18
|
|
|
17
|
-
attr_reader data: Hash[String,
|
|
19
|
+
attr_reader data: Hash[String, json_value]
|
|
18
20
|
|
|
19
|
-
# @rbs (type: Symbol, sequence: Integer, data: Hash[
|
|
20
|
-
def initialize: (type: Symbol, sequence: Integer, data: Hash[
|
|
21
|
+
# @rbs (type: Symbol, sequence: Integer, data: Hash[Object?, Object?]) -> void
|
|
22
|
+
def initialize: (type: Symbol, sequence: Integer, data: Hash[Object?, Object?]) -> void
|
|
21
23
|
|
|
22
|
-
# @rbs () -> Hash[String,
|
|
23
|
-
def to_h: () -> Hash[String,
|
|
24
|
+
# @rbs () -> Hash[String, json_value]
|
|
25
|
+
def to_h: () -> Hash[String, json_value]
|
|
24
26
|
end
|
|
25
27
|
end
|
|
26
28
|
end
|