1
0
Fork 0
mirror of https://github.com/imjasonh/nescript synced 2026-07-10 01:37:45 +00:00

Parser: accept ; as optional statement separator

Newlines remain the primary separator, but \`;\` now lets short
statements share a line for readability:

    on frame {
        a += 1; b += 2
        if button.a { a -= 1; b -= 1 }
    }

Implementation: \`parse_block\` consumes any \`;\` tokens between
statements.

https://claude.ai/code/session_01W6eQFStA66EuMKHUFo2rx3
This commit is contained in:
Claude 2026-04-12 17:23:05 +00:00
parent f0264b124a
commit f95130346a
No known key found for this signature in database
2 changed files with 28 additions and 0 deletions

View file

@ -830,6 +830,13 @@ impl Parser {
let mut statements = Vec::new();
while *self.peek() != TokenKind::RBrace && *self.peek() != TokenKind::Eof {
statements.push(self.parse_statement()?);
// Allow optional `;` between statements for readability.
// Newlines are still the primary separator, but `;` lets
// users put short statements on the same line:
// `x += 1; y += 1`
while *self.peek() == TokenKind::Semicolon {
self.advance();
}
}
self.expect(&TokenKind::RBrace)?;