1
0
Fork 0

Token: Add TOK_Minus and fix negative numbers

master
Marrub 2016-11-21 00:58:32 -05:00
parent 52d431acb9
commit 07bf122fdc
2 changed files with 8 additions and 1 deletions

View File

@ -22,6 +22,7 @@ Lth_X(Number)
Lth_X(Space ) Lth_X(Space )
Lth_X(String) Lth_X(String)
Lth_X(Minus ) // -
Lth_X(Dot ) // . Lth_X(Dot ) // .
Lth_X(Equals) // = Lth_X(Equals) // =
Lth_X(Semico) // ; Lth_X(Semico) // ;

View File

@ -50,6 +50,11 @@ void Lth_TokenGet(FILE *fp, Lth_Token *out)
case '\n': Lth_TokenSet(out, LnEnd ); return; case '\n': Lth_TokenSet(out, LnEnd ); return;
case '-':
if(isdigit(Lth_fpeekc(fp))) break;
Lth_TokenSet(out, Minus);
return;
case '.': case '.':
if(isdigit(Lth_fpeekc(fp))) break; if(isdigit(Lth_fpeekc(fp))) break;
Lth_TokenSet(out, Dot); Lth_TokenSet(out, Dot);
@ -75,6 +80,7 @@ void Lth_TokenGet(FILE *fp, Lth_Token *out)
char beg = ch; char beg = ch;
ACS_BeginPrint(); ACS_BeginPrint();
while((ch = fgetc(fp)) != beg && ch != EOF) while((ch = fgetc(fp)) != beg && ch != EOF)
{ {
if(ch != '\\') if(ch != '\\')
@ -94,7 +100,7 @@ void Lth_TokenGet(FILE *fp, Lth_Token *out)
return; return;
} }
if(isdigit(ch) || ch == '.') if(isdigit(ch) || ch == '.' || ch == '-')
{ {
ACS_BeginPrint(); ACS_BeginPrint();