File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ) } ) {
Original file line number Diff line number Diff line change @@ -395,3 +395,29 @@ def parse_and_adapt(src)
395395 expect ( calls ) . to eq ( %i[ decompose compose ] )
396396 end
397397end
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
You can’t perform that action at this time.
0 commit comments