kumi-parser 0.0.23 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CLAUDE.md +1 -1
- data/lib/kumi/parser/direct_parser.rb +16 -15
- data/lib/kumi/parser/version.rb +1 -1
- data/lib/kumi/text_schema.rb +8 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb3b86394edb12c3c7033ca85d91f84e0945289c384f7a9717ca8c1ce3965432
|
4
|
+
data.tar.gz: b06faae267e651a8440e0218cc587be32c0f9de2a81aef27661198976dfebec1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d89bc307ef6d89c11adce650bc9500cddea0a0fa3e487212d9d483ca921c23839a6c5f2fcd9cae396d497e1e22119a414802624c35de8898db4b5d3247186dbc
|
7
|
+
data.tar.gz: d601d7b9aa7622552dd7bea123ded066bbc7ce57b3bb967a5355ce66d55ead08d0e3fe5553151198469fec7d4a7fd11d1fe6389b787df067b06ee559da9f8313
|
data/CLAUDE.md
CHANGED
@@ -285,7 +285,7 @@ module Kumi
|
|
285
285
|
Kumi::Syntax::ValueDeclaration.new(
|
286
286
|
name_token.value,
|
287
287
|
expression,
|
288
|
-
hints:{inline: true},
|
288
|
+
hints: { inline: true },
|
289
289
|
loc: let_token.location
|
290
290
|
)
|
291
291
|
end
|
@@ -361,6 +361,7 @@ module Kumi
|
|
361
361
|
# Pratt parser for expressions
|
362
362
|
def parse_expression(min_precedence = 0)
|
363
363
|
left = parse_primary_expression
|
364
|
+
left = parse_postfix_chain(left)
|
364
365
|
skip_comments_and_newlines
|
365
366
|
|
366
367
|
while current_token.operator? && current_token.precedence >= min_precedence
|
@@ -381,12 +382,25 @@ module Kumi
|
|
381
382
|
[left, right],
|
382
383
|
loc: operator_token.location
|
383
384
|
)
|
385
|
+
left = parse_postfix_chain(left)
|
384
386
|
skip_comments_and_newlines
|
385
387
|
end
|
386
388
|
|
387
389
|
left
|
388
390
|
end
|
389
391
|
|
392
|
+
def parse_postfix_chain(base)
|
393
|
+
skip_comments_and_newlines
|
394
|
+
while current_token.type == :lbracket
|
395
|
+
expect_token(:lbracket)
|
396
|
+
index_expr = parse_expression
|
397
|
+
expect_token(:rbracket)
|
398
|
+
base = Kumi::Syntax::CallExpression.new(:at, [base, index_expr], loc: base.loc)
|
399
|
+
skip_comments_and_newlines
|
400
|
+
end
|
401
|
+
base
|
402
|
+
end
|
403
|
+
|
390
404
|
def parse_primary_expression
|
391
405
|
token = current_token
|
392
406
|
|
@@ -399,11 +413,8 @@ module Kumi
|
|
399
413
|
parse_function_sugar
|
400
414
|
|
401
415
|
when :identifier
|
402
|
-
|
403
416
|
if token.value == 'input' && peek_token.type == :dot
|
404
417
|
parse_input_reference
|
405
|
-
elsif peek_token.type == :lbracket
|
406
|
-
parse_array_access_reference
|
407
418
|
else
|
408
419
|
advance
|
409
420
|
Kumi::Syntax::DeclarationReference.new(token.value.to_sym, loc: token.location)
|
@@ -485,16 +496,6 @@ module Kumi
|
|
485
496
|
end
|
486
497
|
end
|
487
498
|
|
488
|
-
def parse_array_access_reference
|
489
|
-
name_token = expect_token(:identifier)
|
490
|
-
expect_token(:lbracket)
|
491
|
-
index_expr = parse_expression
|
492
|
-
expect_token(:rbracket)
|
493
|
-
|
494
|
-
base_ref = Kumi::Syntax::DeclarationReference.new(name_token.value.to_sym, loc: name_token.location)
|
495
|
-
Kumi::Syntax::CallExpression.new(:at, [base_ref, index_expr], loc: name_token.location)
|
496
|
-
end
|
497
|
-
|
498
499
|
def parse_function_sugar
|
499
500
|
sugar = current_token
|
500
501
|
advance # e.g. shift(...)
|
@@ -514,7 +515,7 @@ module Kumi
|
|
514
515
|
args, opts = parse_args_and_opts_inside_parens
|
515
516
|
end
|
516
517
|
# expect_token(:rparen)
|
517
|
-
Kumi::Syntax::CallExpression.new(fn_name_token.value, args, loc: fn_name_token.location
|
518
|
+
Kumi::Syntax::CallExpression.new(fn_name_token.value, args, opts, loc: fn_name_token.location)
|
518
519
|
end
|
519
520
|
|
520
521
|
def parse_kw_literal_value
|
data/lib/kumi/parser/version.rb
CHANGED
data/lib/kumi/text_schema.rb
CHANGED
@@ -7,25 +7,25 @@ module Kumi
|
|
7
7
|
# Text-based schema that extends Kumi::Schema with text parsing capabilities
|
8
8
|
class TextSchema
|
9
9
|
extend Kumi::Schema
|
10
|
-
|
10
|
+
|
11
11
|
# Create a schema from text using the same pipeline as Ruby DSL
|
12
12
|
def self.from_text(text, source_file: '<input>')
|
13
13
|
# Parse text to AST (same as RubyParser::Dsl.build_syntax_tree)
|
14
|
-
@
|
15
|
-
@__analyzer_result__ = Analyzer.analyze!(@
|
16
|
-
@__compiled_schema__ = Compiler.compile(@
|
14
|
+
@__kumi_syntax_tree__ = Kumi::TextParser.parse(text, source_file: source_file).freeze
|
15
|
+
@__analyzer_result__ = Analyzer.analyze!(@__kumi_syntax_tree__).freeze
|
16
|
+
@__compiled_schema__ = Compiler.compile(@__kumi_syntax_tree__, analyzer: @__analyzer_result__).freeze
|
17
17
|
|
18
|
-
Inspector.new(@
|
18
|
+
Inspector.new(@__kumi_syntax_tree__, @__analyzer_result__, @__compiled_schema__)
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
# Validate text schema
|
22
22
|
def self.valid?(text, source_file: '<input>')
|
23
23
|
Kumi::TextParser.valid?(text, source_file: source_file)
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
# Get validation diagnostics
|
27
27
|
def self.validate(text, source_file: '<input>')
|
28
28
|
Kumi::TextParser.validate(text, source_file: source_file)
|
29
29
|
end
|
30
30
|
end
|
31
|
-
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kumi-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kumi Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-10-
|
11
|
+
date: 2025-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parslet
|