Skip to content

Bump the parser submodule: StringLiteral source spans - #76

Merged
revarbat merged 2 commits into
mainfrom
bump-parser-string-spans
Aug 7, 2026
Merged

Bump the parser submodule: StringLiteral source spans#76
revarbat merged 2 commits into
mainfrom
bump-parser-string-spans

Conversation

@revarbat

@revarbat revarbat commented Aug 6, 2026

Copy link
Copy Markdown
Member

Picks up openscad_cpp_parser#3.

A StringLiteral's position spanned only its closing quote, and so did any node wrapping one — a PositionalArgument, a vector element — because a string is matched by several lexer rules and YY_USER_ACTION resets tokenStart on each of them.

a = "txt";        span was '"'   now '"txt"'
f("x,y", b);      argument span '"'   now '"x,y"'
x = ["a,b","c"];  element spans '"'   now '"a,b"' / '"c"'

Why it mattered

parse_ast() consumers slicing source by those offsets could land inside string content. BelfrySCAD's reformatter rewrote a comma inside "h,l,height,length" in BOSL2's isosurface.scad, silently changing the string's value. It needed a guard skipping any argument list with an unbalanced quote span — this bump makes that guard unnecessary.

Verification

  • 1399/1399 tests pass
  • Spans confirmed correct through the Python parse_ast API, including escapes, empty strings and multi-line strings
  • Against BelfrySCAD: the separator-spacing pass now covers 74 of 97 corpus files (up from 73 — the extras are exactly the ones its quote guard had been skipping), with 0 structural changes
  • BelfrySCAD's 653 tests and the 145-case differential sweep against real OpenSCAD are unchanged

Minor bump (0.17.0 → 0.18.0): node positions change, which anything using them will see.

🤖 Generated with Claude Code

Picks up openscad_cpp_parser#3. A StringLiteral's position spanned only
its closing quote, and so did any node wrapping one -- a
PositionalArgument, a vector element -- because a string is matched by
several lexer rules and YY_USER_ACTION resets tokenStart on each.

parse_ast() consumers slicing source by those offsets could land inside
string CONTENT. BelfrySCAD's reformatter rewrote a comma inside
"h,l,height,length" in BOSL2's isosurface.scad, silently changing the
string's value; it needed a guard skipping any argument list with an
unbalanced quote span, which this makes unnecessary.

    a = "txt";          span was '"'   now '"txt"'
    f("x,y", b);        argument span '"'   now '"x,y"'

1399/1399 tests pass. Verified through the Python API too, and against
BelfrySCAD: its separator-spacing pass now covers 74 of 97 corpus files
(up from 73, the extras being the ones its quote guard had to skip)
with no structural changes.

Minor bump: node positions change, which anything using them will see.
@revarbat revarbat closed this Aug 6, 2026
@revarbat revarbat reopened this Aug 6, 2026
The push that opened #76 landed while GitHub Actions was still
recovering from an outage and fired no workflow run at all.
@revarbat
revarbat merged commit ee179d1 into main Aug 7, 2026
3 of 6 checks passed
@revarbat
revarbat deleted the bump-parser-string-spans branch August 7, 2026 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant