Skip to content

Commit 9302d2e

Browse files
committed
feat(A4): adopt the strict parse — stray identifiers are a parse error
The batch-4 hazard (stray identifiers silently no-op — a typo'd map is silently wrong) is closed: the corpus gate passed (295/295 strict-clean after maps#207's stray-'s' fix), so comment_item no longer consumes bare identifiers. The batch-4/5 vectors flip accordingly: - stray identifiers now raise Isc::ParseError (was: silent no-op) - is likewise rejected — the strict parse revealed it only ever executed by accident (noop + the case directive). The sanctioned spelling is the bare stage directive, which the vector now pins. Also fixes the run_rule documentation gap: stdlib functions are stage directives, never run targets.
1 parent 69467dd commit 9302d2e

2 files changed

Lines changed: 20 additions & 13 deletions

File tree

‎lib/interscript/isc/grammar/concerns/stages.rb‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ module Stages
2525
whitespace?
2626
end
2727

28-
# Comments and stray identifiers are silently consumed.
28+
# Comments are consumed; stray identifiers are a parse error
29+
# (WO87/A4 strict-parse ruling: the corpus is 295/295 strict-clean,
30+
# so a typo'd map can no longer silently no-op).
2931
rule(:comment_item) do
30-
(str("#") >> (str("\n").absent? >> any).repeat).as(:comment) |
31-
identifier.as(:noop)
32+
(str("#") >> (str("\n").absent? >> any).repeat).as(:comment)
3233
end
3334

3435
# Bare rule directly in a stage body (not wrapped in sequence/parallel).

‎spec/isc/semantics_spec.rb‎

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,17 @@ def system_map(id, body)
228228
ISC
229229
end
230230

231-
it "rules: run <stdlib-name> dispatches the stdlib function" do
232-
with_map("tst-fn-1.isc", system_map(51, "stage main { run downcase }")) do
231+
it "rules: stdlib string functions are stage DIRECTIVES (downcase), not run targets" do
232+
# The strict parse revealed `run downcase` only ever worked by
233+
# accident (noop + case-directive). The sanctioned spelling is the
234+
# bare directive.
235+
with_map("tst-fn-1.isc", system_map(51, "stage main { downcase }")) do
233236
expect(Interscript.transliterate("tst-fn-1", "AbC")).to eq("abc")
234237
end
238+
with_map("tst-fn-1b.isc", system_map(51, "stage main { run downcase }")) do
239+
expect { Interscript.transliterate("tst-fn-1b", "AbC") }
240+
.to raise_error(Interscript::Isc::ParseError)
241+
end
235242
end
236243

237244
it "rules: stage-level case directives run at their position, on the whole string" do
@@ -249,15 +256,14 @@ def system_map(id, body)
249256
end
250257
end
251258

252-
it "rules: stray identifiers are consumed as no-ops — pinned as a hazard" do
253-
# HAZARD (A4 follow-up): `run nosuchfunction` drops BOTH identifiers
254-
# at parse time and the stage becomes empty — a typo'd map is
255-
# silently wrong. Ruled normative-for-now (legacy .imp corpus
256-
# tolerance, grammar/concerns/stages.rb comment_item); the stricter
257-
# parse is an open item tracked in the IS-1 v2 text, gated on a
258-
# clean parse of the full 293-map corpus across all three compilers.
259+
it "rules: stray identifiers are a PARSE ERROR (the strict-parse ruling, A4 adopted)" do
260+
# The batch-4 hazard (silent no-op) is CLOSED: the corpus gate
261+
# passed (295/295 strict-clean after the odni-prs stray-'s' fix,
262+
# maps#207), so the grammar rejects stray identifiers — a typo'd
263+
# map fails loudly instead of being silently wrong.
259264
with_map("tst-fn-4.isc", system_map(54, "stage main { run nosuchfunction parallel { sub { from \"a\" to \"b\" } } }")) do
260-
expect(Interscript.transliterate("tst-fn-4", "a")).to eq("b")
265+
expect { Interscript.transliterate("tst-fn-4", "a") }
266+
.to raise_error(Interscript::Isc::ParseError)
261267
end
262268
end
263269
end

0 commit comments

Comments
 (0)