Skip to content

Lexer: Unicode line separators are whitespace that ends a // comment - #16

Merged
revarbat merged 1 commit into
mainfrom
feat/unicode-line-separators
Oct 26, 2026
Merged

revarbat merged 1 commit into
mainfrom
feat/unicode-line-separators

Conversation

@revarbat

Copy link
Copy Markdown
Member

Refs BelfrySCAD/BelfrySCAD#949

The lexer now accepts U+2028 LINE SEPARATOR, U+2029 PARAGRAPH SEPARATOR and U+0085 NEXT LINE as whitespace. Before this, each was a syntax error ("unexpected character"). A // comment also ends at one of them, so code that appears on its own line after one runs, rather than being swallowed by the comment.

They don't advance the line counter. BelfrySCAD's editor numbers lines by block, and a U+2028 sits inside a block, so line and column numbers after one still match the editor's. Byte offsets are unchanged either way.

Qt's editor types U+2028 for Shift+Enter. BelfrySCAD#950 stops that, but files that already contain one will now parse. OpenSCAD's lexer rejects all three characters, so this is a leniency on our side, and OpenSCAD doesn't accept them.

The new test, LexicalWhitespace.UnicodeLineSeparatorsEndACommentButNotALine, fails without the lexer change. All 670 tests pass.

🤖 Generated with Claude Code

Qt's editor types U+2028 LINE SEPARATOR for Shift+Enter and shows it as
a new line, but the lexer rejected it as an unexpected character
(BelfrySCAD #949). The three Unicode line separators are now whitespace,
and a line comment ends at one, so what follows it on screen is code.

They do not advance the line counter: BelfrySCAD's editor numbers lines
by block and a U+2028 sits inside one, so lines and columns after it
still match the editor's. Byte offsets are untouched either way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@revarbat
revarbat merged commit 3442a82 into main Oct 26, 2026
3 checks passed
@revarbat
revarbat deleted the feat/unicode-line-separators branch October 26, 2026 15:58
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