fix: remove negative number literal parsing in lexer and update tests for unary minus precedence

The lexer previously treated a leading minus sign followed by a digit as a single negative number token, which caused incorrect parsing of expressions like `1-1` and broke method calls on negative numbers. This change removes that special case, making the minus sign always a separate token, and updates all test expectations to use explicit parentheses for negative number method calls.
This commit is contained in:
Bob Nystrom
2015-01-09 15:00:12 +00:00
7 changed files with 34 additions and 35 deletions
+1 -8
View File
@@ -752,14 +752,7 @@ static void nextToken(Parser* parser)
return;
case '-':
if (isDigit(peekChar(parser)))
{
readNumber(parser);
}
else
{
makeToken(parser, TOKEN_MINUS);
}
makeToken(parser, TOKEN_MINUS);
return;
case '|':