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.
Files changed (102) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/README.md +337 -0
  4. data/lib/ibex/runtime/ast_data.rb +23 -0
  5. data/lib/ibex/runtime/cst/annotation.rb +16 -0
  6. data/lib/ibex/runtime/cst/cursor.rb +68 -0
  7. data/lib/ibex/runtime/cst/diff.rb +80 -0
  8. data/lib/ibex/runtime/cst/editing.rb +56 -0
  9. data/lib/ibex/runtime/cst/editor.rb +94 -0
  10. data/lib/ibex/runtime/cst/green/builder.rb +211 -0
  11. data/lib/ibex/runtime/cst/green/cache.rb +150 -0
  12. data/lib/ibex/runtime/cst/green/node.rb +78 -0
  13. data/lib/ibex/runtime/cst/green/token.rb +91 -0
  14. data/lib/ibex/runtime/cst/green/trivia.rb +36 -0
  15. data/lib/ibex/runtime/cst/incremental/blender.rb +233 -0
  16. data/lib/ibex/runtime/cst/incremental/lexed_syntax.rb +28 -0
  17. data/lib/ibex/runtime/cst/incremental/parse_memo.rb +95 -0
  18. data/lib/ibex/runtime/cst/incremental/relexer.rb +134 -0
  19. data/lib/ibex/runtime/cst/incremental/session.rb +229 -0
  20. data/lib/ibex/runtime/cst/incremental/token_memo.rb +66 -0
  21. data/lib/ibex/runtime/cst/kind.rb +133 -0
  22. data/lib/ibex/runtime/cst/parse_result.rb +41 -0
  23. data/lib/ibex/runtime/cst/rewriter.rb +75 -0
  24. data/lib/ibex/runtime/cst/serialize.rb +127 -0
  25. data/lib/ibex/runtime/cst/serialized_tree.rb +44 -0
  26. data/lib/ibex/runtime/cst/source_text.rb +112 -0
  27. data/lib/ibex/runtime/cst/syntax_node.rb +432 -0
  28. data/lib/ibex/runtime/cst/syntax_token.rb +160 -0
  29. data/lib/ibex/runtime/cst/text_edit.rb +77 -0
  30. data/lib/ibex/runtime/cst/typed_node.rb +87 -0
  31. data/lib/ibex/runtime/cst/validator.rb +428 -0
  32. data/lib/ibex/runtime/cst.rb +38 -0
  33. data/lib/ibex/runtime/event.rb +44 -0
  34. data/lib/ibex/runtime/event_jsonl_tracer.rb +37 -0
  35. data/lib/ibex/runtime/event_sanitizer.rb +273 -0
  36. data/lib/ibex/runtime/generated_lexer.rb +514 -0
  37. data/lib/ibex/runtime/jsonl_tracer.rb +75 -0
  38. data/lib/ibex/runtime/lexer_input.rb +107 -0
  39. data/lib/ibex/runtime/location_span.rb +114 -0
  40. data/lib/ibex/runtime/observation.rb +82 -0
  41. data/lib/ibex/runtime/parser.rb +3027 -0
  42. data/lib/ibex/runtime/parser_sync_recovery.rb +108 -0
  43. data/lib/ibex/runtime/repair.rb +126 -0
  44. data/lib/ibex/runtime/repair_priority_queue.rb +60 -0
  45. data/lib/ibex/runtime/repair_search.rb +318 -0
  46. data/lib/ibex/runtime/resource_limits.rb +64 -0
  47. data/lib/ibex/runtime/table_format.rb +11 -0
  48. data/lib/ibex/runtime/version.rb +7 -0
  49. data/lib/ibex/runtime.rb +27 -0
  50. data/lib/ibex/tables/compact.rb +186 -0
  51. data/lib/ibex/tables/compact_actions.rb +135 -0
  52. data/lib/ibex/tables/compact_productions.rb +167 -0
  53. data/sig/ibex/runtime/ast_data.rbs +12 -0
  54. data/sig/ibex/runtime/cst/annotation.rbs +13 -0
  55. data/sig/ibex/runtime/cst/cursor.rbs +34 -0
  56. data/sig/ibex/runtime/cst/diff.rbs +29 -0
  57. data/sig/ibex/runtime/cst/editing.rbs +23 -0
  58. data/sig/ibex/runtime/cst/editor.rbs +43 -0
  59. data/sig/ibex/runtime/cst/green/builder.rbs +84 -0
  60. data/sig/ibex/runtime/cst/green/cache.rbs +60 -0
  61. data/sig/ibex/runtime/cst/green/node.rbs +49 -0
  62. data/sig/ibex/runtime/cst/green/token.rbs +59 -0
  63. data/sig/ibex/runtime/cst/green/trivia.rbs +29 -0
  64. data/sig/ibex/runtime/cst/incremental/blender.rbs +114 -0
  65. data/sig/ibex/runtime/cst/incremental/lexed_syntax.rbs +20 -0
  66. data/sig/ibex/runtime/cst/incremental/parse_memo.rbs +59 -0
  67. data/sig/ibex/runtime/cst/incremental/relexer.rbs +54 -0
  68. data/sig/ibex/runtime/cst/incremental/session.rbs +89 -0
  69. data/sig/ibex/runtime/cst/incremental/token_memo.rbs +31 -0
  70. data/sig/ibex/runtime/cst/kind.rbs +93 -0
  71. data/sig/ibex/runtime/cst/parse_result.rbs +35 -0
  72. data/sig/ibex/runtime/cst/rewriter.rbs +31 -0
  73. data/sig/ibex/runtime/cst/serialize.rbs +39 -0
  74. data/sig/ibex/runtime/cst/serialized_tree.rbs +34 -0
  75. data/sig/ibex/runtime/cst/source_text.rbs +51 -0
  76. data/sig/ibex/runtime/cst/syntax_node.rbs +195 -0
  77. data/sig/ibex/runtime/cst/syntax_token.rbs +112 -0
  78. data/sig/ibex/runtime/cst/text_edit.rbs +33 -0
  79. data/sig/ibex/runtime/cst/typed_node.rbs +50 -0
  80. data/sig/ibex/runtime/cst/validator.rbs +108 -0
  81. data/sig/ibex/runtime/cst.rbs +9 -0
  82. data/sig/ibex/runtime/event.rbs +26 -0
  83. data/sig/ibex/runtime/event_jsonl_tracer.rbs +25 -0
  84. data/sig/ibex/runtime/event_sanitizer.rbs +92 -0
  85. data/sig/ibex/runtime/generated_lexer.rbs +169 -0
  86. data/sig/ibex/runtime/jsonl_tracer.rbs +42 -0
  87. data/sig/ibex/runtime/lexer_input.rbs +44 -0
  88. data/sig/ibex/runtime/location_span.rbs +64 -0
  89. data/sig/ibex/runtime/observation.rbs +35 -0
  90. data/sig/ibex/runtime/parser.rbs +926 -0
  91. data/sig/ibex/runtime/parser_sync_recovery.rbs +60 -0
  92. data/sig/ibex/runtime/repair.rbs +92 -0
  93. data/sig/ibex/runtime/repair_priority_queue.rbs +27 -0
  94. data/sig/ibex/runtime/repair_search.rbs +114 -0
  95. data/sig/ibex/runtime/resource_limits.rbs +39 -0
  96. data/sig/ibex/runtime/table_format.rbs +11 -0
  97. data/sig/ibex/runtime/version.rbs +7 -0
  98. data/sig/ibex/runtime.rbs +6 -0
  99. data/sig/ibex/tables/compact.rbs +70 -0
  100. data/sig/ibex/tables/compact_actions.rbs +57 -0
  101. data/sig/ibex/tables/compact_productions.rbs +68 -0
  102. metadata +144 -0
