From e30cfc6cf4b56da2e2c76bcefc3c56d8f748d001 Mon Sep 17 00:00:00 2001 From: Timerix22 Date: Mon, 25 Dec 2023 21:11:13 +0600 Subject: [PATCH] scientific notation lexing --- src/Lexer.fu | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Lexer.fu b/src/Lexer.fu index 493bfb1..3b7d6a2 100644 --- a/src/Lexer.fu +++ b/src/Lexer.fu @@ -48,10 +48,19 @@ class Lexer { case '/': AddStaticToken(TokDiv); break; case '+': AddStaticToken(TokAdd); break; case '-': - if(i != 0 && ExprStr[i-1] != '(') + // if '-' is not the first char and previous char isn't '(' or 'e' or 'E' + if(i != 0 && ExprStr[i-1] != '(' + && ExprStr[i-1] != 'e' && ExprStr[i-1] != 'E') AddStaticToken(TokSub); // else '-' is a part of numeric expression break; + case 'e': + case 'E': + // if token starts with 'E' it is a literal + if(i == tokBegin) + tokType = Token.Type_Literal; + // else 'E' is a part of literal or number (sientific notation) + break; // try end token and skip current char case ' ': case '\t': case '\n': case '\r': TryEndToken();