ruby-rego 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/.reek.yml +80 -0
- data/.vscode/extensions.json +19 -0
- data/.vscode/launch.json +35 -0
- data/.vscode/settings.json +25 -0
- data/.vscode/tasks.json +117 -0
- data/.yardopts +12 -0
- data/ARCHITECTURE.md +39 -0
- data/CHANGELOG.md +25 -0
- data/CODE_OF_CONDUCT.md +10 -0
- data/LICENSE.txt +21 -0
- data/README.md +183 -0
- data/RELEASING.md +37 -0
- data/Rakefile +38 -0
- data/SECURITY.md +26 -0
- data/Steepfile +10 -0
- data/TODO.md +35 -0
- data/benchmark/builtin_calls.rb +29 -0
- data/benchmark/complex_policy.rb +19 -0
- data/benchmark/comprehensions.rb +19 -0
- data/benchmark/simple_rules.rb +20 -0
- data/examples/README.md +27 -0
- data/examples/sample_config.yaml +2 -0
- data/examples/simple_policy.rego +7 -0
- data/examples/validation_policy.rego +11 -0
- data/exe/rego-validate +6 -0
- data/lib/ruby/rego/ast/base.rb +95 -0
- data/lib/ruby/rego/ast/binary_op.rb +64 -0
- data/lib/ruby/rego/ast/call.rb +27 -0
- data/lib/ruby/rego/ast/composite.rb +48 -0
- data/lib/ruby/rego/ast/comprehension.rb +63 -0
- data/lib/ruby/rego/ast/every.rb +37 -0
- data/lib/ruby/rego/ast/import.rb +32 -0
- data/lib/ruby/rego/ast/literal.rb +70 -0
- data/lib/ruby/rego/ast/module.rb +32 -0
- data/lib/ruby/rego/ast/package.rb +22 -0
- data/lib/ruby/rego/ast/query.rb +63 -0
- data/lib/ruby/rego/ast/reference.rb +58 -0
- data/lib/ruby/rego/ast/rule.rb +114 -0
- data/lib/ruby/rego/ast/unary_op.rb +42 -0
- data/lib/ruby/rego/ast/variable.rb +22 -0
- data/lib/ruby/rego/ast.rb +17 -0
- data/lib/ruby/rego/builtins/aggregates.rb +124 -0
- data/lib/ruby/rego/builtins/base.rb +95 -0
- data/lib/ruby/rego/builtins/collections/array_ops.rb +103 -0
- data/lib/ruby/rego/builtins/collections/object_ops.rb +120 -0
- data/lib/ruby/rego/builtins/collections/set_ops.rb +51 -0
- data/lib/ruby/rego/builtins/collections.rb +137 -0
- data/lib/ruby/rego/builtins/comparisons/casts.rb +139 -0
- data/lib/ruby/rego/builtins/comparisons.rb +84 -0
- data/lib/ruby/rego/builtins/numeric_helpers.rb +56 -0
- data/lib/ruby/rego/builtins/registry.rb +199 -0
- data/lib/ruby/rego/builtins/registry_helpers.rb +27 -0
- data/lib/ruby/rego/builtins/strings/case_ops.rb +22 -0
- data/lib/ruby/rego/builtins/strings/concat.rb +19 -0
- data/lib/ruby/rego/builtins/strings/formatting.rb +35 -0
- data/lib/ruby/rego/builtins/strings/helpers.rb +62 -0
- data/lib/ruby/rego/builtins/strings/number_helpers.rb +48 -0
- data/lib/ruby/rego/builtins/strings/search.rb +63 -0
- data/lib/ruby/rego/builtins/strings/split.rb +19 -0
- data/lib/ruby/rego/builtins/strings/substring.rb +22 -0
- data/lib/ruby/rego/builtins/strings/trim.rb +42 -0
- data/lib/ruby/rego/builtins/strings/trim_helpers.rb +62 -0
- data/lib/ruby/rego/builtins/strings.rb +58 -0
- data/lib/ruby/rego/builtins/types.rb +89 -0
- data/lib/ruby/rego/call_name.rb +55 -0
- data/lib/ruby/rego/cli.rb +1122 -0
- data/lib/ruby/rego/compiled_module.rb +114 -0
- data/lib/ruby/rego/compiler.rb +1097 -0
- data/lib/ruby/rego/environment/overrides.rb +33 -0
- data/lib/ruby/rego/environment/reference_resolution.rb +86 -0
- data/lib/ruby/rego/environment.rb +230 -0
- data/lib/ruby/rego/environment_pool.rb +71 -0
- data/lib/ruby/rego/error_handling.rb +58 -0
- data/lib/ruby/rego/error_payload.rb +34 -0
- data/lib/ruby/rego/errors.rb +196 -0
- data/lib/ruby/rego/evaluator/assignment_support.rb +126 -0
- data/lib/ruby/rego/evaluator/binding_helpers.rb +60 -0
- data/lib/ruby/rego/evaluator/comprehension_evaluator.rb +182 -0
- data/lib/ruby/rego/evaluator/expression_dispatch.rb +45 -0
- data/lib/ruby/rego/evaluator/expression_evaluator.rb +492 -0
- data/lib/ruby/rego/evaluator/object_literal_evaluator.rb +52 -0
- data/lib/ruby/rego/evaluator/operator_evaluator.rb +163 -0
- data/lib/ruby/rego/evaluator/query_node_builder.rb +38 -0
- data/lib/ruby/rego/evaluator/reference_key_resolver.rb +50 -0
- data/lib/ruby/rego/evaluator/reference_resolver.rb +352 -0
- data/lib/ruby/rego/evaluator/rule_evaluator/bindings.rb +70 -0
- data/lib/ruby/rego/evaluator/rule_evaluator.rb +550 -0
- data/lib/ruby/rego/evaluator/rule_value_provider.rb +56 -0
- data/lib/ruby/rego/evaluator/variable_collector.rb +221 -0
- data/lib/ruby/rego/evaluator.rb +174 -0
- data/lib/ruby/rego/lexer/number_reader.rb +68 -0
- data/lib/ruby/rego/lexer/stream.rb +137 -0
- data/lib/ruby/rego/lexer/string_reader.rb +90 -0
- data/lib/ruby/rego/lexer/template_string_reader.rb +62 -0
- data/lib/ruby/rego/lexer.rb +206 -0
- data/lib/ruby/rego/location.rb +73 -0
- data/lib/ruby/rego/memoization.rb +67 -0
- data/lib/ruby/rego/parser/collections.rb +173 -0
- data/lib/ruby/rego/parser/expressions.rb +216 -0
- data/lib/ruby/rego/parser/precedence.rb +42 -0
- data/lib/ruby/rego/parser/query.rb +139 -0
- data/lib/ruby/rego/parser/references.rb +115 -0
- data/lib/ruby/rego/parser/rules.rb +310 -0
- data/lib/ruby/rego/parser.rb +210 -0
- data/lib/ruby/rego/policy.rb +50 -0
- data/lib/ruby/rego/result.rb +91 -0
- data/lib/ruby/rego/token.rb +206 -0
- data/lib/ruby/rego/unifier.rb +451 -0
- data/lib/ruby/rego/value.rb +379 -0
- data/lib/ruby/rego/version.rb +7 -0
- data/lib/ruby/rego/with_modifiers/with_modifier.rb +37 -0
- data/lib/ruby/rego/with_modifiers/with_modifier_applier.rb +48 -0
- data/lib/ruby/rego/with_modifiers/with_modifier_builtin_override.rb +128 -0
- data/lib/ruby/rego/with_modifiers/with_modifier_context.rb +120 -0
- data/lib/ruby/rego/with_modifiers/with_modifier_path_key_resolver.rb +42 -0
- data/lib/ruby/rego/with_modifiers/with_modifier_path_override.rb +99 -0
- data/lib/ruby/rego/with_modifiers/with_modifier_root_scope.rb +58 -0
- data/lib/ruby/rego.rb +72 -0
- data/sig/objspace.rbs +4 -0
- data/sig/psych.rbs +7 -0
- data/sig/rego_validate.rbs +382 -0
- data/sig/ruby/rego.rbs +2150 -0
- metadata +172 -0
data/sig/ruby/rego.rbs
ADDED
|
@@ -0,0 +1,2150 @@
|
|
|
1
|
+
module Ruby
|
|
2
|
+
module Rego
|
|
3
|
+
VERSION: String
|
|
4
|
+
|
|
5
|
+
def self.parse: (String source) -> AST::Module
|
|
6
|
+
def self.compile: (String source) -> CompiledModule
|
|
7
|
+
def self.evaluate: (String source, ?input: untyped, ?data: untyped, ?query: untyped) -> Result
|
|
8
|
+
|
|
9
|
+
type position = {
|
|
10
|
+
line: Integer,
|
|
11
|
+
column: Integer,
|
|
12
|
+
offset: Integer?,
|
|
13
|
+
length: Integer?
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module ErrorFormatting
|
|
17
|
+
def self.format_details: (Hash[Symbol, untyped]) -> String
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
module ErrorHandling
|
|
21
|
+
def self.wrap: (String context) { () -> untyped } -> untyped
|
|
22
|
+
def self.location_from: (untyped error) -> Location?
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def self.build_error: (String context, StandardError error) -> Error
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
module ErrorPayload
|
|
30
|
+
def self.from: (untyped error) -> untyped
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def self.standard_error_payload: (untyped error) -> Hash[Symbol, untyped]
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
class Location
|
|
38
|
+
attr_reader line: Integer
|
|
39
|
+
attr_reader column: Integer
|
|
40
|
+
attr_reader offset: Integer?
|
|
41
|
+
attr_reader length: Integer?
|
|
42
|
+
|
|
43
|
+
def self.from: (Location | position) -> Location
|
|
44
|
+
def initialize: (line: Integer, column: Integer, ?offset: Integer?, ?length: Integer?) -> void
|
|
45
|
+
def to_s: () -> String
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
class Error < StandardError
|
|
49
|
+
attr_reader location: Location?
|
|
50
|
+
|
|
51
|
+
def initialize: (?String message, location: Location?) -> void
|
|
52
|
+
def to_h: () -> Hash[Symbol, untyped]
|
|
53
|
+
|
|
54
|
+
private
|
|
55
|
+
|
|
56
|
+
attr_reader raw_message: String?
|
|
57
|
+
def compose_message: (String? message) -> String
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
class LexerError < Error
|
|
61
|
+
attr_reader line: Integer
|
|
62
|
+
attr_reader column: Integer
|
|
63
|
+
|
|
64
|
+
def initialize: (String message, line: Integer, column: Integer, offset: Integer?, length: Integer?) -> void
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
class ParserError < Error
|
|
68
|
+
attr_reader line: Integer
|
|
69
|
+
attr_reader column: Integer
|
|
70
|
+
attr_reader context: String?
|
|
71
|
+
|
|
72
|
+
def initialize: (String message, location: Location, context: String?) -> void
|
|
73
|
+
def self.from_position: (String message, position: position | Location, context: String?) -> ParserError
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
class CompilationError < Error
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
class EvaluationError < Error
|
|
80
|
+
attr_reader rule: untyped
|
|
81
|
+
|
|
82
|
+
def initialize: (String message, rule: untyped, ?location: Location?) -> void
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
class TypeError < Error
|
|
86
|
+
attr_reader expected: untyped
|
|
87
|
+
attr_reader actual: untyped
|
|
88
|
+
attr_reader context: String?
|
|
89
|
+
|
|
90
|
+
def initialize: (String message, expected: untyped, actual: untyped, context: String?, location: Location?) -> void
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
class BuiltinArgumentError < TypeError
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
class ObjectKeyConflictError < Error
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
class UnificationError < Error
|
|
100
|
+
attr_reader pattern: untyped
|
|
101
|
+
attr_reader value: untyped
|
|
102
|
+
|
|
103
|
+
def initialize: (String message, pattern: untyped, value: untyped, location: Location?) -> void
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
class Value
|
|
107
|
+
TYPE_NAME: String
|
|
108
|
+
|
|
109
|
+
def self.from_ruby: (untyped) -> Value
|
|
110
|
+
def initialize: (?untyped value) -> void
|
|
111
|
+
attr_reader value: untyped
|
|
112
|
+
def truthy?: () -> bool
|
|
113
|
+
def to_ruby: () -> untyped
|
|
114
|
+
def type_name: () -> String
|
|
115
|
+
def undefined?: () -> bool
|
|
116
|
+
def object_key: () -> untyped
|
|
117
|
+
def fetch_reference: (untyped key) -> Value
|
|
118
|
+
def ==: (untyped) -> bool
|
|
119
|
+
def eql?: (untyped) -> bool
|
|
120
|
+
def hash: () -> Integer
|
|
121
|
+
|
|
122
|
+
private
|
|
123
|
+
|
|
124
|
+
def self.build_value: (untyped) -> Value?
|
|
125
|
+
def self.build_simple_value: (untyped) -> Value?
|
|
126
|
+
def self.build_composite_value: (untyped) -> Value?
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
class StringValue < Value
|
|
130
|
+
TYPE_NAME: String
|
|
131
|
+
|
|
132
|
+
def initialize: (String value) -> void
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
class NumberValue < Value
|
|
136
|
+
TYPE_NAME: String
|
|
137
|
+
|
|
138
|
+
def initialize: (Numeric value) -> void
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
class BooleanValue < Value
|
|
142
|
+
TYPE_NAME: String
|
|
143
|
+
|
|
144
|
+
def initialize: (bool value) -> void
|
|
145
|
+
def truthy?: () -> bool
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
class NullValue < Value
|
|
149
|
+
TYPE_NAME: String
|
|
150
|
+
|
|
151
|
+
def initialize: () -> void
|
|
152
|
+
def truthy?: () -> bool
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
class UndefinedValue < Value
|
|
156
|
+
TYPE_NAME: String
|
|
157
|
+
UNDEFINED: untyped
|
|
158
|
+
|
|
159
|
+
def initialize: () -> void
|
|
160
|
+
def truthy?: () -> bool
|
|
161
|
+
def to_ruby: () -> untyped
|
|
162
|
+
def object_key: () -> UndefinedValue
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
class ArrayValue < Value
|
|
166
|
+
TYPE_NAME: String
|
|
167
|
+
|
|
168
|
+
def initialize: (Array[untyped] elements) -> void
|
|
169
|
+
def fetch_index: (Integer index) -> Value
|
|
170
|
+
def fetch_reference: (untyped key) -> Value
|
|
171
|
+
def to_ruby: () -> Array[untyped]
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
class ObjectValue < Value
|
|
175
|
+
TYPE_NAME: String
|
|
176
|
+
|
|
177
|
+
def initialize: (Hash[untyped, untyped] pairs) -> void
|
|
178
|
+
def fetch: (untyped key) -> Value
|
|
179
|
+
def fetch_reference: (untyped key) -> Value
|
|
180
|
+
def to_ruby: () -> Hash[untyped, untyped]
|
|
181
|
+
|
|
182
|
+
private
|
|
183
|
+
|
|
184
|
+
def fetch_by_symbol_key: (Symbol key) -> Value
|
|
185
|
+
def normalize_pairs: (Hash[untyped, untyped] pairs) -> Hash[untyped, Value]
|
|
186
|
+
def ensure_unique_key: (untyped normalized_key, Hash[untyped, untyped] key_sources, untyped key) -> void
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
class SetValue < Value
|
|
190
|
+
TYPE_NAME: String
|
|
191
|
+
|
|
192
|
+
def initialize: (Set[untyped] | Array[untyped] elements) -> void
|
|
193
|
+
def include?: (untyped value) -> bool
|
|
194
|
+
def to_ruby: () -> Set[untyped]
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
module Builtins
|
|
198
|
+
module BuiltinInvocation
|
|
199
|
+
private
|
|
200
|
+
|
|
201
|
+
def invoke_entry: (untyped entry, Array[untyped] args) -> Value
|
|
202
|
+
def ensure_array_args: (untyped args, String builtin_name) -> Array[untyped]
|
|
203
|
+
def normalize_name: (String | Symbol name) -> String
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
module Base
|
|
207
|
+
def self.assert_arity: (Array[untyped] args, Integer | Array[Integer] expected, ?name: String?) -> void
|
|
208
|
+
def self.assert_type: (untyped value, expected: Class | Array[Class], ?context: String?) -> void
|
|
209
|
+
def self.to_ruby: (untyped value) -> untyped
|
|
210
|
+
def self.to_value: (untyped value) -> Value
|
|
211
|
+
|
|
212
|
+
private
|
|
213
|
+
|
|
214
|
+
def self.normalize_expected: (Class | Array[Class]) -> Array[Class]
|
|
215
|
+
def self.normalize_arity: (Integer | Array[Integer] expected) -> Array[Integer]
|
|
216
|
+
def self.format_arity: (Array[Integer] expected_list) -> String
|
|
217
|
+
def self.arity_valid?: (Integer actual, Integer | Array[Integer] expected) -> bool
|
|
218
|
+
def self.raise_builtin_arity_error: (Integer actual, Integer | Array[Integer] expected, String? name) -> void
|
|
219
|
+
def self.raise_type_error: (expected: String, actual: String, ?context: String?) -> void
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
class BuiltinRegistry
|
|
223
|
+
@builtins: Hash[String, untyped]
|
|
224
|
+
Entry: untyped
|
|
225
|
+
|
|
226
|
+
def initialize: () -> void
|
|
227
|
+
def self.instance: () -> BuiltinRegistry
|
|
228
|
+
def register: (String | Symbol name, Integer | Array[Integer] arity) { (*untyped) -> untyped } -> void
|
|
229
|
+
def call: (String | Symbol name, Array[untyped] args) -> Value
|
|
230
|
+
def entry_for: (String | Symbol name) -> untyped
|
|
231
|
+
def with_entry_override: (String | Symbol name, untyped entry) { () -> untyped } -> untyped
|
|
232
|
+
def with_override: (String | Symbol name, untyped entry) -> BuiltinRegistryOverlay
|
|
233
|
+
def registered?: (String | Symbol name) -> bool
|
|
234
|
+
|
|
235
|
+
private
|
|
236
|
+
|
|
237
|
+
def normalize_name: (String | Symbol name) -> String
|
|
238
|
+
def validate_arity: (Integer | Array[Integer] arity) -> void
|
|
239
|
+
def integer_arity_valid?: (untyped arity) -> bool
|
|
240
|
+
def array_arity_valid?: (untyped arity) -> bool
|
|
241
|
+
def fetch_entry: (String builtin_name) -> untyped
|
|
242
|
+
def invoke_entry: (untyped entry, Array[untyped] args) -> Value
|
|
243
|
+
def ensure_array_args: (untyped args, String builtin_name) -> Array[untyped]
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
class BuiltinRegistryOverlay
|
|
247
|
+
@base_registry: BuiltinRegistry
|
|
248
|
+
@overrides: Hash[String, untyped]
|
|
249
|
+
|
|
250
|
+
def initialize: (base_registry: BuiltinRegistry, ?overrides: Hash[String, untyped]) -> void
|
|
251
|
+
def with_override: (String | Symbol name, untyped entry) -> BuiltinRegistryOverlay
|
|
252
|
+
def call: (String | Symbol name, Array[untyped] args) -> Value
|
|
253
|
+
def entry_for: (String | Symbol name) -> untyped
|
|
254
|
+
def registered?: (String | Symbol name) -> bool
|
|
255
|
+
|
|
256
|
+
private
|
|
257
|
+
|
|
258
|
+
attr_reader base_registry: BuiltinRegistry
|
|
259
|
+
attr_reader overrides: Hash[String, untyped]
|
|
260
|
+
def normalize_name: (String | Symbol name) -> String
|
|
261
|
+
def invoke_entry: (untyped entry, Array[untyped] args) -> Value
|
|
262
|
+
def ensure_array_args: (untyped args, String builtin_name) -> Array[untyped]
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
module RegistryHelpers
|
|
266
|
+
def register_configured_functions: (BuiltinRegistry registry, Hash[String, Hash[Symbol, untyped]] mapping) -> void
|
|
267
|
+
|
|
268
|
+
private
|
|
269
|
+
|
|
270
|
+
def register_configured_function: (BuiltinRegistry registry, String name, Hash[Symbol, untyped] config) -> void
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
module NumericHelpers
|
|
274
|
+
def self.integer_value: (Value value, context: String) -> Integer
|
|
275
|
+
def self.non_negative_integer: (Value value, context: String) -> Integer
|
|
276
|
+
|
|
277
|
+
private
|
|
278
|
+
|
|
279
|
+
def self.raise_integer_error: (Numeric numeric, String context) -> bot
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
module Types
|
|
283
|
+
TYPE_PREDICATES: Hash[String, Symbol]
|
|
284
|
+
|
|
285
|
+
def self.register!: () -> BuiltinRegistry
|
|
286
|
+
def self.is_string: (Value value) -> BooleanValue
|
|
287
|
+
def self.is_number: (Value value) -> BooleanValue
|
|
288
|
+
def self.is_boolean: (Value value) -> BooleanValue
|
|
289
|
+
def self.is_array: (Value value) -> BooleanValue
|
|
290
|
+
def self.is_object: (Value value) -> BooleanValue
|
|
291
|
+
def self.is_set: (Value value) -> BooleanValue
|
|
292
|
+
def self.is_null: (Value value) -> BooleanValue
|
|
293
|
+
|
|
294
|
+
private
|
|
295
|
+
|
|
296
|
+
def self.register_predicate: (BuiltinRegistry registry, String name, Symbol handler) -> void
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
module Aggregates
|
|
300
|
+
AGGREGATE_FUNCTIONS: Hash[String, Symbol]
|
|
301
|
+
|
|
302
|
+
def self.register!: () -> BuiltinRegistry
|
|
303
|
+
def self.count: (Value collection) -> NumberValue
|
|
304
|
+
def self.sum: (Value array) -> NumberValue
|
|
305
|
+
def self.max: (Value array) -> NumberValue
|
|
306
|
+
def self.min: (Value array) -> NumberValue
|
|
307
|
+
def self.all: (Value array) -> BooleanValue
|
|
308
|
+
def self.any: (Value array) -> BooleanValue
|
|
309
|
+
|
|
310
|
+
private
|
|
311
|
+
|
|
312
|
+
def self.register_function: (BuiltinRegistry registry, String name, Symbol handler) -> void
|
|
313
|
+
def self.numeric_array: (Value array, name: String) -> Array[Numeric]
|
|
314
|
+
def self.ensure_non_empty: (Array[Numeric] numbers, name: String) -> void
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
module Strings
|
|
318
|
+
extend RegistryHelpers
|
|
319
|
+
|
|
320
|
+
BASE_DIGITS: Array[String]
|
|
321
|
+
STRING_FUNCTIONS: Hash[String, Hash[Symbol, untyped]]
|
|
322
|
+
|
|
323
|
+
def self.register!: () -> BuiltinRegistry
|
|
324
|
+
def self.concat: (Value delimiter, Value array) -> StringValue
|
|
325
|
+
def self.contains: (Value haystack, Value needle) -> BooleanValue
|
|
326
|
+
def self.startswith: (Value string, Value prefix) -> BooleanValue
|
|
327
|
+
def self.endswith: (Value string, Value suffix) -> BooleanValue
|
|
328
|
+
def self.format_int: (Value number, Value base) -> StringValue
|
|
329
|
+
def self.indexof: (Value haystack, Value needle) -> NumberValue
|
|
330
|
+
def self.lower: (Value string) -> StringValue
|
|
331
|
+
def self.upper: (Value string) -> StringValue
|
|
332
|
+
def self.split: (Value string, Value delimiter) -> ArrayValue
|
|
333
|
+
def self.sprintf: (Value format, Value args) -> StringValue
|
|
334
|
+
def self.substring: (Value string, Value offset, Value length) -> StringValue
|
|
335
|
+
def self.trim: (Value string, Value cutset) -> StringValue
|
|
336
|
+
def self.trim_left: (Value string, Value cutset) -> StringValue
|
|
337
|
+
def self.trim_right: (Value string, Value cutset) -> StringValue
|
|
338
|
+
def self.trim_space: (Value string) -> StringValue
|
|
339
|
+
|
|
340
|
+
private
|
|
341
|
+
|
|
342
|
+
def self.string_value: (Value value, context: String) -> String
|
|
343
|
+
def self.array_values: (Value value, name: String) -> Array[Value]
|
|
344
|
+
def self.string_array: (Value value, name: String) -> Array[String]
|
|
345
|
+
def self.ensure_base: (Integer base_value) -> void
|
|
346
|
+
def self.trim_with_cutset: (Value string, Value cutset, Hash[Symbol, untyped] context) -> StringValue
|
|
347
|
+
def self.base_encode: (Integer number_value, Integer base_value) -> String
|
|
348
|
+
def self.negative_prefix: (Integer number_value) -> String
|
|
349
|
+
def self.encode_digits: (Integer remaining, Integer base_value) -> String
|
|
350
|
+
def self.sprintf_values: (Value args) -> Array[untyped]
|
|
351
|
+
def self.raise_sprintf_error: (ArgumentError | ::TypeError error) -> bot
|
|
352
|
+
def self.trim_regex: (String cutset_text, mode: Symbol) -> Regexp
|
|
353
|
+
def self.trimmed_text: (Value string, Value cutset, Hash[Symbol, untyped] context) -> String
|
|
354
|
+
def self.trim_context: (Hash[Symbol, untyped] context) -> [String, Symbol]
|
|
355
|
+
def self.trim_inputs: (Value string, Value cutset, String name) -> [String, String]
|
|
356
|
+
def self.apply_trim_or_original: (String string_text, String cutset_text, Symbol mode) -> String
|
|
357
|
+
def self.apply_trim: (String string_text, String cutset_text, Symbol mode) -> String
|
|
358
|
+
def self.trim_patterns: (String escaped, Symbol mode) -> Array[String]
|
|
359
|
+
def self.string_pair: (Value left, Value right, left_context: String, right_context: String) -> [String, String]
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
module Collections
|
|
363
|
+
extend RegistryHelpers
|
|
364
|
+
|
|
365
|
+
COLLECTION_FUNCTIONS: Hash[String, Hash[Symbol, untyped]]
|
|
366
|
+
MISSING_SET_ARGUMENT: Object
|
|
367
|
+
|
|
368
|
+
def self.register!: () -> BuiltinRegistry
|
|
369
|
+
def self.set: (?Value value) -> SetValue
|
|
370
|
+
def self.sort: (Value array) -> ArrayValue
|
|
371
|
+
def self.array_concat: (Value left, Value right) -> ArrayValue
|
|
372
|
+
def self.array_slice: (Value array, Value start, Value stop) -> ArrayValue
|
|
373
|
+
def self.object_get: (Value object, Value key, Value default) -> Value
|
|
374
|
+
def self.object_keys: (Value object) -> ArrayValue
|
|
375
|
+
def self.object_remove: (Value object, Value keys) -> ObjectValue
|
|
376
|
+
def self.union: (Value left, Value right) -> Value
|
|
377
|
+
def self.intersection: (Value left, Value right) -> SetValue
|
|
378
|
+
def self.set_diff: (Value left, Value right) -> SetValue
|
|
379
|
+
|
|
380
|
+
private
|
|
381
|
+
|
|
382
|
+
def self.raise_union_type_error: (Value left, Value right) -> bot
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
module Collections::ArrayOps
|
|
386
|
+
def self.sort: (Value array) -> ArrayValue
|
|
387
|
+
def self.array_concat: (Value left, Value right) -> ArrayValue
|
|
388
|
+
def self.array_slice: (Value array, Value start, Value stop) -> ArrayValue
|
|
389
|
+
|
|
390
|
+
private
|
|
391
|
+
|
|
392
|
+
def self.array_values: (Value value, name: String) -> Array[Value]
|
|
393
|
+
def self.ensure_uniform_sort_type: (Array[Value] elements) -> void
|
|
394
|
+
def self.sort_type: (Array[Value] elements) -> Class
|
|
395
|
+
def self.validate_sort_element: (Value element, Class type, Integer index) -> void
|
|
396
|
+
def self.raise_sort_type_error: (Class expected_type, Class actual_type) -> bot
|
|
397
|
+
def self.slice_indices: (Value start, Value stop) -> [Integer, Integer]
|
|
398
|
+
def self.slice_elements: (Array[Value] elements, Integer start_index, Integer stop_index) -> Array[Value]
|
|
399
|
+
end
|
|
400
|
+
|
|
401
|
+
module Collections::ObjectOps
|
|
402
|
+
def self.object_get: (Value object, Value key, Value default) -> Value
|
|
403
|
+
def self.object_keys: (Value object) -> ArrayValue
|
|
404
|
+
def self.object_remove: (Value object, Value keys) -> ObjectValue
|
|
405
|
+
def self.union_objects: (Value left, Value right) -> ObjectValue
|
|
406
|
+
|
|
407
|
+
private
|
|
408
|
+
|
|
409
|
+
def self.object_value: (Value value, name: String) -> ObjectValue
|
|
410
|
+
def self.normalize_object_key: (untyped key) -> untyped
|
|
411
|
+
def self.key_collection: (Value keys, name: String) -> Set[untyped]
|
|
412
|
+
def self.key_values: (Value keys, name: String) -> Array[Value]
|
|
413
|
+
def self.array_key_values: (ArrayValue keys) -> Array[Value]
|
|
414
|
+
def self.values_from_set: (SetValue keys) -> Array[Value]
|
|
415
|
+
def self.merge_objects: (Hash[untyped, Value] left_obj, Hash[untyped, Value] right_obj) -> Hash[untyped, Value]
|
|
416
|
+
def self.conflicting_key: (Hash[untyped, Value] left_obj, Hash[untyped, Value] right_obj) -> untyped?
|
|
417
|
+
def self.raise_object_conflict: (untyped key, Hash[untyped, Value] left_obj, Hash[untyped, Value] right_obj) -> bot
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
module Collections::SetOps
|
|
421
|
+
def self.intersection: (Value left, Value right) -> SetValue
|
|
422
|
+
def self.set_diff: (Value left, Value right) -> SetValue
|
|
423
|
+
def self.union_sets: (Value left, Value right) -> SetValue
|
|
424
|
+
|
|
425
|
+
private
|
|
426
|
+
|
|
427
|
+
def self.set_operation: (Value left, Value right, name: String) { (Set[Value], Set[Value]) -> Set[Value] } -> SetValue
|
|
428
|
+
def self.set_contents: (Value value, name: String) -> Set[Value]
|
|
429
|
+
end
|
|
430
|
+
|
|
431
|
+
module Comparisons
|
|
432
|
+
extend RegistryHelpers
|
|
433
|
+
|
|
434
|
+
COMPARISON_FUNCTIONS: Hash[String, Hash[Symbol, untyped]]
|
|
435
|
+
|
|
436
|
+
def self.register!: () -> BuiltinRegistry
|
|
437
|
+
def self.equal: (Value left, Value right) -> BooleanValue
|
|
438
|
+
def self.to_number: (Value value) -> NumberValue
|
|
439
|
+
def self.cast_string: (Value value) -> StringValue
|
|
440
|
+
def self.cast_boolean: (Value value) -> BooleanValue
|
|
441
|
+
def self.cast_array: (Value value) -> ArrayValue
|
|
442
|
+
def self.cast_set: (Value value) -> SetValue
|
|
443
|
+
def self.cast_object: (Value value) -> ObjectValue
|
|
444
|
+
|
|
445
|
+
private
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
module Comparisons::Casts
|
|
449
|
+
def self.to_number: (Value value) -> NumberValue
|
|
450
|
+
def self.cast_string: (Value value) -> StringValue
|
|
451
|
+
def self.cast_boolean: (Value value) -> BooleanValue
|
|
452
|
+
def self.cast_array: (Value value) -> ArrayValue
|
|
453
|
+
def self.cast_set: (Value value) -> SetValue
|
|
454
|
+
def self.cast_object: (Value value) -> ObjectValue
|
|
455
|
+
|
|
456
|
+
private
|
|
457
|
+
|
|
458
|
+
def self.number_from_string: (String text) -> Numeric
|
|
459
|
+
def self.raise_number_error: (String text) -> bot
|
|
460
|
+
def self.boolean_from_string: (String text) -> BooleanValue
|
|
461
|
+
def self.boolean_from_number: (Numeric number) -> BooleanValue
|
|
462
|
+
def self.raise_cast_error: (String message, String context, untyped actual) -> bot
|
|
463
|
+
def self.raise_type_mismatch: (String context, String expected, String actual) -> bot
|
|
464
|
+
end
|
|
465
|
+
end
|
|
466
|
+
|
|
467
|
+
module EnvironmentOverrides
|
|
468
|
+
UNSET: untyped
|
|
469
|
+
|
|
470
|
+
def with_overrides: (?input: untyped, ?data: untyped) { (untyped) -> untyped } -> untyped
|
|
471
|
+
def memoization: () -> Memoization::Store
|
|
472
|
+
|
|
473
|
+
private
|
|
474
|
+
|
|
475
|
+
def apply_overrides: (untyped input, untyped data) -> void
|
|
476
|
+
end
|
|
477
|
+
|
|
478
|
+
module EnvironmentReferenceResolution
|
|
479
|
+
def resolve_reference: (untyped ref) -> Value
|
|
480
|
+
def reference_key_for: (AST::Variable variable) -> untyped
|
|
481
|
+
|
|
482
|
+
private
|
|
483
|
+
|
|
484
|
+
def lookup: (String | Symbol name) -> Value
|
|
485
|
+
def resolve_base: (untyped base) -> Value
|
|
486
|
+
def resolve_path_segment: (Value current, untyped segment) -> Value
|
|
487
|
+
def resolve_reference_path: (Value current, Array[untyped] path) -> Value
|
|
488
|
+
def extract_reference_key: (untyped segment) -> untyped
|
|
489
|
+
def resolve_reference_variable: (untyped value) -> untyped
|
|
490
|
+
end
|
|
491
|
+
|
|
492
|
+
class Environment::State
|
|
493
|
+
attr_reader input: untyped
|
|
494
|
+
attr_reader data: untyped
|
|
495
|
+
attr_reader rules: Hash[untyped, untyped]
|
|
496
|
+
attr_reader builtin_registry: Builtins::BuiltinRegistry | Builtins::BuiltinRegistryOverlay
|
|
497
|
+
|
|
498
|
+
def initialize: (input: untyped, data: untyped, rules: Hash[untyped, untyped], builtin_registry: Builtins::BuiltinRegistry | Builtins::BuiltinRegistryOverlay) -> void
|
|
499
|
+
end
|
|
500
|
+
|
|
501
|
+
module Memoization
|
|
502
|
+
class Context
|
|
503
|
+
attr_reader rule_values: Hash[String, Value]
|
|
504
|
+
attr_reader reference_values: Hash[AST::Reference, Value]
|
|
505
|
+
attr_reader reference_keys: Hash[AST::Reference, untyped]
|
|
506
|
+
attr_reader function_values: Hash[Array[untyped], Value]
|
|
507
|
+
|
|
508
|
+
def initialize: () -> void
|
|
509
|
+
end
|
|
510
|
+
|
|
511
|
+
class Store
|
|
512
|
+
def initialize: () -> void
|
|
513
|
+
def reset!: () -> void
|
|
514
|
+
def reset: () -> void
|
|
515
|
+
def with_context: () { () -> untyped } -> untyped
|
|
516
|
+
def context: () -> Context
|
|
517
|
+
end
|
|
518
|
+
end
|
|
519
|
+
|
|
520
|
+
class Environment
|
|
521
|
+
RESERVED_BINDINGS: Hash[String, Symbol]
|
|
522
|
+
RESERVED_NAMES: Array[String]
|
|
523
|
+
|
|
524
|
+
attr_reader input: Value
|
|
525
|
+
attr_reader data: Value
|
|
526
|
+
attr_reader rules: Hash[untyped, untyped]
|
|
527
|
+
attr_reader builtin_registry: Builtins::BuiltinRegistry | Builtins::BuiltinRegistryOverlay
|
|
528
|
+
attr_reader memoization: Memoization::Store
|
|
529
|
+
|
|
530
|
+
def initialize: (input: untyped, data: untyped, rules: Hash[untyped, untyped], ?builtin_registry: Builtins::BuiltinRegistry | Builtins::BuiltinRegistryOverlay) -> void
|
|
531
|
+
def push_scope: () -> Environment
|
|
532
|
+
def pop_scope: () -> void
|
|
533
|
+
def bind: (String | Symbol name, untyped value) -> Value
|
|
534
|
+
def lookup: (String | Symbol name) -> Value
|
|
535
|
+
def local_bound?: (String | Symbol name) -> bool
|
|
536
|
+
def resolve_reference: (untyped ref) -> Value
|
|
537
|
+
def reference_key_for: (AST::Variable variable) -> untyped
|
|
538
|
+
def with_bindings: (Hash[String | Symbol, untyped] bindings) { () -> untyped } -> untyped
|
|
539
|
+
def with_overrides: (?input: untyped, ?data: untyped) { (Environment) -> untyped } -> untyped
|
|
540
|
+
def with_builtin_registry: (Builtins::BuiltinRegistry | Builtins::BuiltinRegistryOverlay registry) { (Environment) -> untyped } -> untyped
|
|
541
|
+
def self.from_state: (Environment::State state) -> Environment
|
|
542
|
+
def reset!: (Environment::State state) -> Environment
|
|
543
|
+
def reset: (Environment::State state) -> Environment
|
|
544
|
+
def prepare_for_pool: () -> Environment
|
|
545
|
+
|
|
546
|
+
private
|
|
547
|
+
|
|
548
|
+
attr_reader locals: Array[Hash[String, Value]]
|
|
549
|
+
attr_reader scope_pool: Array[Hash[String, Value]]
|
|
550
|
+
def fresh_scope: () -> Hash[String, Value]
|
|
551
|
+
def reset_scopes: () -> void
|
|
552
|
+
def apply_state: (Environment::State state) -> void
|
|
553
|
+
def resolve_base: (untyped base) -> Value
|
|
554
|
+
def resolve_path_segment: (Value current, untyped segment) -> Value
|
|
555
|
+
def resolve_reference_path: (Value current, Array[untyped] path) -> Value
|
|
556
|
+
def extract_reference_key: (untyped segment) -> untyped
|
|
557
|
+
def resolve_reference_variable: (untyped value) -> untyped
|
|
558
|
+
end
|
|
559
|
+
|
|
560
|
+
class EnvironmentPool
|
|
561
|
+
def initialize: (?max_size: Integer?) -> void
|
|
562
|
+
def checkout: (Environment::State state) -> Environment
|
|
563
|
+
def checkin: (Environment environment) -> void
|
|
564
|
+
|
|
565
|
+
private
|
|
566
|
+
|
|
567
|
+
def max_size: () -> untyped
|
|
568
|
+
def max_size_full?: (Integer current_size) -> bool
|
|
569
|
+
def unbounded: () -> untyped
|
|
570
|
+
def normalized_max_size: (untyped value) -> untyped
|
|
571
|
+
end
|
|
572
|
+
|
|
573
|
+
module WithModifiers
|
|
574
|
+
class WithModifier
|
|
575
|
+
attr_reader target: untyped
|
|
576
|
+
attr_reader value: untyped
|
|
577
|
+
|
|
578
|
+
def initialize: (target: untyped, value: untyped) -> void
|
|
579
|
+
def with_environment: (Environment environment, Evaluator::ExpressionEvaluator expression_evaluator) { (Environment) -> untyped } -> untyped
|
|
580
|
+
end
|
|
581
|
+
|
|
582
|
+
class WithModifierApplier
|
|
583
|
+
def self.apply: (Array[AST::WithModifier] modifiers, Environment environment, Evaluator::ExpressionEvaluator expression_evaluator) { (Environment) -> untyped } -> untyped
|
|
584
|
+
|
|
585
|
+
private
|
|
586
|
+
|
|
587
|
+
def self.build_chain: (Array[AST::WithModifier] modifiers, Evaluator::ExpressionEvaluator expression_evaluator, untyped block) -> untyped
|
|
588
|
+
def self.wrap_modifier: (AST::WithModifier modifier, Evaluator::ExpressionEvaluator expression_evaluator, untyped block) -> untyped
|
|
589
|
+
end
|
|
590
|
+
|
|
591
|
+
class WithModifierContext
|
|
592
|
+
def initialize: (modifier: WithModifier, environment: Environment, expression_evaluator: Evaluator::ExpressionEvaluator) -> void
|
|
593
|
+
def apply: () { (Environment) -> untyped } -> untyped
|
|
594
|
+
|
|
595
|
+
private
|
|
596
|
+
|
|
597
|
+
attr_reader modifier: WithModifier
|
|
598
|
+
attr_reader environment: Environment
|
|
599
|
+
attr_reader expression_evaluator: Evaluator::ExpressionEvaluator
|
|
600
|
+
def target: () -> untyped
|
|
601
|
+
def value: () -> untyped
|
|
602
|
+
def apply_reference: () { (Environment) -> untyped } -> untyped
|
|
603
|
+
def reference_scope: () -> WithModifierRootScope
|
|
604
|
+
def reference_override: (WithModifierRootScope scope) -> untyped
|
|
605
|
+
def reference_path_keys: () -> (Array[untyped] | UndefinedValue)
|
|
606
|
+
def apply_variable: () { (Environment) -> untyped } -> untyped
|
|
607
|
+
def apply_builtin_override: (String name) { (Environment) -> untyped } -> untyped
|
|
608
|
+
def resolved_value: () -> untyped
|
|
609
|
+
end
|
|
610
|
+
|
|
611
|
+
class WithModifierPathOverride
|
|
612
|
+
def initialize: (base_value: untyped, keys: Array[untyped], replacement: untyped, location: Location?) -> void
|
|
613
|
+
def apply: () -> untyped
|
|
614
|
+
|
|
615
|
+
private
|
|
616
|
+
|
|
617
|
+
attr_reader base_value: untyped
|
|
618
|
+
attr_reader keys: Array[untyped]
|
|
619
|
+
attr_reader replacement: untyped
|
|
620
|
+
attr_reader location: Location?
|
|
621
|
+
def apply_to: (untyped container, Array[untyped] path_keys) -> untyped
|
|
622
|
+
def apply_hash: (Hash[untyped, untyped] container, Array[untyped] path_keys) -> Hash[untyped, untyped]
|
|
623
|
+
def apply_array: (Array[untyped] container, Array[untyped] path_keys) -> Array[untyped]
|
|
624
|
+
def array_index: (untyped key) -> Integer
|
|
625
|
+
def array_index_key?: (untyped key) -> bool
|
|
626
|
+
def numeric_key?: (untyped key) -> bool
|
|
627
|
+
def apply_missing_container: (Array[untyped] path_keys) -> untyped
|
|
628
|
+
def invalid_index_error: (untyped key) -> EvaluationError
|
|
629
|
+
end
|
|
630
|
+
|
|
631
|
+
class WithModifierBuiltinOverride
|
|
632
|
+
def initialize: (name: String, value: untyped, expression_evaluator: Evaluator::ExpressionEvaluator, location: Location?) -> void
|
|
633
|
+
def apply: (Environment environment) { (Environment) -> untyped } -> untyped
|
|
634
|
+
|
|
635
|
+
private
|
|
636
|
+
|
|
637
|
+
attr_reader name: String
|
|
638
|
+
attr_reader value: untyped
|
|
639
|
+
attr_reader expression_evaluator: Evaluator::ExpressionEvaluator
|
|
640
|
+
attr_reader location: Location?
|
|
641
|
+
def override_entry: (Builtins::BuiltinRegistry | Builtins::BuiltinRegistryOverlay registry, Environment environment) -> untyped
|
|
642
|
+
def replacement_entry: (Builtins::BuiltinRegistry | Builtins::BuiltinRegistryOverlay registry, Environment environment) -> untyped
|
|
643
|
+
def function_entry: (Environment environment, String function_name) -> untyped
|
|
644
|
+
def ensure_matching_arity: (Integer | Array[Integer] expected, Integer | Array[Integer] actual) -> void
|
|
645
|
+
def normalize_arity_list: (Integer | Array[Integer] arity) -> Array[Integer]
|
|
646
|
+
def replacement_name: () -> String
|
|
647
|
+
def direct_name_from_value: () -> String?
|
|
648
|
+
def reference_name_from_value: () -> String?
|
|
649
|
+
def resolved_name_from_value: () -> String?
|
|
650
|
+
end
|
|
651
|
+
|
|
652
|
+
class WithModifierRootScope
|
|
653
|
+
ROOT_NAMES: Array[String]
|
|
654
|
+
|
|
655
|
+
def initialize: (environment: Environment, name: String, location: Location?) -> void
|
|
656
|
+
def base_value: () -> untyped
|
|
657
|
+
def with_override: (untyped overridden) { (Environment) -> untyped } -> untyped
|
|
658
|
+
|
|
659
|
+
private
|
|
660
|
+
|
|
661
|
+
attr_reader environment: Environment
|
|
662
|
+
attr_reader name: String
|
|
663
|
+
attr_reader location: Location?
|
|
664
|
+
def input_scope?: () -> bool
|
|
665
|
+
def validate_name: () -> void
|
|
666
|
+
end
|
|
667
|
+
|
|
668
|
+
class WithModifierPathKeyResolver
|
|
669
|
+
def initialize: (expression_evaluator: Evaluator::ExpressionEvaluator) -> void
|
|
670
|
+
def resolve: (untyped segment) -> untyped
|
|
671
|
+
|
|
672
|
+
private
|
|
673
|
+
|
|
674
|
+
attr_reader expression_evaluator: Evaluator::ExpressionEvaluator
|
|
675
|
+
def resolved_key: (untyped raw) -> untyped
|
|
676
|
+
end
|
|
677
|
+
end
|
|
678
|
+
|
|
679
|
+
class Unifier
|
|
680
|
+
class ReferenceKeyContext
|
|
681
|
+
attr_reader current: Value
|
|
682
|
+
attr_reader env: Environment
|
|
683
|
+
attr_reader bindings: Hash[String, Value]
|
|
684
|
+
attr_reader variable_resolver: untyped
|
|
685
|
+
|
|
686
|
+
def initialize: (current: Value, env: Environment, bindings: Hash[String, Value], ?variable_resolver: untyped) -> void
|
|
687
|
+
end
|
|
688
|
+
|
|
689
|
+
def initialize: (?variable_resolver: untyped) -> void
|
|
690
|
+
def unify: (untyped pattern, untyped value, Environment env) -> Array[Hash[String, Value]]
|
|
691
|
+
def unify_array: (Array[untyped] pattern_elems, untyped value_array, Environment env, ?Hash[String, Value] bindings) -> Array[Hash[String, Value]]
|
|
692
|
+
def unify_object: (Array[[untyped, untyped]] pattern_pairs, untyped value_obj, Environment env, ?Hash[String, Value] bindings) -> Array[Hash[String, Value]]
|
|
693
|
+
def reference_bindings: (AST::Reference reference, Environment env, ?Hash[String, Value] bindings, ?base_value: Value?, ?variable_resolver: untyped) -> Array[[Hash[String, Value], Value]]
|
|
694
|
+
|
|
695
|
+
private
|
|
696
|
+
|
|
697
|
+
def unify_with_bindings: (untyped pattern, untyped value, Environment env, Hash[String, Value] bindings) -> Array[Hash[String, Value]]
|
|
698
|
+
def structured_unification: (untyped pattern, Value resolved_value, Environment env, Hash[String, Value] bindings) -> Array[Hash[String, Value]]?
|
|
699
|
+
def apply_unification: (untyped pattern, Value resolved_value, Environment env, Hash[String, Value] bindings) -> Array[Hash[String, Value]]
|
|
700
|
+
def reduce_array_bindings: (Array[untyped] pattern_elems, Array[Value] elements, Environment env, Hash[String, Value] bindings) -> Array[Hash[String, Value]]
|
|
701
|
+
def reduce_object_pairs: (Array[[untyped, untyped]] pattern_pairs, Hash[untyped, Value] object_values, Environment env, Hash[String, Value] bindings) -> Array[Hash[String, Value]]
|
|
702
|
+
def unify_object_pair: (untyped key_pattern, untyped value_pattern, Hash[untyped, Value] object_values, Environment env, Hash[String, Value] bindings) -> Array[Hash[String, Value]]
|
|
703
|
+
def unify_object_candidate: (untyped candidate_key, untyped key_pattern, untyped value_pattern, Hash[untyped, Value] object_values, Environment env, Hash[String, Value] bindings) -> Array[Hash[String, Value]]
|
|
704
|
+
def bind_key_variable: (untyped key_pattern, untyped candidate_key, Hash[String, Value] bindings, Environment env) -> Hash[String, Value]?
|
|
705
|
+
def unify_reference: (AST::Reference pattern, Value resolved_value, Environment env, Hash[String, Value] bindings) -> Array[Hash[String, Value]]
|
|
706
|
+
def resolve_reference_base: (untyped base, Environment env, Hash[String, Value] bindings) -> Value
|
|
707
|
+
def traverse_reference: (Value current, Array[AST::RefArg] path, Environment env, Hash[String, Value] bindings, ?variable_resolver: untyped) -> Array[[Hash[String, Value], Value]]
|
|
708
|
+
def reference_key_candidates: (Value current, untyped key_node, Environment env, Hash[String, Value] bindings, ?variable_resolver: untyped) -> Array[[untyped, Hash[String, Value]?]]
|
|
709
|
+
def variable_key_candidates: (AST::Variable key_node, Array[untyped] keys, ReferenceKeyContext context) -> Array[[untyped, Hash[String, Value]?]]
|
|
710
|
+
def value_key_candidates: (untyped key_node, ReferenceKeyContext context) -> Array[[untyped, Hash[String, Value]?]]
|
|
711
|
+
def wildcard_key_candidates: (Array[untyped] keys, Hash[String, Value] bindings) -> Array[[untyped, Hash[String, Value]?]]
|
|
712
|
+
def bound_key_candidate: (String name, ReferenceKeyContext context) -> Array[[untyped, Hash[String, Value]?]]?
|
|
713
|
+
def resolved_key_candidate: (String name, ReferenceKeyContext context) -> Array[[untyped, Hash[String, Value]?]]?
|
|
714
|
+
def binding_key_candidates: (String name, Array[untyped] keys, Hash[String, Value] bindings) -> Array[[untyped, Hash[String, Value]?]]
|
|
715
|
+
def resolved_reference_value: (untyped resolved) -> untyped
|
|
716
|
+
def resolve_variable_reference: (String name, untyped resolver) -> Value?
|
|
717
|
+
def reference_keys_for: (Value current) -> Array[untyped]
|
|
718
|
+
def normalize_reference_key: (Value current, untyped key) -> untyped
|
|
719
|
+
end
|
|
720
|
+
|
|
721
|
+
module Unifier::Helpers
|
|
722
|
+
def self.scalar_pattern_value: (untyped pattern, Environment env) -> Value
|
|
723
|
+
def self.value_for_pattern: (untyped pattern, Environment env) -> Value
|
|
724
|
+
def self.normalize_value: (untyped value, Environment env) -> Value
|
|
725
|
+
def self.normalize_array: (untyped value) -> Array[Value]?
|
|
726
|
+
def self.normalize_elements: (Array[untyped] elements) -> Array[Value]?
|
|
727
|
+
def self.object_pairs: (untyped value) -> Hash[untyped, untyped]?
|
|
728
|
+
def self.normalize_key: (untyped key) -> untyped
|
|
729
|
+
def self.normalize_object: (untyped value) -> Hash[untyped, Value]?
|
|
730
|
+
def self.bound_value_for: (String name, Hash[String, Value] bindings, Environment env) -> Value?
|
|
731
|
+
def self.merge_bindings: (Hash[String, Value] bindings, Hash[String, Value] additions) -> Hash[String, Value]?
|
|
732
|
+
def self.unify_variable: (AST::Variable variable, Value value, Environment env, Hash[String, Value] bindings) -> Array[Hash[String, Value]]
|
|
733
|
+
def self.variable_candidate_keys: (AST::Variable key_pattern, Array[untyped] keys, Environment env, Hash[String, Value] bindings) -> Array[untyped]
|
|
734
|
+
def self.bind_key_variable: (untyped key_pattern, untyped candidate_key, Hash[String, Value] bindings, Environment env) -> Hash[String, Value]?
|
|
735
|
+
def self.candidate_keys_for: (untyped key_pattern, Array[untyped] keys, Environment env, Hash[String, Value] bindings) -> Array[untyped]
|
|
736
|
+
def self.match_scalar: (untyped pattern, Value resolved_value, Environment env, Hash[String, Value] bindings) -> Array[Hash[String, Value]]
|
|
737
|
+
end
|
|
738
|
+
|
|
739
|
+
class Result
|
|
740
|
+
attr_reader value: Value
|
|
741
|
+
attr_reader bindings: Hash[String, Value]
|
|
742
|
+
attr_reader success: bool
|
|
743
|
+
attr_reader errors: Array[untyped]
|
|
744
|
+
|
|
745
|
+
def initialize: (value: untyped, success: bool, ?bindings: Hash[String | Symbol, untyped], ?errors: Array[untyped]) -> void
|
|
746
|
+
def success?: () -> bool
|
|
747
|
+
def undefined?: () -> bool
|
|
748
|
+
def to_h: () -> Hash[Symbol, untyped]
|
|
749
|
+
def to_json: (*untyped) -> String
|
|
750
|
+
|
|
751
|
+
private
|
|
752
|
+
|
|
753
|
+
def add_bindings: (Hash[String | Symbol, untyped] bindings) -> void
|
|
754
|
+
end
|
|
755
|
+
|
|
756
|
+
class Policy
|
|
757
|
+
def initialize: (String source, ?environment_pool: EnvironmentPool) -> void
|
|
758
|
+
def evaluate: (?input: untyped, ?data: untyped, ?query: untyped) -> Result
|
|
759
|
+
|
|
760
|
+
private
|
|
761
|
+
|
|
762
|
+
attr_reader compiled_module: CompiledModule
|
|
763
|
+
attr_reader environment_pool: EnvironmentPool
|
|
764
|
+
attr_reader source: String
|
|
765
|
+
def evaluate_with_pool: (input: untyped, data: untyped, query: untyped) -> Result
|
|
766
|
+
end
|
|
767
|
+
|
|
768
|
+
module CompiledModuleLike
|
|
769
|
+
def rules_by_name: () -> Hash[String, Array[AST::Rule]]
|
|
770
|
+
def package_path: () -> Array[String]
|
|
771
|
+
def imports: () -> Array[AST::Import]
|
|
772
|
+
end
|
|
773
|
+
|
|
774
|
+
type from_ast_options = {
|
|
775
|
+
input?: untyped,
|
|
776
|
+
data?: untyped,
|
|
777
|
+
compiler?: Compiler
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
class CompilationArtifacts
|
|
781
|
+
attr_reader rules_by_name: Hash[String, Array[AST::Rule]]
|
|
782
|
+
attr_reader package_path: Array[String]
|
|
783
|
+
attr_reader dependency_graph: Hash[String, Array[String]]
|
|
784
|
+
|
|
785
|
+
def initialize: (rules_by_name: Hash[String, Array[AST::Rule]], package_path: Array[String], dependency_graph: Hash[String, Array[String]]) -> void
|
|
786
|
+
end
|
|
787
|
+
|
|
788
|
+
class CompiledModule
|
|
789
|
+
include CompiledModuleLike
|
|
790
|
+
attr_reader package_path: Array[String]
|
|
791
|
+
attr_reader rules_by_name: Hash[String, Array[AST::Rule]]
|
|
792
|
+
attr_reader imports: Array[AST::Import]
|
|
793
|
+
attr_reader dependency_graph: Hash[String, Array[String]]
|
|
794
|
+
|
|
795
|
+
def initialize: (package_path: Array[String], rules_by_name: Hash[String, Array[AST::Rule]], ?imports: Array[AST::Import], ?dependency_graph: Hash[String, Array[String]]) -> void
|
|
796
|
+
def lookup_rule: (String | Symbol name) -> Array[AST::Rule]
|
|
797
|
+
def rule_names: () -> Array[String]
|
|
798
|
+
def has_rule?: (String | Symbol name) -> bool
|
|
799
|
+
|
|
800
|
+
private
|
|
801
|
+
|
|
802
|
+
def empty_rules: () -> Array[AST::Rule]
|
|
803
|
+
end
|
|
804
|
+
|
|
805
|
+
class CompiledModule::Normalizer
|
|
806
|
+
def initialize: (Hash[Symbol, untyped] state) -> void
|
|
807
|
+
def normalize: () -> [Array[String], Hash[String, Array[AST::Rule]], Array[AST::Import], Hash[String, Array[String]]]
|
|
808
|
+
|
|
809
|
+
private
|
|
810
|
+
|
|
811
|
+
attr_reader package_path: Array[String]
|
|
812
|
+
attr_reader rules_by_name: Hash[String, Array[AST::Rule]]
|
|
813
|
+
attr_reader imports: Array[AST::Import]
|
|
814
|
+
attr_reader dependency_graph: Hash[String, Array[String]]
|
|
815
|
+
def normalize_rules: () -> Hash[String, Array[AST::Rule]]
|
|
816
|
+
def normalize_dependency_graph: () -> Hash[String, Array[String]]
|
|
817
|
+
end
|
|
818
|
+
|
|
819
|
+
class Compiler
|
|
820
|
+
def initialize: (?builtin_registry: Builtins::BuiltinRegistry, ?default_rule_validator: DefaultRuleValidator?) -> void
|
|
821
|
+
def compile: (AST::Module ast_module) -> CompiledModule
|
|
822
|
+
def index_rules: (Array[AST::Rule] rules) -> Hash[String, Array[AST::Rule]]
|
|
823
|
+
def check_conflicts: (Array[AST::Rule] | Hash[String, Array[AST::Rule]] rules) -> void
|
|
824
|
+
def check_safety: (AST::Rule rule) -> void
|
|
825
|
+
|
|
826
|
+
private
|
|
827
|
+
|
|
828
|
+
def compile_rules: (AST::Module ast_module) -> Hash[String, Array[AST::Rule]]
|
|
829
|
+
def rule_indexer: () -> singleton(RuleIndexer)
|
|
830
|
+
def conflict_checker: () -> ConflictChecker
|
|
831
|
+
def safety_checker: () -> SafetyChecker
|
|
832
|
+
def default_rule_validator: () -> DefaultRuleValidator
|
|
833
|
+
def dependency_graph_builder: () -> DependencyGraphBuilder
|
|
834
|
+
def safe_names_for_imports: (Array[AST::Import] imports) -> Array[String]
|
|
835
|
+
def import_alias_name: (AST::Import import) -> String?
|
|
836
|
+
def validate_import_aliases: (Array[AST::Import] imports, Array[String] rule_names) -> void
|
|
837
|
+
def validate_import_alias: (AST::Import import, Hash[String, bool] seen, Array[String] rule_names) -> void
|
|
838
|
+
def reserved_import_alias?: (String name, AST::Import import) -> bool
|
|
839
|
+
def import_path_exact?: (AST::Import import, String name) -> bool
|
|
840
|
+
def validate_function_name_conflicts: (Hash[String, Array[AST::Rule]] rules_by_name) -> void
|
|
841
|
+
def conflicting_function_rule: (String name, Array[AST::Rule] rules) -> AST::Rule?
|
|
842
|
+
attr_reader builtin_registry: Builtins::BuiltinRegistry
|
|
843
|
+
end
|
|
844
|
+
|
|
845
|
+
class RuleGroup
|
|
846
|
+
attr_reader name: String
|
|
847
|
+
attr_reader rules: Array[AST::Rule]
|
|
848
|
+
|
|
849
|
+
def initialize: (name: String, rules: Array[AST::Rule]) -> void
|
|
850
|
+
def validate: (singleton(RuleTypeResolver) type_resolver) -> void
|
|
851
|
+
def types: (singleton(RuleTypeResolver) type_resolver) -> Array[Symbol?]
|
|
852
|
+
def complete_rules: () -> Array[AST::Rule]
|
|
853
|
+
def value_rules: () -> Array[AST::Rule]
|
|
854
|
+
def function_rules: () -> Array[AST::Rule]
|
|
855
|
+
def default_rules: () -> Array[AST::Rule]
|
|
856
|
+
|
|
857
|
+
private
|
|
858
|
+
|
|
859
|
+
def ensure_consistent_types: (singleton(RuleTypeResolver) type_resolver) -> void
|
|
860
|
+
def ensure_complete_rule_consistency: () -> void
|
|
861
|
+
def ensure_function_arity: () -> void
|
|
862
|
+
def ensure_single_default: () -> void
|
|
863
|
+
def function_arities: () -> Array[Integer]
|
|
864
|
+
end
|
|
865
|
+
|
|
866
|
+
module RuleIndexer
|
|
867
|
+
def self.index: (Array[AST::Rule] rules) -> Hash[String, Array[AST::Rule]]
|
|
868
|
+
end
|
|
869
|
+
|
|
870
|
+
module RuleTypeResolver
|
|
871
|
+
def self.type_for: (AST::Rule rule) -> Symbol?
|
|
872
|
+
end
|
|
873
|
+
|
|
874
|
+
class ConflictChecker
|
|
875
|
+
def initialize: (?indexer: singleton(RuleIndexer), ?type_resolver: singleton(RuleTypeResolver)) -> void
|
|
876
|
+
def check: (Array[AST::Rule] | Hash[String, Array[AST::Rule]] rules) -> void
|
|
877
|
+
|
|
878
|
+
private
|
|
879
|
+
|
|
880
|
+
attr_reader indexer: singleton(RuleIndexer)
|
|
881
|
+
attr_reader type_resolver: singleton(RuleTypeResolver)
|
|
882
|
+
def rule_groups: (Array[AST::Rule] | Hash[String, Array[AST::Rule]] rules) -> Array[RuleGroup]
|
|
883
|
+
end
|
|
884
|
+
|
|
885
|
+
module CompiledModuleBuilder
|
|
886
|
+
def self.build: (AST::Module ast_module, CompilationArtifacts artifacts) -> CompiledModule
|
|
887
|
+
end
|
|
888
|
+
|
|
889
|
+
class RuleHead
|
|
890
|
+
def initialize: (Hash[Symbol, untyped]? head) -> void
|
|
891
|
+
def type: () -> Symbol?
|
|
892
|
+
def nodes: () -> Array[untyped]
|
|
893
|
+
def function_arg_names: () -> Array[String]
|
|
894
|
+
|
|
895
|
+
private
|
|
896
|
+
|
|
897
|
+
attr_reader head: Hash[Symbol, untyped]
|
|
898
|
+
def value_nodes: () -> Array[untyped]
|
|
899
|
+
def function_nodes: () -> Array[untyped]
|
|
900
|
+
def function_arg_nodes: () -> Array[untyped]
|
|
901
|
+
end
|
|
902
|
+
|
|
903
|
+
class SafetyChecker
|
|
904
|
+
def initialize: (?bound_collector: Evaluator::BoundVariableCollector, ?variable_collector_class: singleton(Evaluator::VariableCollector), ?safe_names: Array[String]) -> void
|
|
905
|
+
def check_rules: (Hash[String, Array[AST::Rule]] rules_by_name, ?safe_names: Array[String]) -> void
|
|
906
|
+
def check_rule: (AST::Rule rule, ?safe_names: Array[String]) -> void
|
|
907
|
+
|
|
908
|
+
private
|
|
909
|
+
|
|
910
|
+
attr_reader bound_collector: Evaluator::BoundVariableCollector
|
|
911
|
+
attr_reader variable_collector_class: singleton(Evaluator::VariableCollector)
|
|
912
|
+
attr_reader safe_names: Array[String]
|
|
913
|
+
end
|
|
914
|
+
|
|
915
|
+
DEFAULT_RULE_CHILD_NODE_EXTRACTORS: Hash[Class, untyped]
|
|
916
|
+
|
|
917
|
+
module CallName
|
|
918
|
+
def call_name: (untyped node) -> String?
|
|
919
|
+
def reference_call_name: (AST::Reference reference) -> String?
|
|
920
|
+
def reference_base_name: (AST::Reference reference) -> String?
|
|
921
|
+
def reference_call_segments: (Array[AST::RefArg] path) -> Array[String]?
|
|
922
|
+
def dot_ref_segment_value: (untyped segment) -> String?
|
|
923
|
+
|
|
924
|
+
def self.call_name: (untyped node) -> String?
|
|
925
|
+
def self.reference_call_name: (AST::Reference reference) -> String?
|
|
926
|
+
def self.reference_base_name: (AST::Reference reference) -> String?
|
|
927
|
+
def self.reference_call_segments: (Array[AST::RefArg] path) -> Array[String]?
|
|
928
|
+
def self.dot_ref_segment_value: (untyped segment) -> String?
|
|
929
|
+
end
|
|
930
|
+
|
|
931
|
+
module DefaultRuleCallName
|
|
932
|
+
def call_name: (untyped node) -> String?
|
|
933
|
+
def reference_call_name: (AST::Reference reference) -> String?
|
|
934
|
+
def reference_base_name: (AST::Reference reference) -> String?
|
|
935
|
+
def reference_call_segments: (Array[AST::RefArg] path) -> Array[String]?
|
|
936
|
+
def dot_ref_segment_value: (untyped segment) -> String?
|
|
937
|
+
|
|
938
|
+
def self.call_name: (untyped node) -> String?
|
|
939
|
+
def self.reference_call_name: (AST::Reference reference) -> String?
|
|
940
|
+
def self.reference_base_name: (AST::Reference reference) -> String?
|
|
941
|
+
def self.reference_call_segments: (Array[AST::RefArg] path) -> Array[String]?
|
|
942
|
+
def self.dot_ref_segment_value: (untyped segment) -> String?
|
|
943
|
+
end
|
|
944
|
+
|
|
945
|
+
class DefaultRuleValidator
|
|
946
|
+
def initialize: (?child_node_extractors: Hash[Class, untyped], ?builtin_registry: Builtins::BuiltinRegistry) -> void
|
|
947
|
+
def check: (Hash[String, Array[AST::Rule]] rules_by_name) -> void
|
|
948
|
+
|
|
949
|
+
private
|
|
950
|
+
|
|
951
|
+
attr_reader child_node_extractors: Hash[Class, untyped]
|
|
952
|
+
def contains_variable_or_reference?: (untyped node) -> bool
|
|
953
|
+
def comprehension_value?: (untyped value) -> bool
|
|
954
|
+
def child_nodes: (untyped node) -> Array[untyped]
|
|
955
|
+
end
|
|
956
|
+
|
|
957
|
+
class RuleSafetyContext
|
|
958
|
+
attr_reader head: RuleHead
|
|
959
|
+
attr_reader bound_collector: Evaluator::BoundVariableCollector
|
|
960
|
+
attr_reader variable_collector_class: singleton(Evaluator::VariableCollector)
|
|
961
|
+
attr_reader safe_names: Array[String]
|
|
962
|
+
|
|
963
|
+
def initialize: (head: RuleHead, bound_collector: Evaluator::BoundVariableCollector, variable_collector_class: singleton(Evaluator::VariableCollector), safe_names: Array[String]) -> void
|
|
964
|
+
end
|
|
965
|
+
|
|
966
|
+
class RuleSafetySection
|
|
967
|
+
attr_reader body: untyped
|
|
968
|
+
attr_reader head_nodes: Array[untyped]
|
|
969
|
+
|
|
970
|
+
def initialize: (body: untyped, head_nodes: Array[untyped]) -> void
|
|
971
|
+
end
|
|
972
|
+
|
|
973
|
+
class RuleSafety
|
|
974
|
+
def initialize: (rule: AST::Rule, context: RuleSafetyContext) -> void
|
|
975
|
+
def check: () -> void
|
|
976
|
+
|
|
977
|
+
private
|
|
978
|
+
|
|
979
|
+
attr_reader rule: AST::Rule
|
|
980
|
+
attr_reader context: RuleSafetyContext
|
|
981
|
+
def head: () -> RuleHead
|
|
982
|
+
def bound_collector: () -> Evaluator::BoundVariableCollector
|
|
983
|
+
def variable_collector_class: () -> singleton(Evaluator::VariableCollector)
|
|
984
|
+
def safe_names: () -> Array[String]
|
|
985
|
+
def check_body: () -> void
|
|
986
|
+
def check_else_clause: () -> void
|
|
987
|
+
def else_section: () -> RuleSafetySection?
|
|
988
|
+
def else_nodes: (Hash[Symbol, untyped] clause) -> Array[untyped]
|
|
989
|
+
def check_section: (RuleSafetySection section) -> void
|
|
990
|
+
def unbound_variables: (RuleSafetySection section) -> Array[String]
|
|
991
|
+
def bound_variables: (untyped body) -> Array[String]
|
|
992
|
+
def referenced_names: (RuleSafetySection section) -> Array[String]
|
|
993
|
+
def error_message: (Array[String] unbound) -> String
|
|
994
|
+
end
|
|
995
|
+
|
|
996
|
+
class DependencyContext
|
|
997
|
+
attr_reader rule_names: Array[String]
|
|
998
|
+
attr_reader package_path: Array[String]
|
|
999
|
+
|
|
1000
|
+
def initialize: (rule_names: Array[String], package_path: Array[String]) -> void
|
|
1001
|
+
def package_depth: () -> Integer
|
|
1002
|
+
def package_match?: (Array[untyped] keys) -> bool
|
|
1003
|
+
def resolve_rule_name: (Array[untyped] keys) -> String?
|
|
1004
|
+
|
|
1005
|
+
private
|
|
1006
|
+
|
|
1007
|
+
def package_candidate: (Array[untyped] keys) -> String?
|
|
1008
|
+
def direct_candidate: (Array[untyped] keys) -> String?
|
|
1009
|
+
def rule_name_for: (untyped value) -> String?
|
|
1010
|
+
end
|
|
1011
|
+
|
|
1012
|
+
class DependencyGraphBuilder
|
|
1013
|
+
def initialize: (?extractor: RuleDependencyExtractor) -> void
|
|
1014
|
+
def build: (Hash[String, Array[AST::Rule]] rules_by_name, Array[String] package_path) -> Hash[String, Array[String]]
|
|
1015
|
+
|
|
1016
|
+
private
|
|
1017
|
+
|
|
1018
|
+
attr_reader extractor: RuleDependencyExtractor
|
|
1019
|
+
end
|
|
1020
|
+
|
|
1021
|
+
class DependencyGraph
|
|
1022
|
+
def initialize: (rules_by_name: Hash[String, Array[AST::Rule]], context: DependencyContext, extractor: RuleDependencyExtractor) -> void
|
|
1023
|
+
def build: () -> Hash[String, Array[String]]
|
|
1024
|
+
|
|
1025
|
+
private
|
|
1026
|
+
|
|
1027
|
+
attr_reader rules_by_name: Hash[String, Array[AST::Rule]]
|
|
1028
|
+
attr_reader context: DependencyContext
|
|
1029
|
+
attr_reader extractor: RuleDependencyExtractor
|
|
1030
|
+
def dependencies_for: (Array[AST::Rule] rules) -> Array[String]
|
|
1031
|
+
end
|
|
1032
|
+
|
|
1033
|
+
class RuleDependencyExtractor
|
|
1034
|
+
def initialize: (?reference_walker: ReferenceWalker, ?resolver: RuleReferenceResolver, ?node_extractor_class: singleton(RuleNodeExtractor)) -> void
|
|
1035
|
+
def dependencies_for: (AST::Rule rule, DependencyContext context) -> Array[String]
|
|
1036
|
+
|
|
1037
|
+
private
|
|
1038
|
+
|
|
1039
|
+
attr_reader reference_walker: ReferenceWalker
|
|
1040
|
+
attr_reader resolver: RuleReferenceResolver
|
|
1041
|
+
attr_reader node_extractor_class: singleton(RuleNodeExtractor)
|
|
1042
|
+
end
|
|
1043
|
+
|
|
1044
|
+
class RuleNodeExtractor
|
|
1045
|
+
def initialize: (AST::Rule rule) -> void
|
|
1046
|
+
def nodes: () -> Array[untyped]
|
|
1047
|
+
|
|
1048
|
+
private
|
|
1049
|
+
|
|
1050
|
+
attr_reader rule: AST::Rule
|
|
1051
|
+
attr_reader else_clause: Hash[Symbol, untyped]?
|
|
1052
|
+
def base_nodes: () -> Array[untyped]
|
|
1053
|
+
def else_nodes: () -> Array[untyped]
|
|
1054
|
+
end
|
|
1055
|
+
|
|
1056
|
+
class ReferenceWalker
|
|
1057
|
+
NODE_CHILDREN: Hash[Class, untyped]
|
|
1058
|
+
NODE_HANDLERS: Hash[Class, untyped]
|
|
1059
|
+
|
|
1060
|
+
def initialize: (?children_extractors: Hash[Class, untyped], ?handlers: Hash[Class, untyped]) -> void
|
|
1061
|
+
def references: (untyped nodes) -> Array[AST::Reference]
|
|
1062
|
+
def each_reference: (untyped nodes) ?{ (AST::Reference) -> void } -> (Enumerator[AST::Reference] | Array[untyped])
|
|
1063
|
+
def walk_children: (untyped node) { (AST::Reference) -> void } -> void
|
|
1064
|
+
|
|
1065
|
+
private
|
|
1066
|
+
|
|
1067
|
+
attr_reader children_extractors: Hash[Class, untyped]
|
|
1068
|
+
attr_reader handlers: Hash[Class, untyped]
|
|
1069
|
+
def walk: (untyped node) { (AST::Reference) -> void } -> void
|
|
1070
|
+
def children_for: (untyped node) -> Array[untyped]
|
|
1071
|
+
end
|
|
1072
|
+
|
|
1073
|
+
class RuleReferenceResolver
|
|
1074
|
+
def initialize: (?key_extractor: ReferenceKeyExtractor, ?data_root: String) -> void
|
|
1075
|
+
def resolve: (AST::Reference ref, DependencyContext context) -> String?
|
|
1076
|
+
|
|
1077
|
+
private
|
|
1078
|
+
|
|
1079
|
+
attr_reader key_extractor: ReferenceKeyExtractor
|
|
1080
|
+
attr_reader data_root: String
|
|
1081
|
+
def reference_keys: (Array[AST::RefArg] path) -> Array[untyped]
|
|
1082
|
+
end
|
|
1083
|
+
|
|
1084
|
+
class ReferenceKeyExtractor
|
|
1085
|
+
DEFAULT_EXTRACTORS: Hash[Class, untyped]
|
|
1086
|
+
|
|
1087
|
+
def initialize: (?extractors: Hash[Class, untyped]) -> void
|
|
1088
|
+
def extract: (untyped segment) -> untyped?
|
|
1089
|
+
|
|
1090
|
+
private
|
|
1091
|
+
|
|
1092
|
+
attr_reader extractors: Hash[Class, untyped]
|
|
1093
|
+
end
|
|
1094
|
+
|
|
1095
|
+
class Evaluator
|
|
1096
|
+
attr_reader compiled_module: CompiledModuleLike
|
|
1097
|
+
attr_reader environment: Environment
|
|
1098
|
+
|
|
1099
|
+
def self.from_ast: (AST::Module ast_module, ?from_ast_options options) -> Evaluator
|
|
1100
|
+
def self.from_environment: (CompiledModuleLike compiled_module, Environment environment) -> Evaluator
|
|
1101
|
+
def initialize: (CompiledModuleLike compiled_module, ?input: untyped, ?data: untyped) -> void
|
|
1102
|
+
def evaluate: (?untyped query) -> Result
|
|
1103
|
+
|
|
1104
|
+
private
|
|
1105
|
+
attr_reader expression_evaluator: Evaluator::ExpressionEvaluator
|
|
1106
|
+
attr_reader rule_evaluator: Evaluator::RuleEvaluator
|
|
1107
|
+
def evaluate_rules: () -> Hash[untyped, untyped]
|
|
1108
|
+
def evaluate_query: (untyped query) -> [Value, Hash[String, Value]]
|
|
1109
|
+
def bindings_for_query: (untyped node) -> Hash[String, Value]
|
|
1110
|
+
def build_evaluators: (Hash[String, Array[AST::Rule]] rules_by_name, Array[String] package_path) -> [Evaluator::ExpressionEvaluator, Evaluator::RuleEvaluator]
|
|
1111
|
+
def build_expression_evaluator: (Evaluator::RuleValueProvider rule_value_provider, Array[String] package_path) -> Evaluator::ExpressionEvaluator
|
|
1112
|
+
def build_rule_evaluator: (Evaluator::ExpressionEvaluator expression_evaluator, Evaluator::RuleValueProvider rule_value_provider) -> Evaluator::RuleEvaluator
|
|
1113
|
+
def eval_node: (untyped node) -> Value
|
|
1114
|
+
def initialize_with_environment: (CompiledModuleLike compiled_module, Environment environment) -> void
|
|
1115
|
+
end
|
|
1116
|
+
|
|
1117
|
+
class ResultBuilder
|
|
1118
|
+
def initialize: (untyped value, Hash[String, Value]? bindings) -> void
|
|
1119
|
+
def build: () -> Result
|
|
1120
|
+
|
|
1121
|
+
private
|
|
1122
|
+
|
|
1123
|
+
attr_reader bindings: Hash[String, Value]?
|
|
1124
|
+
attr_reader value: untyped
|
|
1125
|
+
end
|
|
1126
|
+
|
|
1127
|
+
class Evaluator::QueryNodeBuilder
|
|
1128
|
+
def initialize: (untyped query) -> void
|
|
1129
|
+
def build: () -> untyped
|
|
1130
|
+
|
|
1131
|
+
private
|
|
1132
|
+
|
|
1133
|
+
attr_reader query: untyped
|
|
1134
|
+
def reference_from_string: () -> AST::Reference
|
|
1135
|
+
end
|
|
1136
|
+
|
|
1137
|
+
class Evaluator::RuleValueProvider
|
|
1138
|
+
def initialize: (rules_by_name: Hash[String, Array[AST::Rule]], ?memoization: Memoization::Store?) -> void
|
|
1139
|
+
def attach: (Evaluator::RuleEvaluator rule_evaluator) -> void
|
|
1140
|
+
def value_for: (String name) -> Value
|
|
1141
|
+
def rule_defined?: (String name) -> bool
|
|
1142
|
+
|
|
1143
|
+
private
|
|
1144
|
+
|
|
1145
|
+
attr_reader rule_evaluator: Evaluator::RuleEvaluator?
|
|
1146
|
+
attr_reader rules_by_name: Hash[String, Array[AST::Rule]]
|
|
1147
|
+
attr_reader memoization: Memoization::Store?
|
|
1148
|
+
def memoized_value_for: (String name) -> Value
|
|
1149
|
+
def evaluate_value_for: (String name) -> Value
|
|
1150
|
+
end
|
|
1151
|
+
|
|
1152
|
+
class Evaluator::ReferenceResolver
|
|
1153
|
+
UNCACHEABLE: untyped
|
|
1154
|
+
|
|
1155
|
+
class StaticKeyBuilder
|
|
1156
|
+
ROOT_NAMES: Array[String]
|
|
1157
|
+
|
|
1158
|
+
def initialize: (AST::Reference reference) -> void
|
|
1159
|
+
def call: () -> Array[untyped]?
|
|
1160
|
+
|
|
1161
|
+
private
|
|
1162
|
+
|
|
1163
|
+
attr_reader reference: AST::Reference
|
|
1164
|
+
def segment_key: (untyped segment) -> untyped?
|
|
1165
|
+
end
|
|
1166
|
+
|
|
1167
|
+
def initialize: (environment: Environment, package_path: Array[String], rule_value_provider: Evaluator::RuleValueProvider, ?imports: Array[AST::Import], ?memoization: Memoization::Store?) -> void
|
|
1168
|
+
def resolve: (untyped ref) -> Value
|
|
1169
|
+
def resolve_import_variable: (String name) -> Value?
|
|
1170
|
+
def resolve_rule_variable: (String name) -> Value?
|
|
1171
|
+
def function_reference_name: (AST::Reference reference) -> String?
|
|
1172
|
+
|
|
1173
|
+
private
|
|
1174
|
+
|
|
1175
|
+
def resolve_reference_value: (AST::Reference ref) -> Value
|
|
1176
|
+
def resolve_rule_reference: (AST::Reference ref) -> Value?
|
|
1177
|
+
def resolve_import_reference: (AST::Reference ref) -> Value?
|
|
1178
|
+
def resolve_rule_reference_without_data: (AST::Reference ref) -> Value?
|
|
1179
|
+
def import_reference_for: (AST::Reference ref) -> AST::Reference?
|
|
1180
|
+
def rule_reference: (Array[AST::RefArg] path) -> [String, Array[AST::RefArg]]?
|
|
1181
|
+
def resolve_rule_value: (String rule_name, Array[AST::RefArg] remaining_path) -> Value
|
|
1182
|
+
def package_rule_reference: (Array[untyped] keys, Array[AST::RefArg] path) -> [String, Array[AST::RefArg]]?
|
|
1183
|
+
def direct_rule_reference: (Array[untyped] keys, Array[AST::RefArg] path) -> [String, Array[AST::RefArg]]?
|
|
1184
|
+
def resolve_reference_path: (Value current, Array[AST::RefArg] path) -> Value
|
|
1185
|
+
def resolve_reference_path_fast: (Value current, AST::Reference reference) -> Value
|
|
1186
|
+
def resolve_reference_path_keys: (Value current, Array[untyped] keys) -> Value
|
|
1187
|
+
def resolve_path_segment: (Value current, AST::RefArg segment) -> Value
|
|
1188
|
+
def valid_reference_keys: (Array[AST::RefArg] path) -> Array[untyped]?
|
|
1189
|
+
def reference_keys: (Array[AST::RefArg] path) -> Array[untyped]
|
|
1190
|
+
def package_match?: (Array[untyped] keys) -> bool
|
|
1191
|
+
def function_reference_target: (AST::Reference reference) -> AST::Reference
|
|
1192
|
+
def resolve_function_reference_name: (AST::Reference reference) -> String?
|
|
1193
|
+
def build_import_map: (Array[AST::Import] imports) -> Hash[String, AST::Reference]
|
|
1194
|
+
def import_path_segments: (AST::Import import) -> Array[String]
|
|
1195
|
+
def build_reference_from_path: (Array[String] path) -> AST::Reference
|
|
1196
|
+
def resolve_variable_key: (String name) -> Value
|
|
1197
|
+
def cached_reference_value: (AST::Reference reference) -> Value?
|
|
1198
|
+
def cache_reference_value: (AST::Reference reference, Value value) -> void
|
|
1199
|
+
def reference_cache: () -> Hash[AST::Reference, Value]?
|
|
1200
|
+
def cacheable_reference?: (AST::Reference reference) -> bool
|
|
1201
|
+
def static_reference_keys: (AST::Reference reference) -> Array[untyped]?
|
|
1202
|
+
|
|
1203
|
+
private
|
|
1204
|
+
|
|
1205
|
+
attr_reader environment: Environment
|
|
1206
|
+
attr_reader key_resolver: Evaluator::ReferenceKeyResolver
|
|
1207
|
+
attr_reader package_path: Array[String]
|
|
1208
|
+
attr_reader rule_value_provider: Evaluator::RuleValueProvider
|
|
1209
|
+
attr_reader import_map: Hash[String, AST::Reference]
|
|
1210
|
+
attr_reader memoization: Memoization::Store?
|
|
1211
|
+
end
|
|
1212
|
+
|
|
1213
|
+
class Evaluator::ReferenceKeyResolver
|
|
1214
|
+
def initialize: (environment: Environment, ?variable_resolver: untyped) -> void
|
|
1215
|
+
def resolve: (untyped segment) -> untyped
|
|
1216
|
+
|
|
1217
|
+
private
|
|
1218
|
+
|
|
1219
|
+
attr_reader environment: Environment
|
|
1220
|
+
attr_reader variable_resolver: untyped
|
|
1221
|
+
def resolve_segment: (untyped segment) -> untyped
|
|
1222
|
+
def resolve_variable_key: (AST::Variable variable) -> untyped
|
|
1223
|
+
end
|
|
1224
|
+
|
|
1225
|
+
class Evaluator::ExpressionEvaluator
|
|
1226
|
+
PRIMITIVE_TYPES: Array[Class]
|
|
1227
|
+
NODE_EVALUATORS: Array[[Class, ^(untyped, Evaluator::ExpressionEvaluator) -> Value]]
|
|
1228
|
+
TRUE_VALUE: BooleanValue
|
|
1229
|
+
FALSE_VALUE: BooleanValue
|
|
1230
|
+
|
|
1231
|
+
include Evaluator::AssignmentSupport
|
|
1232
|
+
|
|
1233
|
+
def initialize: (environment: Environment, reference_resolver: Evaluator::ReferenceResolver) -> void
|
|
1234
|
+
def attach_query_evaluator: (Evaluator::RuleEvaluator query_evaluator) -> void
|
|
1235
|
+
def evaluate: (untyped node) -> Value
|
|
1236
|
+
def eval_with_unification: (untyped node, ?Environment env) -> Enumerator[Hash[String, Value]]
|
|
1237
|
+
def evaluate_user_function: (String name, Array[Value] args) -> Value
|
|
1238
|
+
|
|
1239
|
+
private
|
|
1240
|
+
|
|
1241
|
+
def evaluate_variable: (AST::Variable node) -> Value
|
|
1242
|
+
def resolve_variable_name: (String name) -> Value
|
|
1243
|
+
def resolve_reference_variable_key: (String name) -> Value
|
|
1244
|
+
def resolve_import_or_rule: (String name, Value fallback) -> Value
|
|
1245
|
+
def evaluate_reference: (AST::Reference node) -> Value
|
|
1246
|
+
def evaluate_array_literal: (AST::ArrayLiteral node) -> Value
|
|
1247
|
+
def evaluate_object_literal: (AST::ObjectLiteral node) -> Value
|
|
1248
|
+
def evaluate_set_literal: (AST::SetLiteral node) -> Value
|
|
1249
|
+
def evaluate_call: (AST::Call node) -> Value
|
|
1250
|
+
def evaluate_template_string: (AST::TemplateString node) -> Value
|
|
1251
|
+
def eval_array_comprehension: (AST::ArrayComprehension node) -> Value
|
|
1252
|
+
def eval_object_comprehension: (AST::ObjectComprehension node) -> Value
|
|
1253
|
+
def eval_set_comprehension: (AST::SetComprehension node) -> Value
|
|
1254
|
+
def evaluate_every: (AST::Every node) -> Value
|
|
1255
|
+
def evaluate_every_bindings: (AST::Every node, Enumerator[Hash[String, Value]] bindings_enum) -> Value
|
|
1256
|
+
def evaluate_binary_op: (AST::BinaryOp node) -> Value
|
|
1257
|
+
def evaluate_logical_operator: (AST::BinaryOp node) -> Value
|
|
1258
|
+
def evaluate_and_operator: (AST::BinaryOp node) -> Value
|
|
1259
|
+
def evaluate_or_operator: (AST::BinaryOp node) -> Value
|
|
1260
|
+
def logical_state: (Value value) -> Symbol
|
|
1261
|
+
def evaluate_unary_op: (AST::UnaryOp node) -> Value
|
|
1262
|
+
def self.call_name: (untyped node) -> String?
|
|
1263
|
+
def self.reference_call_name: (AST::Reference reference) -> String?
|
|
1264
|
+
def self.reference_base_name: (AST::Reference reference) -> String?
|
|
1265
|
+
def self.reference_call_segments: (Array[AST::RefArg] path) -> Array[String]?
|
|
1266
|
+
def self.dot_ref_segment_value: (untyped segment) -> String?
|
|
1267
|
+
def build_dispatch: () -> Evaluator::ExpressionDispatch
|
|
1268
|
+
def handle_unification_operator: (AST::BinaryOp node, Environment env, Enumerator::Yielder yielder) -> void
|
|
1269
|
+
def yield_assignment_bindings: (AST::BinaryOp node, Environment env, Enumerator::Yielder yielder) -> void
|
|
1270
|
+
def yield_unification_bindings: (AST::BinaryOp node, Environment env, Enumerator::Yielder yielder) -> void
|
|
1271
|
+
def yield_truthy_bindings: (untyped node, Enumerator::Yielder yielder) -> void
|
|
1272
|
+
def yield_reference_bindings: (AST::Reference node, Environment env, Enumerator::Yielder yielder) -> void
|
|
1273
|
+
def format_template_value: (Value value) -> String
|
|
1274
|
+
def call_named_function: (String name, untyped name_node, Array[Value] args) -> Value
|
|
1275
|
+
def function_name_for_call: (untyped name_node, String fallback_name) -> String
|
|
1276
|
+
def every_body_succeeds?: (Array[untyped] body, Hash[String, Value] bindings) -> bool
|
|
1277
|
+
def every_bindings: (Array[AST::Variable] variables, Value collection_value) -> Enumerator[Hash[String, Value]]?
|
|
1278
|
+
def bindings_for_collection: (Array[AST::Variable] variables, Value collection_value) -> Enumerator[Hash[String, Value]]?
|
|
1279
|
+
def array_bindings_for: (Array[AST::Variable] variables, ArrayValue collection_value) -> Enumerator[Hash[String, Value]]?
|
|
1280
|
+
def set_bindings_for: (Array[AST::Variable] variables, SetValue collection_value) -> Enumerator[Hash[String, Value]]?
|
|
1281
|
+
def object_bindings_for: (Array[AST::Variable] variables, ObjectValue collection_value) -> Enumerator[Hash[String, Value]]?
|
|
1282
|
+
def each_array_binding: (Array[AST::Variable] variables, ArrayValue collection_value) -> Enumerator[Hash[String, Value]]
|
|
1283
|
+
def each_set_binding: (Array[AST::Variable] variables, SetValue collection_value) -> Enumerator[Hash[String, Value]]
|
|
1284
|
+
def each_object_binding: (Array[AST::Variable] variables, ObjectValue collection_value) -> Enumerator[Hash[String, Value]]
|
|
1285
|
+
def bindings_for_pair: (Array[AST::Variable] variables, untyped first_value, untyped second_value) -> Hash[String, Value]
|
|
1286
|
+
def bindings_for: (AST::Variable variable, untyped value) -> Hash[String, Value]
|
|
1287
|
+
def with_every_scope: (AST::Every node) { () -> untyped } -> untyped
|
|
1288
|
+
def shadow_every_locals: (AST::Every node) -> void
|
|
1289
|
+
def every_variable_names: (AST::Every node) -> Array[String]
|
|
1290
|
+
def shadow_explicit_locals: (Array[String] names) -> void
|
|
1291
|
+
def shadow_unification_locals: (Array[String] names, Array[String] explicit_names) -> void
|
|
1292
|
+
def bind_undefined: (String name) -> void
|
|
1293
|
+
def query_evaluator: () -> Evaluator::RuleEvaluator
|
|
1294
|
+
def raise_unknown_node: (untyped node) -> Value
|
|
1295
|
+
|
|
1296
|
+
attr_reader environment: Environment
|
|
1297
|
+
attr_reader reference_resolver: Evaluator::ReferenceResolver
|
|
1298
|
+
attr_reader object_literal_evaluator: Evaluator::ObjectLiteralEvaluator
|
|
1299
|
+
attr_reader dispatch: Evaluator::ExpressionDispatch
|
|
1300
|
+
attr_reader unifier: Unifier
|
|
1301
|
+
attr_reader comprehension_evaluator: Evaluator::ComprehensionEvaluator
|
|
1302
|
+
|
|
1303
|
+
end
|
|
1304
|
+
|
|
1305
|
+
class Evaluator::TemplateValueFormatter
|
|
1306
|
+
def initialize: (untyped value) -> void
|
|
1307
|
+
def render: () -> String
|
|
1308
|
+
def canonical_value: () -> untyped
|
|
1309
|
+
|
|
1310
|
+
private
|
|
1311
|
+
|
|
1312
|
+
attr_reader value: untyped
|
|
1313
|
+
def canonicalize_hash: () -> Hash[untyped, untyped]
|
|
1314
|
+
def canonicalize_array: () -> Array[untyped]
|
|
1315
|
+
def canonicalize_set: () -> Array[untyped]
|
|
1316
|
+
end
|
|
1317
|
+
|
|
1318
|
+
module Evaluator::BindingHelpers
|
|
1319
|
+
private
|
|
1320
|
+
|
|
1321
|
+
def each_array_binding: (Array[AST::Variable] variables, ArrayValue collection_value) -> Enumerator[Hash[String, Value]]
|
|
1322
|
+
def each_set_binding: (Array[AST::Variable] variables, SetValue collection_value) -> Enumerator[Hash[String, Value]]
|
|
1323
|
+
def each_object_binding: (Array[AST::Variable] variables, ObjectValue collection_value) -> Enumerator[Hash[String, Value]]
|
|
1324
|
+
def bindings_for_pair: (Array[AST::Variable] variables, untyped first_value, untyped second_value) -> Hash[String, Value]
|
|
1325
|
+
def bindings_for: (AST::Variable variable, untyped value) -> Hash[String, Value]
|
|
1326
|
+
end
|
|
1327
|
+
|
|
1328
|
+
class Evaluator::ComprehensionEvaluator
|
|
1329
|
+
class ObjectAccumulator
|
|
1330
|
+
def initialize: () -> void
|
|
1331
|
+
def add: (Hash[Object, Value] values, untyped key, Value value) -> void
|
|
1332
|
+
|
|
1333
|
+
private
|
|
1334
|
+
|
|
1335
|
+
attr_reader key_sources: Hash[Object, Object]
|
|
1336
|
+
end
|
|
1337
|
+
|
|
1338
|
+
class ObjectPairContext
|
|
1339
|
+
attr_reader result_values: Hash[Object, Value]
|
|
1340
|
+
attr_reader accumulator: ObjectAccumulator
|
|
1341
|
+
|
|
1342
|
+
def initialize: (Hash[Object, Value] result_values, ObjectAccumulator accumulator) -> void
|
|
1343
|
+
end
|
|
1344
|
+
|
|
1345
|
+
def initialize: (expression_evaluator: Evaluator::ExpressionEvaluator, environment: Environment) -> void
|
|
1346
|
+
def attach_query_evaluator: (Evaluator::RuleEvaluator query_evaluator) -> void
|
|
1347
|
+
def eval_array: (AST::ArrayComprehension node) -> Value
|
|
1348
|
+
def eval_object: (AST::ObjectComprehension node) -> Value
|
|
1349
|
+
def eval_set: (AST::SetComprehension node) -> Value
|
|
1350
|
+
|
|
1351
|
+
private
|
|
1352
|
+
|
|
1353
|
+
def object_pairs: (AST::ObjectComprehension node) -> Hash[Object, Value]
|
|
1354
|
+
def apply_object_binding: (ObjectPairContext context, AST::object_term term, Hash[String, Value] bindings) -> void
|
|
1355
|
+
def resolve_pair: (AST::object_term term) -> (Array[untyped] | nil)
|
|
1356
|
+
def each_comprehension_binding: (Array[untyped] body) { (Hash[String, Value]) -> untyped } -> void
|
|
1357
|
+
def collect_values: (AST::ArrayComprehension | AST::SetComprehension node) -> Array[Value]
|
|
1358
|
+
def append_value: (Array[Value] values, untyped term, Hash[String, Value] bindings) -> void
|
|
1359
|
+
def evaluate_defined_key: (untyped node) -> untyped
|
|
1360
|
+
def evaluate_defined_value: (untyped node) -> untyped
|
|
1361
|
+
def comprehension_solutions: (Array[untyped] body) -> Enumerator[Hash[String, Value]]
|
|
1362
|
+
def with_comprehension_scope: (Array[untyped] body) { () -> untyped } -> untyped
|
|
1363
|
+
def shadow_comprehension_locals: (Array[untyped] body) -> void
|
|
1364
|
+
def shadow_explicit_locals: (Array[String] names) -> void
|
|
1365
|
+
def shadow_unification_locals: (Array[String] names, Array[String] explicit_names) -> void
|
|
1366
|
+
def bind_undefined: (String name) -> void
|
|
1367
|
+
|
|
1368
|
+
attr_reader expression_evaluator: Evaluator::ExpressionEvaluator
|
|
1369
|
+
attr_reader environment: Environment
|
|
1370
|
+
attr_reader query_evaluator: Evaluator::RuleEvaluator?
|
|
1371
|
+
end
|
|
1372
|
+
|
|
1373
|
+
module Evaluator::VariableCollectorHelpers
|
|
1374
|
+
NODE_COLLECTORS: Hash[Class, untyped]
|
|
1375
|
+
CHILDREN_EXTRACTORS: Hash[Class, untyped]
|
|
1376
|
+
|
|
1377
|
+
def self.collector_for: (untyped node) -> untyped
|
|
1378
|
+
def self.children_for: (untyped node) -> Array[untyped]
|
|
1379
|
+
def self.comprehension_node?: (untyped node) -> bool
|
|
1380
|
+
end
|
|
1381
|
+
|
|
1382
|
+
class Evaluator::BoundVariableCollector
|
|
1383
|
+
@explicit_names: Array[String]
|
|
1384
|
+
@unify_names: Array[String]
|
|
1385
|
+
|
|
1386
|
+
def initialize: () -> void
|
|
1387
|
+
def collect: (Array[untyped] literals) -> Array[String]
|
|
1388
|
+
def collect_details: (Array[untyped] literals) -> Hash[Symbol, Array[String]]
|
|
1389
|
+
|
|
1390
|
+
private
|
|
1391
|
+
|
|
1392
|
+
attr_reader explicit_names: Array[String]
|
|
1393
|
+
attr_reader unify_names: Array[String]
|
|
1394
|
+
def reset: () -> void
|
|
1395
|
+
def collect_from_literal: (untyped literal) -> void
|
|
1396
|
+
def collect_from_expression: (untyped expression) -> void
|
|
1397
|
+
def collect_explicit_variables: (untyped node) -> void
|
|
1398
|
+
def collect_unification_variables: (untyped node) -> void
|
|
1399
|
+
def collect_all_variables: (untyped node, Array[String] target) -> void
|
|
1400
|
+
end
|
|
1401
|
+
|
|
1402
|
+
class Evaluator::VariableCollector
|
|
1403
|
+
@names: Array[String]
|
|
1404
|
+
@local_scopes: Array[Array[String]]
|
|
1405
|
+
|
|
1406
|
+
def initialize: () -> void
|
|
1407
|
+
def collect: (untyped node) -> Array[String]
|
|
1408
|
+
def collect_literals: (Array[untyped] literals) -> Array[String]
|
|
1409
|
+
|
|
1410
|
+
private
|
|
1411
|
+
|
|
1412
|
+
attr_reader names: Array[String]
|
|
1413
|
+
def collect_node: (untyped node) -> void
|
|
1414
|
+
def collect_comprehension: (Array[untyped] term_nodes, Array[untyped] body_literals) -> void
|
|
1415
|
+
def collect_comprehension_body: (Array[untyped] term_nodes, Array[untyped] body_literals) -> void
|
|
1416
|
+
def collect_some_decl: (AST::SomeDecl node) -> void
|
|
1417
|
+
def collect_every: (AST::Every node) -> void
|
|
1418
|
+
def every_variable_names: (AST::Every node) -> Array[String]
|
|
1419
|
+
def add_name: (String name) -> void
|
|
1420
|
+
def with_locals: (Array[String] names) { () -> untyped } -> void
|
|
1421
|
+
def local_name?: (String name) -> bool
|
|
1422
|
+
end
|
|
1423
|
+
|
|
1424
|
+
class Evaluator::ObjectLiteralEvaluator
|
|
1425
|
+
def initialize: (expression_evaluator: Evaluator::ExpressionEvaluator) -> void
|
|
1426
|
+
def evaluate: (AST::ObjectLiteral node) -> Value
|
|
1427
|
+
|
|
1428
|
+
private
|
|
1429
|
+
|
|
1430
|
+
attr_reader expression_evaluator: Evaluator::ExpressionEvaluator
|
|
1431
|
+
def build_pairs: (AST::ObjectLiteral node) -> (Hash[Object, Value] | UndefinedValue)
|
|
1432
|
+
def evaluate_key: (untyped key_node) -> untyped
|
|
1433
|
+
def resolve_pair: (untyped key_node, untyped value_node) -> (Array[untyped] | UndefinedValue)
|
|
1434
|
+
end
|
|
1435
|
+
|
|
1436
|
+
module Evaluator::AssignmentSupport
|
|
1437
|
+
private
|
|
1438
|
+
|
|
1439
|
+
def evaluate: (untyped node) -> Value
|
|
1440
|
+
def environment: () -> Environment
|
|
1441
|
+
def unifier: () -> Unifier
|
|
1442
|
+
def reference_resolver: () -> Evaluator::ReferenceResolver
|
|
1443
|
+
def evaluate_assignment: (AST::BinaryOp node) -> Value
|
|
1444
|
+
def evaluate_unification: (AST::BinaryOp node) -> Value
|
|
1445
|
+
def unification_binding_sets: (AST::BinaryOp node, Environment env) -> Array[Hash[String, Value]]
|
|
1446
|
+
def unification_result: (AST::BinaryOp node, Environment env) -> [Array[Hash[String, Value]], Value]
|
|
1447
|
+
def reference_bindings_for: (AST::Reference reference, Environment env) -> Array[[Hash[String, Value], Value]]
|
|
1448
|
+
def reference_base_override: (AST::Reference reference) -> Value?
|
|
1449
|
+
def reference_base_name: (AST::Reference reference) -> String?
|
|
1450
|
+
def unresolved_reference_base?: (String name) -> bool
|
|
1451
|
+
def resolve_reference_base: (String name) -> Value?
|
|
1452
|
+
def bind_reference_variable: (AST::Variable variable, Array[[Hash[String, Value], Value]] reference_bindings) -> Array[Hash[String, Value]]
|
|
1453
|
+
def apply_bindings: (Hash[String, Value] bindings) -> Hash[String, Value]
|
|
1454
|
+
end
|
|
1455
|
+
|
|
1456
|
+
class Evaluator::ExpressionDispatch
|
|
1457
|
+
def initialize: (primitive_types: Array[Class], node_evaluators: Array[[Class, ^(untyped, Evaluator::ExpressionEvaluator) -> Value]]) -> void
|
|
1458
|
+
def primitive_value: (untyped node) -> Value?
|
|
1459
|
+
def dispatch_node: (untyped node, Evaluator::ExpressionEvaluator evaluator) -> Value?
|
|
1460
|
+
|
|
1461
|
+
private
|
|
1462
|
+
|
|
1463
|
+
attr_reader primitive_types: Array[Class]
|
|
1464
|
+
attr_reader node_evaluators: Array[[Class, ^(untyped, Evaluator::ExpressionEvaluator) -> Value]]
|
|
1465
|
+
attr_reader handler_cache: Hash[Class, (^(untyped, Evaluator::ExpressionEvaluator) -> Value)?]
|
|
1466
|
+
def handler_for: (untyped node) -> (^(untyped, Evaluator::ExpressionEvaluator) -> Value)?
|
|
1467
|
+
end
|
|
1468
|
+
|
|
1469
|
+
class Evaluator::RuleEvaluator
|
|
1470
|
+
class QueryContext
|
|
1471
|
+
attr_reader literals: Array[untyped]
|
|
1472
|
+
attr_reader env: Environment
|
|
1473
|
+
|
|
1474
|
+
def initialize: (literals: Array[untyped], env: Environment) -> void
|
|
1475
|
+
end
|
|
1476
|
+
|
|
1477
|
+
class ModifierContext
|
|
1478
|
+
attr_reader expression: untyped
|
|
1479
|
+
attr_reader env: Environment
|
|
1480
|
+
attr_reader bound_vars: Array[String]
|
|
1481
|
+
|
|
1482
|
+
def initialize: (expression: untyped, env: Environment, bound_vars: Array[String]) -> void
|
|
1483
|
+
def with_env: (Environment new_env) -> ModifierContext
|
|
1484
|
+
end
|
|
1485
|
+
|
|
1486
|
+
class ValueEvaluationContext
|
|
1487
|
+
attr_reader body: Array[untyped]?
|
|
1488
|
+
attr_reader rule: AST::Rule
|
|
1489
|
+
attr_reader value_node: untyped
|
|
1490
|
+
attr_reader initial_bindings: Hash[String, Value]
|
|
1491
|
+
|
|
1492
|
+
def initialize: (body: Array[untyped]?, rule: AST::Rule, value_node: untyped, initial_bindings: Hash[String, Value]) -> void
|
|
1493
|
+
end
|
|
1494
|
+
|
|
1495
|
+
def initialize: (environment: Environment, expression_evaluator: Evaluator::ExpressionEvaluator) -> void
|
|
1496
|
+
def evaluate_group: (Array[AST::Rule] rules) -> Value
|
|
1497
|
+
def evaluate_rule: (AST::Rule rule) -> Value
|
|
1498
|
+
def evaluate_function_call: (String name, Array[Value] args) -> Value
|
|
1499
|
+
def query_solutions: (Array[untyped] literals, ?Environment env) -> Enumerator[Hash[String, Value]]
|
|
1500
|
+
|
|
1501
|
+
private
|
|
1502
|
+
|
|
1503
|
+
def evaluate_function_call_uncached: (String name, Array[Value] args) -> Value
|
|
1504
|
+
def evaluate_partial_set_rules: (Array[AST::Rule] rules) -> Value
|
|
1505
|
+
def evaluate_partial_object_rules: (Array[AST::Rule] rules) -> Value
|
|
1506
|
+
def partial_object_pairs: (Array[AST::Rule] rules) -> Hash[Object, Value]
|
|
1507
|
+
def merge_partial_object_value: (Value? existing, Value value, untyped key, bool existing_nested, bool current_nested) -> Value
|
|
1508
|
+
def merge_object_value_hash: (Hash[Object, Value] left, Hash[Object, Value] right, untyped key) -> Hash[Object, Value]
|
|
1509
|
+
def merge_object_value_value: (Value? existing, Value value, untyped key) -> Value
|
|
1510
|
+
def evaluate_complete_rules: (Array[AST::Rule] rules) -> Value
|
|
1511
|
+
def evaluate_partial_object_value: (untyped head) -> untyped
|
|
1512
|
+
def evaluate_complete_rule_value: (untyped head, ?untyped value_node) -> Value
|
|
1513
|
+
def complete_rule_value_with_else: (AST::Rule rule) -> Value
|
|
1514
|
+
def else_clause_value: (AST::Rule rule, untyped clause) -> Value
|
|
1515
|
+
def evaluate_value_with_body: (ValueEvaluationContext context) -> Array[Value]
|
|
1516
|
+
def values_for_body_context: (ValueEvaluationContext context) -> Array[Value]
|
|
1517
|
+
def evaluate_value_node: (AST::Rule rule, untyped value_node) -> Value?
|
|
1518
|
+
def empty_bindings: () -> Hash[String, Value]
|
|
1519
|
+
def evaluate_clause_value: (AST::Rule rule, untyped clause, Hash[String, Value] bindings) -> Array[Value]
|
|
1520
|
+
def function_values_with_else: (AST::Rule rule, Hash[String, Value] bindings) -> Array[Value]
|
|
1521
|
+
def function_else_values: (AST::Rule rule, untyped clause, Hash[String, Value] bindings) -> Array[Value]
|
|
1522
|
+
def resolve_conflicts: (Array[Value] values, String name) -> Value?
|
|
1523
|
+
def evaluate_function_rules: (Array[AST::Rule] rules, Array[Value] args) -> Array[Value]
|
|
1524
|
+
def function_rule_values: (AST::Rule rule, Array[Value] args) -> Array[Value]
|
|
1525
|
+
def body_succeeds?: (Array[untyped]? body) -> bool
|
|
1526
|
+
def query_literal_truthy?: (untyped literal) -> bool
|
|
1527
|
+
def some_decl_truthy?: (AST::SomeDecl literal) -> bool
|
|
1528
|
+
def evaluate_rule_value: (untyped head) -> Value
|
|
1529
|
+
def rule_body_values: (AST::Rule rule, ?Hash[String, Value] initial_bindings) -> Array[Value]
|
|
1530
|
+
def rule_body_pairs: (AST::Rule rule) -> Array[[Object, Value, bool]]
|
|
1531
|
+
def eval_rule_body: (Array[untyped]? body, Environment env) -> Enumerator[Hash[String, Value]]
|
|
1532
|
+
def eval_query: (Array[untyped] literals, Environment env) -> Enumerator[Hash[String, Value]]
|
|
1533
|
+
def with_query_scope: (Environment env, Array[untyped] literals) { () -> untyped } -> untyped
|
|
1534
|
+
def shadow_query_locals: (Environment env, Array[untyped] literals) -> void
|
|
1535
|
+
def shadow_explicit_locals: (Environment env, Array[String] names) -> void
|
|
1536
|
+
def shadow_unification_locals: (Environment env, Array[String] names, Array[String] explicit_names) -> void
|
|
1537
|
+
def bind_undefined: (Environment env, String name) -> void
|
|
1538
|
+
def yield_query_solutions: (Enumerator::Yielder yielder, QueryContext context, Integer index, Hash[String, Value] bindings, Array[String] bound_vars) -> void
|
|
1539
|
+
def eval_literal: (untyped literal, Environment env, Array[String] bound_vars) -> Enumerator[Hash[String, Value]]
|
|
1540
|
+
def eval_query_literal: (AST::QueryLiteral literal, Environment env, Array[String] bound_vars) -> Enumerator[Hash[String, Value]]
|
|
1541
|
+
def eval_query_expression: (untyped expression, Environment env, Array[String] bound_vars) -> Enumerator[Hash[String, Value]]
|
|
1542
|
+
def with_modifiers_enum: (Array[AST::WithModifier] modifiers, ModifierContext context) -> Enumerator[Hash[String, Value]]
|
|
1543
|
+
def yield_query_expression: (Enumerator::Yielder yielder, ModifierContext context) -> void
|
|
1544
|
+
def eval_not: (untyped expr, Environment env, Array[String] bound_vars) -> Enumerator[Hash[String, Value]]
|
|
1545
|
+
def check_safety: (untyped expr, Environment env, Array[String] bound_vars) -> void
|
|
1546
|
+
def raise_unsafe_negation: (untyped expr, Array[String] unbound) -> void
|
|
1547
|
+
def unbound_variables: (Array[String] names, Environment env, Array[String] bound_vars) -> Array[String]
|
|
1548
|
+
def env_bound?: (Environment env, String name) -> bool
|
|
1549
|
+
def eval_some_decl: (AST::SomeDecl literal, ?Environment env) -> Enumerator[Hash[String, Value]]
|
|
1550
|
+
def yield_empty_bindings: (Enumerator::Yielder yielder) -> void
|
|
1551
|
+
def each_some_solution: (AST::SomeDecl literal) -> Enumerator[Hash[String, Value]]
|
|
1552
|
+
def collection_bindings: (Array[AST::Variable] variables, Value collection_value) -> Enumerator[Hash[String, Value]]
|
|
1553
|
+
def each_array_binding: (Array[AST::Variable] variables, ArrayValue collection_value) -> Enumerator[Hash[String, Value]]
|
|
1554
|
+
def each_set_binding: (Array[AST::Variable] variables, SetValue collection_value) -> Enumerator[Hash[String, Value]]
|
|
1555
|
+
def each_object_binding: (Array[AST::Variable] variables, ObjectValue collection_value) -> Enumerator[Hash[String, Value]]
|
|
1556
|
+
def bindings_for_pair: (Array[AST::Variable] variables, untyped first_value, untyped second_value) -> Hash[String, Value]
|
|
1557
|
+
def bindings_for: (AST::Variable variable, untyped value) -> Hash[String, Value]
|
|
1558
|
+
def merge_bindings: (Hash[String, Value] existing, Hash[String, Value] additions) -> Hash[String, Value]?
|
|
1559
|
+
def empty_bindings_enum: () -> Enumerator[Hash[String, Value]]
|
|
1560
|
+
def memoization: () -> Memoization::Store
|
|
1561
|
+
|
|
1562
|
+
attr_reader environment: Environment
|
|
1563
|
+
attr_reader expression_evaluator: Evaluator::ExpressionEvaluator
|
|
1564
|
+
attr_reader unifier: Unifier
|
|
1565
|
+
end
|
|
1566
|
+
|
|
1567
|
+
module Evaluator::OperatorEvaluator
|
|
1568
|
+
EQUALITY_OPERATORS: Hash[Symbol, ^(untyped, untyped) -> Value]
|
|
1569
|
+
LOGICAL_OPERATORS: Hash[Symbol, ^(Value, Value) -> Value]
|
|
1570
|
+
COMPARISON_OPERATORS: Hash[Symbol, ^(untyped, untyped) -> bool]
|
|
1571
|
+
ARITHMETIC_OPERATORS: Hash[Symbol, ^(untyped, untyped) -> untyped]
|
|
1572
|
+
MEMBERSHIP_OPERATORS: Hash[Symbol, ^(Value, Value) -> Value]
|
|
1573
|
+
UNARY_OPERATORS: Hash[Symbol, ^(Value) -> Value]
|
|
1574
|
+
|
|
1575
|
+
def self.apply: (Symbol operator, Value left, Value right) -> Value
|
|
1576
|
+
def self.apply_unary: (Symbol operator, Value operand) -> Value
|
|
1577
|
+
def self.apply_logical: (Symbol operator, Value left, Value right) -> Value?
|
|
1578
|
+
def self.apply_comparison: (Symbol operator, Value left, Value right) -> Value?
|
|
1579
|
+
def self.apply_arithmetic: (Symbol operator, Value left, Value right) -> Value?
|
|
1580
|
+
def self.compare_values: (Value left, Value right) { (untyped, untyped) -> bool } -> Value
|
|
1581
|
+
def self.comparable?: (untyped left_value, untyped right_value) -> bool
|
|
1582
|
+
def self.arithmetic_values: (Symbol operator, Value left, Value right) { (untyped, untyped) -> untyped } -> Value
|
|
1583
|
+
def self.numeric_value: (Value value) -> Numeric?
|
|
1584
|
+
def self.division_by_zero?: (Symbol operator, Numeric right_value) -> bool
|
|
1585
|
+
def self.undefined_operand?: (Value lhs, Value rhs) -> bool
|
|
1586
|
+
def self.collection_values: (Value value) -> (Array[Value] | UndefinedValue)
|
|
1587
|
+
def self.membership_value: (Value lhs, Value rhs) -> Value
|
|
1588
|
+
end
|
|
1589
|
+
|
|
1590
|
+
module TokenType
|
|
1591
|
+
PACKAGE: Symbol
|
|
1592
|
+
IMPORT: Symbol
|
|
1593
|
+
AS: Symbol
|
|
1594
|
+
DEFAULT: Symbol
|
|
1595
|
+
IF: Symbol
|
|
1596
|
+
CONTAINS: Symbol
|
|
1597
|
+
SOME: Symbol
|
|
1598
|
+
IN: Symbol
|
|
1599
|
+
EVERY: Symbol
|
|
1600
|
+
NOT: Symbol
|
|
1601
|
+
AND: Symbol
|
|
1602
|
+
OR: Symbol
|
|
1603
|
+
WITH: Symbol
|
|
1604
|
+
ELSE: Symbol
|
|
1605
|
+
TRUE: Symbol
|
|
1606
|
+
FALSE: Symbol
|
|
1607
|
+
NULL: Symbol
|
|
1608
|
+
DATA: Symbol
|
|
1609
|
+
INPUT: Symbol
|
|
1610
|
+
|
|
1611
|
+
ASSIGN: Symbol
|
|
1612
|
+
EQ: Symbol
|
|
1613
|
+
NEQ: Symbol
|
|
1614
|
+
LT: Symbol
|
|
1615
|
+
LTE: Symbol
|
|
1616
|
+
GT: Symbol
|
|
1617
|
+
GTE: Symbol
|
|
1618
|
+
PLUS: Symbol
|
|
1619
|
+
MINUS: Symbol
|
|
1620
|
+
STAR: Symbol
|
|
1621
|
+
SLASH: Symbol
|
|
1622
|
+
PERCENT: Symbol
|
|
1623
|
+
PIPE: Symbol
|
|
1624
|
+
AMPERSAND: Symbol
|
|
1625
|
+
UNIFY: Symbol
|
|
1626
|
+
|
|
1627
|
+
LPAREN: Symbol
|
|
1628
|
+
RPAREN: Symbol
|
|
1629
|
+
LBRACKET: Symbol
|
|
1630
|
+
RBRACKET: Symbol
|
|
1631
|
+
LBRACE: Symbol
|
|
1632
|
+
RBRACE: Symbol
|
|
1633
|
+
DOT: Symbol
|
|
1634
|
+
COMMA: Symbol
|
|
1635
|
+
SEMICOLON: Symbol
|
|
1636
|
+
COLON: Symbol
|
|
1637
|
+
UNDERSCORE: Symbol
|
|
1638
|
+
|
|
1639
|
+
STRING: Symbol
|
|
1640
|
+
TEMPLATE_STRING: Symbol
|
|
1641
|
+
NUMBER: Symbol
|
|
1642
|
+
RAW_STRING: Symbol
|
|
1643
|
+
RAW_TEMPLATE_STRING: Symbol
|
|
1644
|
+
IDENT: Symbol
|
|
1645
|
+
|
|
1646
|
+
EOF: Symbol
|
|
1647
|
+
NEWLINE: Symbol
|
|
1648
|
+
COMMENT: Symbol
|
|
1649
|
+
|
|
1650
|
+
KEYWORDS: Array[Symbol]
|
|
1651
|
+
OPERATORS: Array[Symbol]
|
|
1652
|
+
DELIMITERS: Array[Symbol]
|
|
1653
|
+
LITERALS: Array[Symbol]
|
|
1654
|
+
SPECIALS: Array[Symbol]
|
|
1655
|
+
|
|
1656
|
+
def self.keyword?: (Symbol type) -> bool
|
|
1657
|
+
def self.operator?: (Symbol type) -> bool
|
|
1658
|
+
def self.literal?: (Symbol type) -> bool
|
|
1659
|
+
end
|
|
1660
|
+
|
|
1661
|
+
class Token
|
|
1662
|
+
attr_reader type: Symbol
|
|
1663
|
+
attr_reader value: untyped
|
|
1664
|
+
attr_reader location: Location?
|
|
1665
|
+
|
|
1666
|
+
def initialize: (type: Symbol, ?value: untyped, ?location: Location?) -> void
|
|
1667
|
+
def keyword?: () -> bool
|
|
1668
|
+
def operator?: () -> bool
|
|
1669
|
+
def literal?: () -> bool
|
|
1670
|
+
def to_s: () -> String
|
|
1671
|
+
end
|
|
1672
|
+
|
|
1673
|
+
class Lexer
|
|
1674
|
+
KEYWORDS: Hash[String, Symbol]
|
|
1675
|
+
SINGLE_CHAR_TOKENS: Hash[String, Symbol]
|
|
1676
|
+
COMPOUND_TOKENS: Hash[String, [Symbol?, Symbol]]
|
|
1677
|
+
NEWLINE_CHARS: Array[String]
|
|
1678
|
+
WHITESPACE_CHARS: Array[String]
|
|
1679
|
+
EXPONENT_CHARS: Array[String]
|
|
1680
|
+
SIGN_CHARS: Array[String]
|
|
1681
|
+
IDENTIFIER_START: Regexp
|
|
1682
|
+
IDENTIFIER_PART: Regexp
|
|
1683
|
+
DIGIT: Regexp
|
|
1684
|
+
HEX_DIGIT: Regexp
|
|
1685
|
+
TEMPLATE_ESCAPE: String
|
|
1686
|
+
|
|
1687
|
+
def initialize: (String source) -> void
|
|
1688
|
+
def tokenize: () -> Array[Token]
|
|
1689
|
+
|
|
1690
|
+
private
|
|
1691
|
+
|
|
1692
|
+
def next_token: () -> Token
|
|
1693
|
+
def eof_token: () -> Token
|
|
1694
|
+
def simple_token_for: (String char) -> Token?
|
|
1695
|
+
def read_compound_token: (String char) -> Token?
|
|
1696
|
+
def skip_whitespace: () -> void
|
|
1697
|
+
def skip_comment: () -> void
|
|
1698
|
+
def read_number: () -> Token
|
|
1699
|
+
def read_number_prefix: () -> String
|
|
1700
|
+
def read_fractional_part: () -> String
|
|
1701
|
+
def read_exponent_part: () -> String
|
|
1702
|
+
def read_exponent_sign: () -> String
|
|
1703
|
+
def read_string: () -> Token
|
|
1704
|
+
def read_raw_string: () -> Token
|
|
1705
|
+
def read_template_string: () -> Token
|
|
1706
|
+
def read_standard_template_string: (position start) -> Token
|
|
1707
|
+
def read_raw_template_string: (position start) -> Token
|
|
1708
|
+
def read_newline: () -> Token
|
|
1709
|
+
def read_identifier: () -> Token
|
|
1710
|
+
def read_digits: () -> String
|
|
1711
|
+
def read_escape_sequence: (position backslash_position) -> String
|
|
1712
|
+
def read_unicode_escape: () -> String
|
|
1713
|
+
def parse_number: (String buffer, position start) -> Numeric
|
|
1714
|
+
def template_string_start?: (String char) -> bool
|
|
1715
|
+
def advance: () -> String
|
|
1716
|
+
def advance_line_break: () -> String
|
|
1717
|
+
def advance_newline: () -> String
|
|
1718
|
+
def increment_line: (Integer count) -> void
|
|
1719
|
+
def increment_position: (Integer count) -> void
|
|
1720
|
+
def peek: (?Integer distance) -> String?
|
|
1721
|
+
def match?: (String expected) -> bool
|
|
1722
|
+
def current_char: () -> String?
|
|
1723
|
+
def eof?: () -> bool
|
|
1724
|
+
def capture_position: () -> position
|
|
1725
|
+
def build_token: (Symbol type, untyped value, position start) -> Token
|
|
1726
|
+
def identifier_start?: (String? char) -> bool
|
|
1727
|
+
def identifier_part?: (String? char) -> bool
|
|
1728
|
+
def digit?: (String? char) -> bool
|
|
1729
|
+
def hex_digit?: (String? char) -> bool
|
|
1730
|
+
def whitespace?: (String? char) -> bool
|
|
1731
|
+
def newline?: (String? char) -> bool
|
|
1732
|
+
def exponent_start?: () -> bool
|
|
1733
|
+
def span_length_from: (position start) -> Integer
|
|
1734
|
+
def raise_unterminated_string: (position start) -> bot
|
|
1735
|
+
def raise_unterminated_raw_string: (position start) -> bot
|
|
1736
|
+
def raise_unexpected_eof: () -> bot
|
|
1737
|
+
def raise_error: (String message, position position, length: Integer?) -> bot
|
|
1738
|
+
|
|
1739
|
+
private
|
|
1740
|
+
|
|
1741
|
+
attr_reader source: String
|
|
1742
|
+
attr_reader position: Integer
|
|
1743
|
+
attr_reader line: Integer
|
|
1744
|
+
attr_reader column: Integer
|
|
1745
|
+
attr_reader offset: Integer
|
|
1746
|
+
end
|
|
1747
|
+
|
|
1748
|
+
class Parser
|
|
1749
|
+
IDENTIFIER_TOKEN_TYPES: Array[Symbol]
|
|
1750
|
+
IDENTIFIER_TOKEN_NAMES: Hash[Symbol, String]
|
|
1751
|
+
PACKAGE_PATH_TOKEN_TYPES: Array[Symbol]
|
|
1752
|
+
IMPORT_PATH_TOKEN_TYPES: Array[Symbol]
|
|
1753
|
+
BINARY_OPERATOR_MAP: Hash[Symbol, Symbol]
|
|
1754
|
+
UNARY_OPERATOR_MAP: Hash[Symbol, Symbol]
|
|
1755
|
+
PRIMARY_PARSERS: Hash[Symbol, Symbol]
|
|
1756
|
+
|
|
1757
|
+
@tokens: Array[Token]
|
|
1758
|
+
@current: Integer
|
|
1759
|
+
@errors: Array[ParserError]
|
|
1760
|
+
|
|
1761
|
+
def initialize: (Array[Token] tokens) -> void
|
|
1762
|
+
def parse: () -> AST::Module
|
|
1763
|
+
def self.parse_expression_from_string: (String source) -> AST::expression
|
|
1764
|
+
|
|
1765
|
+
private
|
|
1766
|
+
|
|
1767
|
+
def tokens: () -> Array[Token]
|
|
1768
|
+
def current_token: () -> Token
|
|
1769
|
+
def peek: (?Integer distance) -> Token
|
|
1770
|
+
def advance: () -> Token
|
|
1771
|
+
def consume: (Symbol type, ?String message) -> Token
|
|
1772
|
+
def match?: (*Symbol types) -> bool
|
|
1773
|
+
def pipe_token?: () -> bool
|
|
1774
|
+
def rbrace_token?: () -> bool
|
|
1775
|
+
def newline_token?: () -> bool
|
|
1776
|
+
def consume_newlines: () -> void
|
|
1777
|
+
def at_end?: () -> bool
|
|
1778
|
+
def parse_error: (String message) -> bot
|
|
1779
|
+
def synchronize: () -> void
|
|
1780
|
+
def parse_module: () -> AST::Module
|
|
1781
|
+
def parse_statement: (Array[AST::Import] imports, Array[AST::Rule] rules) -> void
|
|
1782
|
+
def parse_package: () -> AST::Package
|
|
1783
|
+
def parse_import: () -> AST::Import
|
|
1784
|
+
def parse_import_alias: () -> String?
|
|
1785
|
+
def parse_rule: () -> AST::Rule
|
|
1786
|
+
def consume_default_keyword: () -> Token?
|
|
1787
|
+
def parse_rule_name_path: () -> Array[String]
|
|
1788
|
+
def mark_default_head: (Hash[Symbol, untyped] head) -> Hash[Symbol, untyped]
|
|
1789
|
+
def parse_default_value: (Token? default_token, Hash[Symbol, untyped] head) -> AST::expression?
|
|
1790
|
+
def parse_non_default_body: (Token? default_token) -> Array[AST::query_literal]?
|
|
1791
|
+
def parse_rule_definition: (Token? default_token, Hash[Symbol, untyped] head) -> Hash[Symbol, untyped]
|
|
1792
|
+
def parse_else_clause_for_definition: (Token? default_token) -> Hash[Symbol, untyped]?
|
|
1793
|
+
def validate_rule_definition: (Token? default_token, Hash[Symbol, untyped] head, Hash[Symbol, untyped] definition) -> void
|
|
1794
|
+
def parse_else_clause_if_present: () -> Hash[Symbol, untyped]?
|
|
1795
|
+
def build_rule_node: (name: String, head: Hash[Symbol, untyped], name_token: Token, definition: Hash[Symbol, untyped]) -> AST::Rule
|
|
1796
|
+
def parse_rule_head: (String name, Token name_token) -> Hash[Symbol, untyped]
|
|
1797
|
+
def parse_contains_rule_head: (String name, Token name_token) -> Hash[Symbol, untyped]
|
|
1798
|
+
def parse_function_rule_head: (String name, Token name_token) -> Hash[Symbol, untyped]
|
|
1799
|
+
def parse_bracket_rule_head: (String name, Token name_token) -> Hash[Symbol, untyped]
|
|
1800
|
+
def parse_partial_object_rule_head: (String name, Token name_token, AST::expression key) -> Hash[Symbol, untyped]
|
|
1801
|
+
def build_rule_head: (Symbol type, String name, Token name_token, **untyped attrs) -> Hash[Symbol, untyped]
|
|
1802
|
+
def parse_rule_head_args: () -> Array[AST::expression]
|
|
1803
|
+
def parse_rule_head_key: () -> AST::expression
|
|
1804
|
+
def parse_rule_value: () -> AST::expression?
|
|
1805
|
+
def parse_rule_body: () -> Array[AST::query_literal]
|
|
1806
|
+
def parse_braced_rule_body: () -> Array[AST::query_literal]
|
|
1807
|
+
def parse_empty_rule_body: () -> Array[AST::query_literal]
|
|
1808
|
+
def apply_rule_head_path: (Hash[Symbol, untyped] head, Array[String] segments, Token name_token) -> Hash[Symbol, untyped]
|
|
1809
|
+
def nested_rule_head: (Hash[Symbol, untyped] head, Array[String] segments, Token name_token) -> Hash[Symbol, untyped]
|
|
1810
|
+
def parse_query: (*Symbol end_tokens, ?newline_delimiter: bool) -> Array[AST::query_literal]
|
|
1811
|
+
def consume_query_separators: (bool newline_delimiter) -> bool
|
|
1812
|
+
def parse_literal: () -> AST::query_literal
|
|
1813
|
+
def parse_some_decl: () -> AST::SomeDecl
|
|
1814
|
+
def parse_every: () -> AST::Every
|
|
1815
|
+
def parse_some_variables: () -> Array[AST::Variable]
|
|
1816
|
+
def parse_some_collection: () -> AST::expression?
|
|
1817
|
+
def parse_every_variables: () -> [AST::Variable?, AST::Variable]
|
|
1818
|
+
def parse_every_domain: () -> AST::expression
|
|
1819
|
+
def parse_every_body: () -> Array[AST::query_literal]
|
|
1820
|
+
def parse_with_modifier: () -> AST::WithModifier
|
|
1821
|
+
def parse_with_modifiers: () -> Array[AST::WithModifier]
|
|
1822
|
+
def parse_else_clause: () -> Hash[Symbol, untyped]
|
|
1823
|
+
def parse_expression: (?Integer precedence) -> AST::expression
|
|
1824
|
+
def parse_infix_expression: (AST::expression left, Integer precedence) -> AST::expression
|
|
1825
|
+
def infix_operator?: (Integer precedence) -> bool
|
|
1826
|
+
def parse_primary: () -> AST::expression
|
|
1827
|
+
def parse_infix: (AST::expression left, Token operator_token) -> AST::BinaryOp
|
|
1828
|
+
def parse_reference: (AST::expression base) -> AST::Reference
|
|
1829
|
+
def parse_array: () -> AST::expression
|
|
1830
|
+
def parse_object: (Token start_token, AST::expression first_key, AST::expression first_value) -> AST::ObjectLiteral
|
|
1831
|
+
def build_object_pairs: (AST::expression first_key, AST::expression first_value) -> Array[[AST::expression, AST::expression]]
|
|
1832
|
+
def parse_set: (Token start_token, ?AST::expression first_element) -> AST::SetLiteral
|
|
1833
|
+
def parse_array_comprehension: (Token start_token, AST::expression term) -> AST::ArrayComprehension
|
|
1834
|
+
def parse_object_comprehension: (Token start_token, AST::expression key, AST::expression value) -> AST::ObjectComprehension
|
|
1835
|
+
def parse_set_comprehension: (Token start_token, AST::expression term) -> AST::SetComprehension
|
|
1836
|
+
def parse_comprehension: (Token start_token, untyped term, Symbol end_token, [String, String] messages, untyped node_class) -> untyped
|
|
1837
|
+
def parse_call_args: () -> Array[AST::expression]
|
|
1838
|
+
def parse_string_literal: () -> AST::StringLiteral
|
|
1839
|
+
def parse_template_string: () -> AST::TemplateString
|
|
1840
|
+
def parse_template_parts: (Token token) -> Array[untyped]
|
|
1841
|
+
def append_template_literal: (Array[untyped] parts, String literal, Location? location) -> void
|
|
1842
|
+
def normalize_template_literal: (String literal) -> String
|
|
1843
|
+
def find_template_expression_end: (String text, Integer start_index) -> Integer
|
|
1844
|
+
def parse_number_literal: () -> AST::NumberLiteral
|
|
1845
|
+
def parse_boolean_literal: () -> AST::BooleanLiteral
|
|
1846
|
+
def parse_null_literal: () -> AST::NullLiteral
|
|
1847
|
+
def parse_unary_expression: () -> AST::UnaryOp
|
|
1848
|
+
def parse_parenthesized_expression: () -> AST::expression
|
|
1849
|
+
def parse_parenthesized_body: () -> AST::expression
|
|
1850
|
+
def parse_parenthesized_expression_list: (open_message: String, close_message: String) -> Array[AST::expression]
|
|
1851
|
+
def parse_path: (Parser::IdentifierContext identifier_context) -> Array[String]
|
|
1852
|
+
def parse_path_segment: (Parser::IdentifierContext identifier_context) -> String
|
|
1853
|
+
def parse_bracket_path_segment: () -> String?
|
|
1854
|
+
def bracket_string_segment?: () -> bool
|
|
1855
|
+
def parse_identifier: (Parser::IdentifierContext identifier_context) -> String
|
|
1856
|
+
def parse_braced_literal: () -> AST::expression
|
|
1857
|
+
def parse_object_literal_or_comprehension: (Token start_token, AST::expression key) -> AST::expression
|
|
1858
|
+
def parse_identifier_expression: () -> AST::expression
|
|
1859
|
+
def parse_variable: () -> AST::Variable
|
|
1860
|
+
def parse_expression_list_until: (Symbol end_token) -> Array[AST::expression]
|
|
1861
|
+
def parse_expression_list_until_with_first: (Symbol end_token, AST::expression first_element) -> Array[AST::expression]
|
|
1862
|
+
def append_expression_list: (Array[AST::expression] elements, Symbol end_token) -> void
|
|
1863
|
+
def parse_object_pair: (AST::expression key) -> [AST::expression, AST::expression]
|
|
1864
|
+
def append_object_pairs: (Array[[AST::expression, AST::expression]] pairs) -> void
|
|
1865
|
+
def empty_set?: (AST::expression?) -> bool
|
|
1866
|
+
def empty_object_literal: (Token start_token) -> AST::ObjectLiteral
|
|
1867
|
+
def empty_set_literal: (Token start_token) -> AST::SetLiteral
|
|
1868
|
+
def parse_reference_path: (Array[AST::RefArg] path) -> void
|
|
1869
|
+
def parse_dot_reference: (Array[AST::RefArg] path) -> void
|
|
1870
|
+
def parse_bracket_reference: (Array[AST::RefArg] path) -> void
|
|
1871
|
+
def safe_token_at: (Integer index) -> Token
|
|
1872
|
+
def record_error: (ParserError error) -> void
|
|
1873
|
+
|
|
1874
|
+
private
|
|
1875
|
+
|
|
1876
|
+
def errors: () -> Array[ParserError]
|
|
1877
|
+
end
|
|
1878
|
+
|
|
1879
|
+
class Parser::IdentifierContext
|
|
1880
|
+
attr_reader name: String
|
|
1881
|
+
attr_reader allowed_types: Array[Symbol]
|
|
1882
|
+
|
|
1883
|
+
def initialize: (name: String, allowed_types: Array[Symbol]) -> void
|
|
1884
|
+
end
|
|
1885
|
+
|
|
1886
|
+
class Parser
|
|
1887
|
+
module Precedence
|
|
1888
|
+
LOWEST: Integer
|
|
1889
|
+
ASSIGNMENT: Integer
|
|
1890
|
+
OR: Integer
|
|
1891
|
+
AND: Integer
|
|
1892
|
+
EQUALS: Integer
|
|
1893
|
+
COMPARE: Integer
|
|
1894
|
+
SUM: Integer
|
|
1895
|
+
PRODUCT: Integer
|
|
1896
|
+
UNARY: Integer
|
|
1897
|
+
BINARY: Hash[Symbol, Integer]
|
|
1898
|
+
end
|
|
1899
|
+
end
|
|
1900
|
+
|
|
1901
|
+
class Parser
|
|
1902
|
+
module Helpers
|
|
1903
|
+
def self.precedence_of: (Symbol operator) -> Integer
|
|
1904
|
+
def self.normalize_reference_base: (AST::expression base) -> [AST::expression, Array[AST::RefArg]]
|
|
1905
|
+
def self.variable_name_for: (Token token) -> String
|
|
1906
|
+
end
|
|
1907
|
+
end
|
|
1908
|
+
|
|
1909
|
+
module AST
|
|
1910
|
+
class Base
|
|
1911
|
+
attr_reader location: Location?
|
|
1912
|
+
|
|
1913
|
+
def initialize: (?location: Location?) -> void
|
|
1914
|
+
def accept: (untyped visitor) -> untyped
|
|
1915
|
+
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
|
|
1916
|
+
def to_s: () -> String
|
|
1917
|
+
def ==: (untyped other) -> bool
|
|
1918
|
+
def eql?: (untyped other) -> bool
|
|
1919
|
+
def hash: () -> Integer
|
|
1920
|
+
def self.format_value: (untyped value) -> String
|
|
1921
|
+
|
|
1922
|
+
private
|
|
1923
|
+
|
|
1924
|
+
def deconstruct_attributes: () -> Hash[Symbol, untyped]
|
|
1925
|
+
def deconstructable_keys: () -> Array[Symbol]
|
|
1926
|
+
end
|
|
1927
|
+
|
|
1928
|
+
type expression = Literal | TemplateString | Variable | Reference | BinaryOp | UnaryOp | ArrayLiteral | ObjectLiteral | SetLiteral | ArrayComprehension | ObjectComprehension | SetComprehension | Every | Call
|
|
1929
|
+
type call_name = String | Variable | Reference
|
|
1930
|
+
type query_literal = QueryLiteral | SomeDecl
|
|
1931
|
+
type query = Array[query_literal]
|
|
1932
|
+
type object_term = [expression, expression]
|
|
1933
|
+
|
|
1934
|
+
class Literal < Base
|
|
1935
|
+
attr_reader value: untyped
|
|
1936
|
+
|
|
1937
|
+
def initialize: (value: untyped, ?location: Location?) -> void
|
|
1938
|
+
end
|
|
1939
|
+
|
|
1940
|
+
class StringLiteral < Literal
|
|
1941
|
+
attr_reader value: String
|
|
1942
|
+
|
|
1943
|
+
def initialize: (value: String, ?location: Location?) -> void
|
|
1944
|
+
end
|
|
1945
|
+
|
|
1946
|
+
class TemplateString < Base
|
|
1947
|
+
attr_reader parts: Array[untyped]
|
|
1948
|
+
|
|
1949
|
+
def initialize: (parts: Array[untyped], ?location: Location?) -> void
|
|
1950
|
+
end
|
|
1951
|
+
|
|
1952
|
+
class NumberLiteral < Literal
|
|
1953
|
+
attr_reader value: Numeric
|
|
1954
|
+
|
|
1955
|
+
def initialize: (value: Numeric, ?location: Location?) -> void
|
|
1956
|
+
end
|
|
1957
|
+
|
|
1958
|
+
class BooleanLiteral < Literal
|
|
1959
|
+
attr_reader value: bool
|
|
1960
|
+
|
|
1961
|
+
def initialize: (value: bool, ?location: Location?) -> void
|
|
1962
|
+
end
|
|
1963
|
+
|
|
1964
|
+
class NullLiteral < Literal
|
|
1965
|
+
attr_reader value: nil
|
|
1966
|
+
|
|
1967
|
+
def initialize: (?location: Location?) -> void
|
|
1968
|
+
end
|
|
1969
|
+
|
|
1970
|
+
class Variable < Base
|
|
1971
|
+
attr_reader name: String
|
|
1972
|
+
|
|
1973
|
+
def initialize: (name: String, ?location: Location?) -> void
|
|
1974
|
+
end
|
|
1975
|
+
|
|
1976
|
+
class Reference < Base
|
|
1977
|
+
attr_reader base: expression
|
|
1978
|
+
attr_reader path: Array[RefArg]
|
|
1979
|
+
|
|
1980
|
+
def initialize: (base: expression, path: Array[RefArg], ?location: Location?) -> void
|
|
1981
|
+
end
|
|
1982
|
+
|
|
1983
|
+
class RefArg < Base
|
|
1984
|
+
attr_reader value: untyped
|
|
1985
|
+
|
|
1986
|
+
def initialize: (value: untyped, ?location: Location?) -> void
|
|
1987
|
+
end
|
|
1988
|
+
|
|
1989
|
+
class DotRefArg < RefArg
|
|
1990
|
+
def initialize: (value: untyped, ?location: Location?) -> void
|
|
1991
|
+
end
|
|
1992
|
+
|
|
1993
|
+
class BracketRefArg < RefArg
|
|
1994
|
+
def initialize: (value: untyped, ?location: Location?) -> void
|
|
1995
|
+
end
|
|
1996
|
+
|
|
1997
|
+
class BinaryOp < Base
|
|
1998
|
+
OPERATORS: Array[Symbol]
|
|
1999
|
+
|
|
2000
|
+
attr_reader operator: Symbol
|
|
2001
|
+
attr_reader left: expression
|
|
2002
|
+
attr_reader right: expression
|
|
2003
|
+
|
|
2004
|
+
def initialize: (operator: Symbol, left: expression, right: expression, ?location: Location?) -> void
|
|
2005
|
+
|
|
2006
|
+
private
|
|
2007
|
+
|
|
2008
|
+
def validate_operator: () -> bool
|
|
2009
|
+
def validate_operator!: () -> void
|
|
2010
|
+
end
|
|
2011
|
+
|
|
2012
|
+
class UnaryOp < Base
|
|
2013
|
+
OPERATORS: Array[Symbol]
|
|
2014
|
+
|
|
2015
|
+
attr_reader operator: Symbol
|
|
2016
|
+
attr_reader operand: expression
|
|
2017
|
+
|
|
2018
|
+
def initialize: (operator: Symbol, operand: expression, ?location: Location?) -> void
|
|
2019
|
+
|
|
2020
|
+
private
|
|
2021
|
+
|
|
2022
|
+
def validate_operator: () -> bool
|
|
2023
|
+
def validate_operator!: () -> void
|
|
2024
|
+
end
|
|
2025
|
+
|
|
2026
|
+
class ArrayLiteral < Base
|
|
2027
|
+
attr_reader elements: Array[expression]
|
|
2028
|
+
|
|
2029
|
+
def initialize: (elements: Array[expression], ?location: Location?) -> void
|
|
2030
|
+
end
|
|
2031
|
+
|
|
2032
|
+
class ObjectLiteral < Base
|
|
2033
|
+
attr_reader pairs: Array[[expression, expression]]
|
|
2034
|
+
|
|
2035
|
+
def initialize: (pairs: Array[[expression, expression]], ?location: Location?) -> void
|
|
2036
|
+
end
|
|
2037
|
+
|
|
2038
|
+
class SetLiteral < Base
|
|
2039
|
+
attr_reader elements: Array[expression]
|
|
2040
|
+
|
|
2041
|
+
def initialize: (elements: Array[expression], ?location: Location?) -> void
|
|
2042
|
+
end
|
|
2043
|
+
|
|
2044
|
+
class ArrayComprehension < Base
|
|
2045
|
+
attr_reader term: expression
|
|
2046
|
+
attr_reader body: query
|
|
2047
|
+
|
|
2048
|
+
def initialize: (term: expression, body: query, ?location: Location?) -> void
|
|
2049
|
+
end
|
|
2050
|
+
|
|
2051
|
+
class ObjectComprehension < Base
|
|
2052
|
+
attr_reader term: object_term
|
|
2053
|
+
attr_reader body: query
|
|
2054
|
+
|
|
2055
|
+
def initialize: (term: object_term, body: query, ?location: Location?) -> void
|
|
2056
|
+
end
|
|
2057
|
+
|
|
2058
|
+
class SetComprehension < Base
|
|
2059
|
+
attr_reader term: expression
|
|
2060
|
+
attr_reader body: query
|
|
2061
|
+
|
|
2062
|
+
def initialize: (term: expression, body: query, ?location: Location?) -> void
|
|
2063
|
+
end
|
|
2064
|
+
|
|
2065
|
+
class Every < Base
|
|
2066
|
+
attr_reader key_var: Variable?
|
|
2067
|
+
attr_reader value_var: Variable
|
|
2068
|
+
attr_reader domain: expression
|
|
2069
|
+
attr_reader body: query
|
|
2070
|
+
|
|
2071
|
+
def initialize: (value_var: Variable, domain: expression, body: query, key_var: Variable?, ?location: Location?) -> void
|
|
2072
|
+
end
|
|
2073
|
+
|
|
2074
|
+
class QueryLiteral < Base
|
|
2075
|
+
attr_reader expression: expression
|
|
2076
|
+
attr_reader with_modifiers: Array[WithModifier]
|
|
2077
|
+
|
|
2078
|
+
def initialize: (expression: expression, ?with_modifiers: Array[WithModifier], ?location: Location?) -> void
|
|
2079
|
+
end
|
|
2080
|
+
|
|
2081
|
+
class SomeDecl < Base
|
|
2082
|
+
attr_reader variables: Array[Variable]
|
|
2083
|
+
attr_reader collection: expression?
|
|
2084
|
+
|
|
2085
|
+
def initialize: (variables: Array[Variable], ?collection: expression?, ?location: Location?) -> void
|
|
2086
|
+
end
|
|
2087
|
+
|
|
2088
|
+
class WithModifier < Base
|
|
2089
|
+
attr_reader target: expression
|
|
2090
|
+
attr_reader value: expression
|
|
2091
|
+
|
|
2092
|
+
def initialize: (target: expression, value: expression, ?location: Location?) -> void
|
|
2093
|
+
end
|
|
2094
|
+
|
|
2095
|
+
class Call < Base
|
|
2096
|
+
attr_reader name: call_name
|
|
2097
|
+
attr_reader args: Array[expression]
|
|
2098
|
+
|
|
2099
|
+
def initialize: (name: call_name, args: Array[expression], ?location: Location?) -> void
|
|
2100
|
+
end
|
|
2101
|
+
|
|
2102
|
+
class Module < Base
|
|
2103
|
+
attr_reader package: Package
|
|
2104
|
+
attr_reader imports: Array[Import]
|
|
2105
|
+
attr_reader rules: Array[Rule]
|
|
2106
|
+
|
|
2107
|
+
def initialize: (package: Package, imports: Array[Import], rules: Array[Rule], ?location: Location?) -> void
|
|
2108
|
+
end
|
|
2109
|
+
|
|
2110
|
+
class Package < Base
|
|
2111
|
+
attr_reader path: Array[String]
|
|
2112
|
+
|
|
2113
|
+
def initialize: (path: Array[String], ?location: Location?) -> void
|
|
2114
|
+
end
|
|
2115
|
+
|
|
2116
|
+
class Import < Base
|
|
2117
|
+
attr_reader path: Array[String] | String
|
|
2118
|
+
attr_reader alias: String?
|
|
2119
|
+
|
|
2120
|
+
def initialize: (path: Array[String] | String, ?alias_name: String?, ?location: Location?) -> void
|
|
2121
|
+
def alias_name: () -> String?
|
|
2122
|
+
end
|
|
2123
|
+
|
|
2124
|
+
class Rule < Base
|
|
2125
|
+
RULE_TYPE_LOOKUP: Array[Symbol]
|
|
2126
|
+
Definition: untyped
|
|
2127
|
+
|
|
2128
|
+
attr_reader name: String
|
|
2129
|
+
attr_reader head: untyped
|
|
2130
|
+
attr_reader body: untyped
|
|
2131
|
+
attr_reader default_value: untyped
|
|
2132
|
+
attr_reader else_clause: untyped
|
|
2133
|
+
|
|
2134
|
+
def initialize: (name: String, ?head: untyped, ?body: untyped, ?default_value: untyped, ?else_clause: untyped, ?location: Location?) -> void
|
|
2135
|
+
def complete?: () -> bool
|
|
2136
|
+
def partial_set?: () -> bool
|
|
2137
|
+
def partial_object?: () -> bool
|
|
2138
|
+
def function?: () -> bool
|
|
2139
|
+
|
|
2140
|
+
private
|
|
2141
|
+
|
|
2142
|
+
def rule_type: () -> Symbol?
|
|
2143
|
+
def resolve_rule_type: () -> (String | Symbol | nil)
|
|
2144
|
+
def type_from_object: () -> untyped
|
|
2145
|
+
def type_from_hash: () -> untyped
|
|
2146
|
+
attr_reader definition: untyped
|
|
2147
|
+
end
|
|
2148
|
+
end
|
|
2149
|
+
end
|
|
2150
|
+
end
|