Skip to content

Commit 1d80448

Browse files
committed
fix(isc): retry the DSL grammar when the artifact misparses a source
The shipped isc.artifact.json rejects lowercase system codes that the Ruby-DSL grammar accepts (acadsin-zho-Hani-Latn-2002.isc) — one bad map broke every spec that loads the corpus in CI. The runtime now prefers the artifact and retries through the DSL on ParseFailed; the artifact recompile via the parsanol toolchain remains the upstream fix.
1 parent c40ac81 commit 1d80448

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎lib/interscript/isc/parser.rb‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ def parse_with_callbacks(source, filename: nil)
3434
parse_with_artifact(source)
3535
rescue ArtifactUnavailable
3636
parse_with_dsl(source)
37+
rescue Parsanol::ParseFailed
38+
# A stale or buggy artifact must not fail a source the DSL
39+
# grammar accepts (the acadsin-zho-Hani-Latn-2002 incident:
40+
# the shipped artifact rejected lowercase system codes the
41+
# DSL handles). Re-parse through the Ruby grammar; the
42+
# artifact recompile remains the real fix upstream.
43+
parse_with_dsl(source)
3744
end
3845
Normalizer.normalize(tree)
3946
rescue Parsanol::ParseFailed => e

‎spec/interscript/isc/parser_spec.rb‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,19 @@
8080
expect(artifact_tree).to eq(dsl_tree)
8181
end
8282

83+
it "retries the DSL grammar when the artifact misparses a corpus map" do
84+
skip "parsanol lacks PARG (needs >= 1.3.61)" unless Interscript::Isc::Parser.respond_to?(:artifact)
85+
86+
# Regression guard: a stale/buggy artifact must not fail a source the
87+
# DSL grammar handles (acadsin-zho-Hani-Latn-2002.isc did exactly
88+
# this — artifact rejected lowercase system codes, DSL accepted).
89+
allow(described_class).to receive(:parse_with_artifact)
90+
.and_raise(Parsanol::ParseFailed.new("artifact mismatch"))
91+
tree = described_class.parse(src)
92+
doc = Interscript::Isc::DocumentBuilder.build(tree, filename: "test.isc")
93+
expect(doc[:systemCode]).to eq("s")
94+
end
95+
8396
it "falls back to the DSL grammar when the artifact cannot load" do
8497
skip "parsanol lacks PARG (needs >= 1.3.61)" unless Interscript::Isc::Parser.respond_to?(:artifact)
8598

0 commit comments

Comments
 (0)