Repository navigation
strict_commas(): reject the trailing commas OpenSCAD 2021.01 rejected - #12
Merged
Merged
Conversation
Ports openscad_cpp_parser #9. Inside `with strict_commas():` a trailing comma in a call's arguments or a let/for/intersection_for assignment list is a syntax error, as in 2021.01; list literals, comprehensions and parameter declarations keep theirs, since 2021.01 accepted them. The two grammar rules carrying it (`arguments` and `assignments_expr` -- let is not a call) are rewritten for a second, lazily built parser. A context variable, like the C++ parser's thread-local scope, so no entry point grows a parameter: it nests, restores on exit even when the body raises, and keys every cache -- memory, resolved and disk -- so a strict parse is never served a lenient tree. CLI: --strict-commas. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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.
Ports openscad_cpp_parser #9: strict-commas mode.
The accept/reject table matches the one the C++ port measured against OpenSCAD 2021.01, case for case:
cube(1,),translate([0,0,0],),max(1, 2,),str("a","b",)[2, 4,]let(x=1, y=2,),for (i=[0:2],),intersection_for(i=[0:1],)[for (i=[0:2]) i,],[each [1,2],]module m(a, b,),function f(a, b,)argumentsandassignments_expr(letisn't a call in this grammar). They are rewritten for a second Lark parser that is built lazily on first strict use.contextvarscontext manager rather than a parameter on every entry point, the Python counterpart of the C++ thread-localStrictCommaScope. It nests and restores on exit, including when the body raises.openscad-lalr --strict-commas.🤖 Generated with Claude Code