scientific notation lexing
This commit is contained in:
parent
2a4f92fe35
commit
e30cfc6cf4
11
src/Lexer.fu
11
src/Lexer.fu
@ -48,10 +48,19 @@ class Lexer {
|
|||||||
case '/': AddStaticToken(TokDiv); break;
|
case '/': AddStaticToken(TokDiv); break;
|
||||||
case '+': AddStaticToken(TokAdd); break;
|
case '+': AddStaticToken(TokAdd); break;
|
||||||
case '-':
|
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);
|
AddStaticToken(TokSub);
|
||||||
// else '-' is a part of numeric expression
|
// else '-' is a part of numeric expression
|
||||||
break;
|
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
|
// try end token and skip current char
|
||||||
case ' ': case '\t': case '\n': case '\r':
|
case ' ': case '\t': case '\n': case '\r':
|
||||||
TryEndToken();
|
TryEndToken();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user