Skip to content

Commit 7664ae0

Browse files
authored
Merge pull request #785 from interscript/feat/parg-complete
fix: any_character is the Stdlib any-char alias — odni-uzb green (38→32)
2 parents e8a7a85 + 837c97e commit 7664ae0

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

‎lib/interscript/isc/transform.rb‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class Transform < Parsanol::Transform
2323
rule(identifier: simple(:i)) { i.to_s }
2424

2525
rule(none: simple(:_)) { Items::None.new }
26+
# any_character is the Stdlib any-char alias (".") — without this
27+
# rule the fragment stringified to "any_charany_character".
28+
rule(any_char: simple(:_)) { Items::AliasRef.new("any_character") }
2629
rule(primitive: simple(:p)) { Items::Primitive.new(p.to_s) }
2730
rule(function: simple(:f)) { Items::Function.new(f.to_s) }
2831
rule(alias: {identifier: simple(:n), qualified_name: simple(:q)}) {

‎spec/interscript/isc/node_adapter_spec.rb‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,3 +395,29 @@ def parse_and_adapt(src)
395395
expect(calls).to eq(%i[decompose compose])
396396
end
397397
end
398+
399+
RSpec.describe "NodeAdapter any_character" do
400+
it "converts to the Stdlib any-character alias, not a stringified fragment" do
401+
src = <<~ISC
402+
system "t:a-b:C-D:1" {
403+
metadata { name "T" }
404+
stage main {
405+
sub {
406+
from capture(any_character) + ref(1)
407+
to ref(1)
408+
}
409+
}
410+
}
411+
ISC
412+
node = Interscript::Isc::NodeAdapter.to_interscript_node(
413+
Interscript::Isc::DocumentBuilder.build(Interscript::Isc::Parser.parse(src))
414+
)
415+
inner = node.stages[:main].children.first.from.children.first.data
416+
expect(inner).to be_a(Interscript::Node::Item::Alias)
417+
expect(inner.name).to eq(:any_character)
418+
interp = Interscript::Interpreter.new
419+
interp.compile(node)
420+
# The geminate collapse: any char followed by itself collapses to one.
421+
expect(interp.call("чч")).to eq("ч")
422+
end
423+
end

0 commit comments

Comments
 (0)