Handle new lines

This commit is contained in:
2026-08-01 19:30:49 +10:00
parent ad9254b975
commit 476b401e55
2 changed files with 5 additions and 1 deletions

View File

@@ -3,7 +3,7 @@
#include <iostream> #include <iostream>
int main() { int main() {
Solstice::Lexer lexer{"(2 + 2) / 5"}; Solstice::Lexer lexer{"(2 + 2) / 5\n(1, 2, 3)"};
auto lexed = lexer.lex(); auto lexed = lexer.lex();
Solstice::Parser parser{lexed}; Solstice::Parser parser{lexed};

View File

@@ -323,6 +323,10 @@ namespace Solstice {
case TT::OpenParen: case TT::OpenParen:
return parseOpenParen(); return parseOpenParen();
case TT::NewLine:
// ignore new line
return parseOneNode(precedence);
// stuff that causes errors // stuff that causes errors
case TT::CloseParen: case TT::CloseParen:
throw std::runtime_error("Extra closing paren"); throw std::runtime_error("Extra closing paren");