Repository navigation
state_exec: grammar spec, conformance cases and parse corpus (grammar P0) - #644
Merged
Merged
Conversation
… P0) Declare the state_exec s-expression grammar in docs/STATE_EXEC_GRAMMAR.md (W3C EBNF, Unicode source rules, literal tables, and a table of every intentional change from the hand-written parser, tagged by phase P2-P4). The parser itself is unchanged; later phases build it from this grammar. state_exec_grammar_test tags each case with the phase it holds from: landed cases must hold, pending cases must still differ, the doc's EBNF must be closed, and every production needs a case. state_exec_corpus_test pins how the 597 DSL scripts the repo carries parse today (state_exec_corpus/, regenerated with gen_state_exec_corpus.py and CVC_UPDATE_GOLDENS=1). Also correct parser.h (no quasiquote) and the developer guide (false and #f read as nil, bytes literals exist).
Spec only: parse_options::max_depth on parse()/parse_all()/parser and execute_options::max_parse_depth for submitted scripts, both from P2. Records why the limit exists (the reader recurses on the native stack; the evaluators are stackless) and the corpus's real depths (max 13, median 2).
Spec only. max_depth resolves from state_exec.schedulers.<id>.parser.max_depth, then state_exec.defaults.parser.max_depth, then 256, matching scheduler::load_settings(); parse_options remains for callers without a tree. Drops the execute_options::max_parse_depth idea so the tree is the single source.
This was referenced Oct 17, 2026
…/state-exec-grammar-p0 # Conflicts: # src/cvc/tests/CMakeLists.txt
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.
Phase P0 of the state_exec grammar work: write the grammar down, and pin today's parser against it. No parser behaviour changes in this PR. Later phases build the parser from this declaration:
The spec:
docs/STATE_EXEC_GRAMMAR.md0x/0o/0band#x/#o/#b, with_separators. Overflow is an error.+inf.0/-inf.0/+nan.0.\NNNescapes, plus\a \b \f \v.r"…"/r#"…"#and raw bytesbr"…"., [ \ ] ` { | }.nests 13 levels). Like the scheduler's settings, it is configured on the state tree:
state_exec.schedulers.<id>.parser.max_depth, thenstate_exec.defaults.parser.max_depth,then 256. A follow-up PR implements it.
)reads as a symbol today;parse("1 2")drops the2;0x1Freads as the double31.0;inf/nancan't be symbols;Tests
state_exec_grammar_testhas 75 cases, each tagged with the phase it holds from: 32 hold today, and 23, 11 and 9 belong to P2, P3 and P4. It checks that:kLandedPhase = 0);state_exec_corpus_testparses 597 DSL scripts and compares each parse withstate_exec_corpus/expected.txt. The scripts come from the.arifields, the docs'lispblocks, balanced C++ string literals in state_exec/ariadne sources, and the pycvc tests. A later phase can't change how an existing script reads without that file changing in the same PR.gen_state_exec_corpus.py(needs PyYAML), thenCVC_UPDATE_GOLDENS=1..gitattributes.state_exec_grammar_dump.h, an exact dump that tags every value with its type. They don't useto_string, which is lossy and changes in P5.Audit
{...}dict-literal sketch indocs/roadmap/STATE_BINARY_STREAMING.md, which no parser implements.\0followed by a digit, an unknown escape,inf/nan, radix-like tokens, or multi-formon:programs. So the C-style octal escapes break nothing.Docs
parser.hno longer claims quasiquote support.falseand#fread as nil, and lists bytes literals.Test (local, Windows MSVC 14.38 Release, cvcpkg prefix)
state_exec_grammar_test4/4,state_exec_corpus_test1/1,state_exec_parser_test30/30 andstate_exec_unicode_test23/23. The new tests also pass underctest.check_test_targets.pyis OK, and clang-format 18 is clean.