@@ -0,0 +1,108 @@
1
+ # Generated from lib/ibex/runtime/cst/validator.rb with RBS::Inline
2
+
3
+ module Ibex
4
+ module Runtime
5
+ module CST
6
+ # Structured failure raised for an invalid or incompatible CST document.
7
+ class ValidationError < StandardError
8
+ attr_reader code: Symbol
9
+
10
+ attr_reader path: String
11
+
12
+ attr_reader expected: untyped
13
+
14
+ attr_reader actual: untyped
15
+
16
+ # @rbs (code: Symbol, path: String, message: String, ?expected: untyped, ?actual: untyped) -> void
17
+ def initialize: (code: Symbol, path: String, message: String, ?expected: untyped, ?actual: untyped) -> void
18
+ end
19
+
20
+ # Validates schema-v1 CST documents while rebuilding all derived Green data.
21
+ module Validator
22
+ # rubocop:disable Metrics/ModuleLength -- closed schema checks remain auditable in one boundary.
23
+ TOP_KEYS: Array[String]
24
+
25
+ KIND_KEYS: Array[String]
26
+
27
+ KNOWN_FLAGS: Integer
28
+
29
+ # @rbs (String source, ?grammar_digest: String?, ?state_count: Integer?,
30
+ # ?production_count: Integer?) -> SerializedTree
31
+ def self?.validate: (String source, ?grammar_digest: String?, ?state_count: Integer?, ?production_count: Integer?) -> SerializedTree
32
+
33
+ # @rbs (untyped value) -> Kind
34
+ def self?.load_kinds: (untyped value) -> Kind
35
+
36
+ # @rbs (untyped value, GreenNode root, String digest, Integer state_count, Integer production_count,
37
+ # expected_state_count: Integer?, expected_production_count: Integer?) -> ParseMemo?
38
+ def self?.load_memo: (untyped value, GreenNode root, String digest, Integer state_count, Integer production_count, expected_state_count: Integer?, expected_production_count: Integer?) -> ParseMemo?
39
+
40
+ # @rbs (untyped value, Integer state_count) -> Array[Integer?]
41
+ def self?.load_memo_states: (untyped value, Integer state_count) -> Array[Integer?]
42
+
43
+ # @rbs (Array[Integer?] states, GreenNode root) -> void
44
+ def self?.validate_memo_length!: (Array[Integer?] states, GreenNode root) -> void
45
+
46
+ # @rbs (untyped value, Kind kinds, String path) -> (GreenNode | GreenToken)
47
+ def self?.load_element: (untyped value, Kind kinds, String path) -> (GreenNode | GreenToken)
48
+
49
+ # @rbs (untyped value, Kind kinds, String path) -> Array[GreenTrivia]
50
+ def self?.load_trivia: (untyped value, Kind kinds, String path) -> Array[GreenTrivia]
51
+
52
+ # @rbs (untyped value, String path) -> String
53
+ def self?.decode_text: (untyped value, String path) -> String
54
+
55
+ # @rbs (GreenNode | GreenToken element, String path) -> void
56
+ def self?.validate_derived!: (GreenNode | GreenToken element, String path) -> void
57
+
58
+ # @rbs (Integer kind, Kind kinds, String path) -> void
59
+ def self?.validate_kind!: (Integer kind, Kind kinds, String path) -> void
60
+
61
+ # @rbs (untyped value, String path) -> Hash[String, untyped]
62
+ def self?.object!: (untyped value, String path) -> Hash[String, untyped]
63
+
64
+ # @rbs (untyped value, String path) -> Array[untyped]
65
+ def self?.array!: (untyped value, String path) -> Array[untyped]
66
+
67
+ # @rbs (untyped value, String path) -> String
68
+ def self?.string!: (untyped value, String path) -> String
69
+
70
+ # @rbs (untyped value, String path) -> Integer
71
+ def self?.nonnegative_integer!: (untyped value, String path) -> Integer
72
+
73
+ # @rbs (untyped value, String path) -> Integer
74
+ def self?.positive_integer!: (untyped value, String path) -> Integer
75
+
76
+ # @rbs (untyped value, String path) -> Symbol
77
+ def self?.trivia_policy!: (untyped value, String path) -> Symbol
78
+
79
+ # @rbs (untyped value, String path) -> Integer
80
+ def self?.flags!: (untyped value, String path) -> Integer
81
+
82
+ # @rbs (untyped value, String path) -> Array[Integer]
83
+ def self?.integer_pair!: (untyped value, String path) -> Array[Integer]
84
+
85
+ # @rbs (untyped value, String path) -> Hash[String, Integer]
86
+ def self?.string_integer_map!: (untyped value, String path) -> Hash[String, Integer]
87
+
88
+ # @rbs (untyped value, String path) -> Hash[Integer, Integer]
89
+ def self?.integer_integer_map!: (untyped value, String path) -> Hash[Integer, Integer]
90
+
91
+ # @rbs (Kind::metadata metadata) -> void
92
+ def self?.validate_kind_metadata!: (Kind::metadata metadata) -> void
93
+
94
+ # @rbs (Array[Integer] range, Integer limit, String path) -> void
95
+ def self?.validate_kind_range!: (Array[Integer] range, Integer limit, String path) -> void
96
+
97
+ # @rbs (Hash[String, untyped] value, Array[String] expected, String path) -> void
98
+ def self?.exact_keys!: (Hash[String, untyped] value, Array[String] expected, String path) -> void
99
+
100
+ # @rbs (Hash[String, untyped] value, String key, untyped expected, String path) -> void
101
+ def self?.value!: (Hash[String, untyped] value, String key, untyped expected, String path) -> void
102
+
103
+ # @rbs (Symbol code, String path, String message, ?expected: untyped, ?actual: untyped) -> bot
104
+ def self?.fail_validation: (Symbol code, String path, String message, ?expected: untyped, ?actual: untyped) -> bot
105
+ end
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,9 @@
1
+ # Generated from lib/ibex/runtime/cst.rb with RBS::Inline
2
+
3
+ module Ibex
4
+ module Runtime
5
+ # Current Red/Green concrete-syntax APIs.
6
+ module CST
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,26 @@
1
+ # Generated from lib/ibex/runtime/event.rb with RBS::Inline
2
+
3
+ module Ibex
4
+ module Runtime
5
+ # One immutable versioned parser observation.
6
+ class Event
7
+ SCHEMA_VERSION: Integer
8
+
9
+ IDENTIFIER: String
10
+
11
+ TYPES: Array[Symbol]
12
+
13
+ attr_reader type: Symbol
14
+
15
+ attr_reader sequence: Integer
16
+
17
+ attr_reader data: Hash[String, untyped]
18
+
19
+ # @rbs (type: Symbol, sequence: Integer, data: Hash[untyped, untyped]) -> void
20
+ def initialize: (type: Symbol, sequence: Integer, data: Hash[untyped, untyped]) -> void
21
+
22
+ # @rbs () -> Hash[String, untyped]
23
+ def to_h: () -> Hash[String, untyped]
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,25 @@
1
+ # Generated from lib/ibex/runtime/event_jsonl_tracer.rb with RBS::Inline
2
+
3
+ module Ibex
4
+ module Runtime
5
+ # Emits schema-v1 immutable runtime events as JSON Lines.
6
+ class EventJSONLTracer
7
+ interface _EventTraceOutput
8
+ def puts: (String) -> untyped
9
+ end
10
+
11
+ attr_reader parser: Parser
12
+
13
+ attr_reader subscription: Observation::Subscription
14
+
15
+ # @rbs (Parser parser, _EventTraceOutput output) -> void
16
+ def initialize: (Parser parser, _EventTraceOutput output) -> void
17
+
18
+ # @rbs () -> bool
19
+ def detach: () -> bool
20
+
21
+ # @rbs [P < Parser] (P parser, io: _EventTraceOutput) -> EventJSONLTracer
22
+ def self.attach: [P < Parser] (P parser, io: _EventTraceOutput) -> EventJSONLTracer
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,92 @@
1
+ # Generated from lib/ibex/runtime/event_sanitizer.rb with RBS::Inline
2
+
3
+ module Ibex
4
+ module Runtime
5
+ # Converts application-owned values into bounded, data-only event summaries.
6
+ # rubocop:disable Metrics/ModuleLength
7
+ module EventSanitizer
8
+ MAX_DEPTH: Integer
9
+
10
+ MAX_COLLECTION_ENTRIES: Integer
11
+
12
+ MAX_STRING_BYTES: Integer
13
+
14
+ MAX_INTEGER_BITS: Integer
15
+
16
+ STRING_INPUT_BYTES: Integer
17
+
18
+ DATA_MAX_DEPTH: Integer
19
+
20
+ # Copy a runtime payload into deeply frozen JSON data. Unknown objects are
21
+ # summarized instead of being retained, so callers cannot smuggle mutable
22
+ # application identities into an Event.
23
+ # @rbs (Hash[untyped, untyped] input) -> Hash[String, untyped]
24
+ def self.data: (Hash[untyped, untyped] input) -> Hash[String, untyped]
25
+
26
+ # @rbs (untyped input) -> untyped
27
+ def self.value: (untyped input) -> untyped
28
+
29
+ # @rbs (untyped location) -> Hash[String, untyped]?
30
+ def self.location: (untyped location) -> Hash[String, untyped]?
31
+
32
+ # @rbs (untyped input) -> String
33
+ def self.string: (untyped input) -> String
34
+
35
+ # @rbs (untyped input) -> String
36
+ def self.class_name: (untyped input) -> String
37
+
38
+ # @rbs (untyped input, depth: Integer, seen: Hash[Integer, bool]) -> untyped
39
+ private def self.summarize: (untyped input, depth: Integer, seen: Hash[Integer, bool]) -> untyped
40
+
41
+ # @rbs (untyped input, depth: Integer, seen: Hash[Integer, bool]) -> untyped
42
+ private def self.json_data: (untyped input, depth: Integer, seen: Hash[Integer, bool]) -> untyped
43
+
44
+ # @rbs (Array[untyped] input, depth: Integer, seen: Hash[Integer, bool]) -> untyped
45
+ private def self.summarize_array: (Array[untyped] input, depth: Integer, seen: Hash[Integer, bool]) -> untyped
46
+
47
+ # @rbs (Hash[untyped, untyped] input, depth: Integer, seen: Hash[Integer, bool]) -> untyped
48
+ private def self.summarize_hash: (Hash[untyped, untyped] input, depth: Integer, seen: Hash[Integer, bool]) -> untyped
49
+
50
+ # @rbs (Array[untyped] input, depth: Integer, seen: Hash[Integer, bool]) -> untyped
51
+ private def self.json_array: (Array[untyped] input, depth: Integer, seen: Hash[Integer, bool]) -> untyped
52
+
53
+ # @rbs (Hash[untyped, untyped] input, depth: Integer, seen: Hash[Integer, bool]) -> untyped
54
+ private def self.json_hash: (Hash[untyped, untyped] input, depth: Integer, seen: Hash[Integer, bool]) -> untyped
55
+
56
+ # @rbs (Array[untyped] input, seen: Hash[Integer, bool])
57
+ # { (untyped, Hash[Integer, bool]) -> untyped } -> untyped
58
+ private def self.copy_array: (Array[untyped] input, seen: Hash[Integer, bool]) { (untyped, Hash[Integer, bool]) -> untyped } -> untyped
59
+
60
+ # @rbs (untyped input) -> bool
61
+ private def self.primitive?: (untyped input) -> bool
62
+
63
+ # @rbs (Integer input) -> untyped
64
+ private def self.bounded_integer: (Integer input) -> untyped
65
+
66
+ # @rbs (Float input) -> untyped
67
+ private def self.finite_float: (Float input) -> untyped
68
+
69
+ # @rbs (untyped input, Module type) -> bool
70
+ private def self.core_type?: (untyped input, Module type) -> bool
71
+
72
+ # @rbs (untyped key) -> String
73
+ private def self.data_key: (untyped key) -> String
74
+
75
+ # @rbs (String input) -> String
76
+ private def self.truncate_utf8: (String input) -> String
77
+
78
+ # @rbs (untyped input) -> Integer
79
+ private def self.object_identity: (untyped input) -> Integer
80
+
81
+ # @rbs (untyped location, Symbol field) -> untyped
82
+ private def self.location_field: (untyped location, Symbol field) -> untyped
83
+
84
+ # @rbs (String reason) -> Hash[String, untyped]
85
+ private def self.unavailable: (String reason) -> Hash[String, untyped]
86
+
87
+ # @rbs (Module owner, Symbol method_name, untyped receiver, *untyped args, **untyped keywords)
88
+ # ?{ (*untyped) -> untyped } -> untyped
89
+ private def self.core_call: (Module owner, Symbol method_name, untyped receiver, *untyped args, **untyped keywords) ?{ (*untyped) -> untyped } -> untyped
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,169 @@
1
+ # Generated from lib/ibex/runtime/generated_lexer.rb with RBS::Inline
2
+
3
+ module Ibex
4
+ module Runtime
5
+ # Runtime contract mixed into parser classes that declare a lexer.
6
+ # rubocop:disable Metrics/ModuleLength -- matching, actions, state, and positions share one session invariant.
7
+ # @rbs module-self Parser
8
+ module GeneratedLexer : Parser
9
+ NO_EMISSION: Object
10
+
11
+ # @type var empty_green_trivia: Array[CST::GreenTrivia]
12
+ EMPTY_GREEN_TRIVIA: Array[CST::GreenTrivia]
13
+
14
+ @lexer_has_token: bool
15
+
16
+ @lexer_cst_trivia_kinds: Hash[String, Integer]?
17
+
18
+ @lexer_cst_trivia_policy: Symbol
19
+
20
+ @lexer_pending_green_trivia: Array[CST::GreenTrivia]
21
+
22
+ @lexer_skip_requested: bool
23
+
24
+ @lexer_emission: Object | Array[untyped]
25
+
26
+ @lexer_lexeme: String?
27
+
28
+ @lexer_byte_offset: Integer
29
+
30
+ @lexer_byte_column: Integer
31
+
32
+ @lexer_column: Integer
33
+
34
+ @lexer_line: Integer
35
+
36
+ @lexer_states: Array[String]
37
+
38
+ @lexer_file: String
39
+
40
+ @lexer_input: LexerInput?
41
+
42
+ # Reset the generated lexer to the beginning of an input.
43
+ # @rbs (String | IO | Fiber source, ?file: String) -> self
44
+ def lex: (String | IO | Fiber source, ?file: String) -> self
45
+
46
+ # Lex and parse one String, IO, or Fiber source.
47
+ # @rbs (String | IO | Fiber source, ?file: String) -> untyped
48
+ def parse: (String | IO | Fiber source, ?file: String) -> untyped
49
+
50
+ # Parse one generated-lexer source and return its semantic and syntax results.
51
+ # @rbs (String | IO | Fiber source, ?file: String) -> CST::ParseResult
52
+ def parse_with_syntax: (String | IO | Fiber source, ?file: String) -> CST::ParseResult
53
+
54
+ # Parse without executing parser production actions.
55
+ # Lexer actions still run because they define tokenization and lexer state.
56
+ # @rbs (String source, ?file: String) -> CST::SyntaxResult
57
+ def parse_syntax: (String source, ?file: String) -> CST::SyntaxResult
58
+
59
+ # Return the current named lexer state.
60
+ # @rbs () -> Symbol
61
+ def lexer_state: () -> Symbol
62
+
63
+ # Replace the current named lexer state.
64
+ # @rbs (Symbol | String state) -> Symbol
65
+ def lexer_state=: (Symbol | String state) -> Symbol
66
+
67
+ # Pull one token using longest match and declaration-order tie breaking.
68
+ # @rbs () -> [untyped, untyped, Hash[Symbol, untyped]]
69
+ def next_token: () -> [ untyped, untyped, Hash[Symbol, untyped] ]
70
+
71
+ private
72
+
73
+ # @rbs (CST::SourceText source_text, CST::NodeCache cache) -> CST::SyntaxResult
74
+ def parse_syntax_with_cache: (CST::SourceText source_text, CST::NodeCache cache) -> CST::SyntaxResult
75
+
76
+ # Run the generated lexer once and materialize its exact Green token stream.
77
+ # @rbs (CST::SourceText source_text, CST::NodeCache cache) -> CST::LexedSyntax
78
+ def scan_syntax_with_cache: (CST::SourceText source_text, CST::NodeCache cache) -> CST::LexedSyntax
79
+
80
+ # @rbs (Integer token_id, untyped value, untyped location, CST::NodeCache cache) -> CST::GreenToken
81
+ def scanned_green_token: (Integer token_id, untyped value, untyped location, CST::NodeCache cache) -> CST::GreenToken
82
+
83
+ # @rbs (Array[CST::GreenToken] tokens, untyped location, CST::NodeCache cache) -> void
84
+ def replace_previous_scanned_trailing: (Array[CST::GreenToken] tokens, untyped location, CST::NodeCache cache) -> void
85
+
86
+ # @rbs (untyped location, Symbol key) -> Array[CST::GreenTrivia]
87
+ def scanned_green_trivia: (untyped location, Symbol key) -> Array[CST::GreenTrivia]
88
+
89
+ # @rbs (LexerInput input) -> bool
90
+ def ensure_lexer_data?: (LexerInput input) -> bool
91
+
92
+ # @rbs (LexerInput input) -> [Hash[Symbol, untyped]?, String?]
93
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
94
+ def select_lexer_match: (LexerInput input) -> [ Hash[Symbol, untyped]?, String? ]
95
+
96
+ # @rbs () -> Array[Hash[Symbol, untyped]]
97
+ def lexer_rules: () -> Array[Hash[Symbol, untyped]]
98
+
99
+ # @rbs (LexerInput input) -> bot
100
+ def raise_lexer_no_match: (LexerInput input) -> bot
101
+
102
+ # @rbs (LexerInput input, String lexeme) -> Hash[Symbol, untyped]
103
+ def consume_lexer_match: (LexerInput input, String lexeme) -> Hash[Symbol, untyped]
104
+
105
+ # @rbs (Hash[Symbol, untyped] rule, String lexeme, Hash[Symbol, untyped] location) ->
106
+ # [untyped, untyped, Hash[Symbol, untyped]]?
107
+ def apply_lexer_rule: (Hash[Symbol, untyped] rule, String lexeme, Hash[Symbol, untyped] location) -> [ untyped, untyped, Hash[Symbol, untyped] ]?
108
+
109
+ # Emit a token from a lexer action.
110
+ # @rbs (untyped token, ?untyped value) -> untyped
111
+ def emit: (untyped token, ?untyped value) -> untyped
112
+
113
+ # Suppress the current match from a lexer action.
114
+ # @rbs () -> nil
115
+ def skip: () -> nil
116
+
117
+ # Return the text consumed by the active lexer action.
118
+ # @rbs () -> String?
119
+ def lexeme: () -> String?
120
+
121
+ # @rbs (String text, Hash[Symbol, untyped] location) -> void
122
+ def retain_cst_trivia: (String text, Hash[Symbol, untyped] location) -> void
123
+
124
+ # @rbs (Hash[Symbol, untyped] location) -> Hash[Symbol, untyped]
125
+ def attach_cst_trivia: (Hash[Symbol, untyped] location) -> Hash[Symbol, untyped]
126
+
127
+ # @rbs () -> Symbol
128
+ def cst_trivia_policy: () -> Symbol
129
+
130
+ # @rbs (String text) -> Integer
131
+ def cst_trivia_kind: (String text) -> Integer
132
+
133
+ # @rbs () -> void
134
+ def configure_lexer_cst: () -> void
135
+
136
+ # @rbs (Array[CST::GreenTrivia] trivia) -> [Array[CST::GreenTrivia], Array[CST::GreenTrivia]]
137
+ def split_balanced_trivia: (Array[CST::GreenTrivia] trivia) -> [ Array[CST::GreenTrivia], Array[CST::GreenTrivia] ]
138
+
139
+ # @rbs () -> CST::SourceText
140
+ def cst_source_text: () -> CST::SourceText
141
+
142
+ # @rbs () -> Array[CST::GreenTrivia]
143
+ def take_cst_pending_green_trivia: () -> Array[CST::GreenTrivia]
144
+
145
+ # @rbs (Array[CST::GreenTrivia] values) -> Array[CST::GreenTrivia]
146
+ def green_trivia_values: (Array[CST::GreenTrivia] values) -> Array[CST::GreenTrivia]
147
+
148
+ # Push a named lexer state.
149
+ # @rbs (Symbol | String state) -> Symbol
150
+ def push_state: (Symbol | String state) -> Symbol
151
+
152
+ # Pop the current named lexer state.
153
+ # @rbs () -> Symbol
154
+ def pop_state: () -> Symbol
155
+
156
+ # @rbs (Symbol | String state) -> String
157
+ def validate_lexer_state: (Symbol | String state) -> String
158
+
159
+ # @rbs () -> Hash[Symbol, Integer]
160
+ def lexer_position: () -> Hash[Symbol, Integer]
161
+
162
+ # @rbs () -> Hash[Symbol, untyped]
163
+ def lexer_zero_width_location: () -> Hash[Symbol, untyped]
164
+
165
+ # @rbs (String lexeme) -> void
166
+ def advance_lexer_position: (String lexeme) -> void
167
+ end
168
+ end
169
+ end
@@ -0,0 +1,42 @@
1
+ # Generated from lib/ibex/runtime/jsonl_tracer.rb with RBS::Inline
2
+
3
+ module Ibex
4
+ module Runtime
5
+ # Emits committed parser observer events as JSON Lines.
6
+ module JSONLTracer
7
+ interface _TraceOutput
8
+ def puts: (String) -> untyped
9
+ end
10
+
11
+ # Hook layer installed on an individual parser's singleton class.
12
+ module Hooks
13
+ def token_to_str: (Integer) -> String
14
+
15
+ @ibex_jsonl_trace_output: _TraceOutput?
16
+
17
+ # @rbs (Integer token_id, untyped value, Integer state) -> void
18
+ def on_shift: (Integer token_id, untyped value, Integer state) -> void
19
+
20
+ # @rbs (Integer production_id, Array[untyped] values, untyped result) -> void
21
+ def on_reduce: (Integer production_id, Array[untyped] values, untyped result) -> void
22
+
23
+ # @rbs (Integer token_id, untyped value, Array[untyped] value_stack) -> void
24
+ def on_error_recover: (Integer token_id, untyped value, Array[untyped] value_stack) -> void
25
+
26
+ private
27
+
28
+ # @rbs (_TraceOutput output) -> void
29
+ def ibex_jsonl_trace_output=: (_TraceOutput output) -> void
30
+
31
+ # @rbs (**untyped event) -> void
32
+ def write_trace: (**untyped event) -> void
33
+
34
+ # @rbs (untyped value) -> String
35
+ def safe_inspect: (untyped value) -> String
36
+ end
37
+
38
+ # @rbs [P < Parser] (P parser, io: _TraceOutput) -> P
39
+ def self.attach: [P < Parser] (P parser, io: _TraceOutput) -> P
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,44 @@
1
+ # Generated from lib/ibex/runtime/lexer_input.rb with RBS::Inline
2
+
3
+ module Ibex
4
+ module Runtime
5
+ # Incremental String, IO, or Fiber input used by generated lexers.
6
+ class LexerInput
7
+ DEFAULT_CHUNK_SIZE: Integer
8
+
9
+ attr_reader buffer: String
10
+
11
+ # @rbs (String | IO | Fiber source, ?chunk_size: Integer) -> void
12
+ def initialize: (String | IO | Fiber source, ?chunk_size: Integer) -> void
13
+
14
+ # @rbs () -> bool
15
+ def eof?: () -> bool
16
+
17
+ # Return every source byte read so far, including the unconsumed buffer.
18
+ # @rbs () -> String
19
+ def source_bytes: () -> String
20
+
21
+ # Read until at least one byte is added or EOF is observed.
22
+ # @rbs () -> bool
23
+ def read_more?: () -> bool
24
+
25
+ # @rbs (String prefix) -> void
26
+ def consume: (String prefix) -> void
27
+
28
+ # Return one source line, reading ahead only to its line boundary.
29
+ # @rbs (Integer line) -> String
30
+ def source_line: (Integer line) -> String
31
+
32
+ private
33
+
34
+ # @rbs () -> void
35
+ def read_chunk: () -> void
36
+
37
+ # @rbs (Fiber source) -> untyped
38
+ def resume_fiber: (Fiber source) -> untyped
39
+
40
+ # @rbs (String chunk) -> void
41
+ def append: (String chunk) -> void
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,64 @@
1
+ # Generated from lib/ibex/runtime/location_span.rb with RBS::Inline
2
+
3
+ module Ibex
4
+ module Runtime
5
+ # The deterministic source span assigned to a reduced nonterminal.
6
+ #
7
+ # Terminal stack entries retain the application-owned location object
8
+ # supplied by the lexer. A reduction wraps the outer boundaries in this
9
+ # immutable value so actions can distinguish synthesized spans.
10
+ class LocationSpan
11
+ attr_reader start: untyped
12
+
13
+ attr_reader finish: untyped
14
+
15
+ # @rbs (start: untyped, finish: untyped, ?empty: bool) -> void
16
+ def initialize: (start: untyped, finish: untyped, ?empty: bool) -> void
17
+
18
+ # Build a span for an LR reduction. Nonempty reductions cover the first
19
+ # through last located RHS entry. Empty reductions are zero-width at the
20
+ # current lookahead location.
21
+ # @rbs (Array[untyped] locations, lookahead: untyped) -> LocationSpan?
22
+ def self.for_reduction: (Array[untyped] locations, lookahead: untyped) -> LocationSpan?
23
+
24
+ # Whether this is the zero-width span of an empty production.
25
+ # @rbs () -> bool
26
+ def empty?: () -> bool
27
+
28
+ # @rbs () -> untyped
29
+ def file: () -> untyped
30
+
31
+ # @rbs () -> untyped
32
+ def line: () -> untyped
33
+
34
+ # @rbs () -> untyped
35
+ def column: () -> untyped
36
+
37
+ # @rbs () -> untyped
38
+ def source_line: () -> untyped
39
+
40
+ # @rbs () -> untyped
41
+ def end_file: () -> untyped
42
+
43
+ # @rbs () -> untyped
44
+ def end_line: () -> untyped
45
+
46
+ # @rbs () -> untyped
47
+ def end_column: () -> untyped
48
+
49
+ # @rbs () -> Hash[Symbol, untyped]
50
+ def to_h: () -> Hash[Symbol, untyped]
51
+
52
+ # @rbs (untyped location) -> untyped
53
+ private def self.boundary_start: (untyped location) -> untyped
54
+
55
+ # @rbs (untyped location) -> untyped
56
+ private def self.boundary_finish: (untyped location) -> untyped
57
+
58
+ private
59
+
60
+ # @rbs (untyped location, Symbol key) -> untyped
61
+ def location_value: (untyped location, Symbol key) -> untyped
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,35 @@
1
+ # Generated from lib/ibex/runtime/observation.rb with RBS::Inline
2
+
3
+ module Ibex
4
+ module Runtime
5
+ # Registration and ordered synchronous dispatch for parser observers.
6
+ module Observation
7
+ # Opaque identity returned by Parser#observe.
8
+ class Subscription
9
+ # @rbs () -> Subscription
10
+ private def self.new: () -> Subscription
11
+
12
+ # @rbs () -> Subscription
13
+ # rubocop:disable Lint/UselessMethodDefinition -- explicit override keeps runtime and generated RBS private.
14
+ private def self.allocate: () -> Subscription
15
+ end
16
+
17
+ # @rbs () { (Event) -> void } -> Subscription
18
+ def observe: () { (Event) -> void } -> Subscription
19
+
20
+ # @rbs (Subscription subscription) -> bool
21
+ def unobserve: (Subscription subscription) -> bool
22
+
23
+ private
24
+
25
+ # @rbs (Symbol type, Hash[untyped, untyped] data, ?observers: Array[Proc]?) -> void
26
+ def emit_runtime_event: (Symbol type, Hash[untyped, untyped] data, ?observers: Array[Proc]?) -> void
27
+
28
+ # @rbs () -> Array[Proc]?
29
+ def runtime_observer_snapshot: () -> Array[Proc]?
30
+
31
+ # @rbs () -> void
32
+ def ensure_observation_thread!: () -> void
33
+ end
34
+ end
35
+ end