X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fnasal%2Flex.c;h=89c3c407b28c578181f07c4e460c684ea8fe591d;hb=bcb320b537b6f7e5e3724e8a30d309322171eb43;hp=432537467290fe64127ea4fb371896f24b83aecd;hpb=dd1ea541ecc4403bcea2ca8c60c03971d1f4338f;p=simgear.git diff --git a/simgear/nasal/lex.c b/simgear/nasal/lex.c index 43253746..89c3c407 100644 --- a/simgear/nasal/lex.c +++ b/simgear/nasal/lex.c @@ -256,25 +256,27 @@ static int lexHexLiteral(struct Parser* p, int index) return i; } +#define ISNUM(c) ((c) >= '0' && (c) <= '9') +#define ISHEX(c) (ISNUM(c) || ((c)>='a' && (c)<='f') || ((c)>='A' && (c)<='F')) +#define NUMSTART(c) (ISNUM(c) || (c) == '+' || (c) == '-') static int lexNumLiteral(struct Parser* p, int index) { int len = p->len, i = index; unsigned char* buf = (unsigned char*)p->buf; double d; - if(i+1= '0' && buf[i] <= '9') i++; + while(i= '0' && buf[i] <= '9') i++; + while(i= '0' && buf[i+1] <= '9')) i++; - while(i= '0' && buf[i] <= '9') i++; + if(buf[i] == '-' || buf[i] == '+') i++; + while(ibuf + index, i - index, &d); newToken(p, index, TOK_LITERAL, 0, 0, d); @@ -333,7 +335,6 @@ static int tryLexemes(struct Parser* p, int index, int* lexemeOut) return best; } -#define ISNUM(c) ((c) >= '0' && (c) <= '9') void naLex(struct Parser* p) { int i = 0;