From aa7be467e110de4d3757fc7e0697d89f397aea34 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sun, 8 Jan 2012 23:47:09 +1000 Subject: Rearrange everything, to be consistant order. --- LuaSL/src/LuaSL_lexer.l | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'LuaSL/src/LuaSL_lexer.l') diff --git a/LuaSL/src/LuaSL_lexer.l b/LuaSL/src/LuaSL_lexer.l index 2166743..9753a57 100644 --- a/LuaSL/src/LuaSL_lexer.l +++ b/LuaSL/src/LuaSL_lexer.l @@ -20,21 +20,19 @@ %option align full HEX [[:xdigit:]] -NAME [[:alpha:]](_|[[:alpha:]]|[[:digit:]])* INTEGER [[:digit:]]+ EXPONANT [eE][+-]?{INTEGER} FLOAT {INTEGER}("."{INTEGER})?{EXPONANT}? +NAME [[:alpha:]](_|[[:alpha:]]|[[:digit:]])* %% - /* Basic tokens */ + /* The order here is important, in mysterious ways. The more specific the lower in case of ambiguities like "floats contain integers". I think, not tested that well yet. */ + + /* White space. */ [[:space:]]+ %{ /* ECHO; yylval->spaceValue = strdup(yytext); return LSL_SPACE; */ %} -{NAME} %{ ECHO; /* yylval->nameValue = strdup(yytext); return LSL_NAME; */ %} -{INTEGER} %{ ECHO; yylval->integerValue = atoi(yytext); return LSL_INTEGER; %} -{FLOAT} %{ ECHO; /* yylval->floatValue = atof(yytext); return LSL_FLOAT; */ %} - /* Expression tokens */ -";" { ECHO; return LSL_STATEMENT; } + /* Operations. */ "&&" { ECHO; return LSL_BOOL_AND; } "||" { ECHO; return LSL_BOOL_OR; } "|" { ECHO; return LSL_BIT_OR; } @@ -58,6 +56,14 @@ FLOAT {INTEGER}("."{INTEGER})?{EXPONANT}? "(" { ECHO; return LSL_PARENTHESIS_OPEN; } ")" { ECHO; return LSL_PARENTHESIS_CLOSE; } + /* Types. */ +{INTEGER} %{ ECHO; yylval->integerValue = atoi(yytext); return LSL_INTEGER; %} +{FLOAT} %{ ECHO; /* yylval->floatValue = atof(yytext); return LSL_FLOAT; */ %} + +{NAME} %{ ECHO; /* yylval->nameValue = strdup(yytext); return LSL_NAME; */ %} + +";" { ECHO; return LSL_STATEMENT; } + <> { yyterminate(); } /* Everything else */ -- cgit v1.1