feat(dsl): scena-check, the DSL checking CLI (p7-s5) - #104
Merged
Conversation
Adds `tools/scena-check`: load a .osc file, follow its imports, report what the checker finds. A thin consumer of `scena::dsl::check_file` with no language semantics of its own, linking the DSL frontend alone — checking a DSL file needs no engine, no road backend and no XML frontend. Options: -I/--search-path (repeatable, searched in order), --no-standard-library, --strict, --quiet. Exit codes follow scena-run's convention and the Status model's own split: 0 ok, 2 usage, 3 the source did not check, 4 the input could not be read. A defect in the content and the host handing us something unusable are different failures, and a build script can act on the difference. Diagnostics print in the same one-per-line shape scena-run uses, so a script that parses one tool's output can parse the other's. A DSL diagnostic prints no bracketed rule id, because the DSL standard defines none — the section reference in the message is the citation, and a test pins that no rule id appears. Fixes a diagnostic gap the CLI made obvious: resolver and expression diagnostics carried a line and column but no file. A Program spans every file its root imported, so a line number alone does not locate anything — a diagnostic from an imported file was indistinguishable from one in the file you passed. `Scope` and `ExpressionContext` now carry the source file, the three resolver emitters and expression typing's `fail` stamp it, and `dsl_import_test.cpp` pins that a two-file program attributes each diagnostic to the file it came from. Tests drive the built binary as a subprocess, reusing scena-run's harness with its portability fixes intact: the cmd.exe outer-quote wrapping and the POSIX exit-status unpacking. 18 cases covering the exit codes, the diagnostic shape and position, search-path ordering, module and file imports, --strict, --quiet, --no-standard-library, the usage errors, multi-diagnostic recovery, and determinism of the output. Docs: docs/user-guide/scena-check.md and an index entry. 1304 gtest (+19), 184 pytest. Refs #43
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First half of slice 43i.
tools/scena-check— load a.oscfile, follow itsimports, report what the checker finds.
A thin consumer of
scena::dsl::check_filewith no language semantics of itsown. It links the DSL frontend alone: checking a DSL file needs no engine, no
road backend and no XML frontend.
Exit codes
0ok,2usage,3the source did not check,4the input could not beread.
3and4are deliberately distinct. Scena's status model separates a defectin the content from the host handing the library something unusable, and the
exit codes follow that line — a file full of type errors is the scenario's
problem, an unreadable path is the invocation's, and a build script can branch
on which.
A diagnostic gap the CLI made obvious
Resolver and expression diagnostics carried a line and a column but no file.
That is fine inside a test that checks one string, and useless in a checker: a
Programspans every file its root imported, so a diagnostic from an importedfile was indistinguishable from one in the file you passed.
ScopeandExpressionContextnow carry the source file; the three resolveremitters and expression typing's
failstamp it.dsl_import_test.cppgainsADiagnosticNamesTheFileItCameFrom, which builds a two-file program with anerror in each and asserts both that no diagnostic has an empty file and that
each names the right one.
This is why the slice was worth splitting — the gap is only visible once
something has to print the diagnostics for a human.
Tests
18 subprocess cases, reusing
scena-run's harness with its portability fixesintact: the
cmd.exeouter-quote wrapping and the POSIX exit-status unpacking.They cover every exit code, the diagnostic shape and position, search-path
ordering (two copies of a module, resolved differently depending on
-Iorder), file and module imports,
--strictpromoting a warning,--quietstaying silent while still exiting non-zero,
--no-standard-library, the threeusage errors, multi-diagnostic recovery, and byte-identical output across two
runs.
One pins something specific to this frontend: a DSL diagnostic prints no
bracketed rule id, because the DSL standard defines no
asam.net:ruleidentifiers. The section reference in the message is the citation.
1304 gtest (+19: 18 CLI + 1 import), 184 pytest.
Docs:
docs/user-guide/scena-check.mdand an index entry.What is left on #43
43i-2: the C ABI
scn_check_dsl, the Pythoncheck_dsl, the parity auditupdate and an example. That PR carries
Closes #43.Refs #43