Expose the parser's strict-comma mode: --strict-commas, strict_commas= - #158
Merged
Merged
Conversation
Evaluator half of BelfrySCAD#362. Bumps the parser submodule to v1.2.0 (openscad_cpp_parser#9), which added StrictCommaScope, and hands it to the three places that can ask for it: openscad-cpp-evaluator --strict-commas Evaluator.evaluate(path, vp, strict_commas=True) (Python) oscad::StrictCommaScope (C++, from the parser) A trailing comma in a CALL ARGUMENT list or a let/for ASSIGNMENT list becomes a syntax error, as OpenSCAD 2021.01 had it. A list literal's and a parameter declaration's are untouched: 2021.01 accepted both, and rejecting them would fail files it loads. See the parser PR for the measured table. The scope is constructed on the thread that parses, not set from Python before the call. It is thread-local in the parser, and a host evaluating on a worker thread -- which BelfrySCAD does for every render -- would otherwise set the mode on the main thread and parse on another, silently getting nothing. Costs nothing here and removes the trap outright. Two binding tests, because the facade and the nanobind binding restate the same parameter list by hand and the LAST argument added this way was silently dropped by the facade (see test_export_model_facade_accepts_split_components, added when that happened): one that the flag reaches the parser at all, one that it does not leak into the next evaluation. 1830 C++ tests and 34 Python binding tests pass. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AzS79GLeG7LpYB6KjgDbi1
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.
Evaluator half of BelfrySCAD#362. Bumps the parser submodule to v1.2.0 (openscad_cpp_parser#9), which added
StrictCommaScope, and hands it to the three places that can ask for it:A trailing comma in a call argument list or a let/for assignment list becomes a syntax error, as OpenSCAD 2021.01 had it. A list literal's and a parameter declaration's are untouched — 2021.01 accepted both, and rejecting them would fail files it loads. The measured table is in the parser PR.
The scope is constructed on the parsing thread
Not set from Python before the call. It's thread-local in the parser, and a host that evaluates on a worker thread — which BelfrySCAD does for every render — would otherwise set the mode on the main thread, parse on another, and silently get nothing. Costs nothing here and removes the trap outright.
Two binding tests, for a specific reason
The Python facade and the nanobind binding restate the same parameter list by hand, and the last argument added this way was silently dropped by the facade —
split_components, which no C++ test could see because the C++ suite never enters Python. That's whattest_export_model_facade_accepts_split_componentsexists for.So: one test that the flag reaches the parser at all, and one that it doesn't leak into the next evaluation.
1830 C++ tests and 34 Python binding tests pass.
Verified end to end through the CLI:
--strict-commascube(1,);y = let(x=1,) x;a = [2,4,];🤖 Generated with Claude Code
https://claude.ai/code/session_01AzS79GLeG7LpYB6KjgDbi1