Skip to content

Commit e8a7a85

Browse files
authored
Merge pull request #784 from interscript/feat/parg-complete
fix: decompose is not compose — var-kor green (sweep tail 132→38)
2 parents f2d29c1 + e7d3cc3 commit e8a7a85

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

‎lib/interscript/isc/document_builder.rb‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,10 @@ def extract_stage_items(n)
263263
elsif n[:separate]
264264
[{kind: :separate, separator: n[:separator] ? materialize(n[:separator]) : nil}]
265265
elsif n[:compose]
266-
[{kind: :compose}]
266+
# The grammar captures both `compose` and `decompose` under this
267+
# key — the value decides the directive. Dropping it compiled
268+
# every decompose as NFC compose.
269+
[{kind: n[:compose].to_s.to_sym}]
267270
elsif n[:case]
268271
item = {kind: :string_case, op: n[:case].to_s}
269272
item[:kwargs] = extract_kwargs(n[:case_kwargs]) if n[:case_kwargs]

‎spec/interscript/isc/node_adapter_spec.rb‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,3 +373,25 @@ def parse_and_adapt(src)
373373
expect(node.name).to eq("test-map")
374374
end
375375
end
376+
377+
RSpec.describe "NodeAdapter compose vs decompose" do
378+
it "keeps decompose distinct from compose" do
379+
src = <<~ISC
380+
system "t:a-b:C-D:1" {
381+
metadata { name "T" }
382+
stage main {
383+
sub "a" "b"
384+
decompose
385+
compose
386+
}
387+
}
388+
ISC
389+
node = Interscript::Isc::NodeAdapter.to_interscript_node(
390+
Interscript::Isc::DocumentBuilder.build(Interscript::Isc::Parser.parse(src))
391+
)
392+
calls = node.stages[:main].children.select { |c| c.is_a?(Interscript::Node::Rule::Funcall) }.map(&:name)
393+
# The grammar captures both directives under :compose; the builder must
394+
# read the value or decompose compiles as NFC compose.
395+
expect(calls).to eq(%i[decompose compose])
396+
end
397+
end

0 commit comments

Comments
 (0)