From eca011188687bfacdfff221d8db190d817570599 Mon Sep 17 00:00:00 2001 From: Waldemar Celes Date: Fri, 17 Dec 1993 16:53:41 -0200 Subject: LUA lexis description --- lua.lex | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 lua.lex (limited to 'lua.lex') diff --git a/lua.lex b/lua.lex new file mode 100644 index 00000000..23a1d7b1 --- /dev/null +++ b/lua.lex @@ -0,0 +1,85 @@ +%{ + +char *rcs_lualex = "$Id: $"; + +#include +#include + +#include "opcode.h" +#include "hash.h" +#include "inout.h" +#include "table.h" +#include "y.tab.h" + +#undef input +#undef unput + +static Input input; +static Unput unput; + +void lua_setinput (Input fn) +{ + input = fn; +} + +void lua_setunput (Unput fn) +{ + unput = fn; +} + +char *lua_lasttext (void) +{ + return yytext; +} + +%} + + +%% +[ \t]* ; +^"$debug" {yylval.vInt = 1; return DEBUG;} +^"$nodebug" {yylval.vInt = 0; return DEBUG;} +\n lua_linenumber++; +"--".* ; +"local" return LOCAL; +"if" return IF; +"then" return THEN; +"else" return ELSE; +"elseif" return ELSEIF; +"while" return WHILE; +"do" return DO; +"repeat" return REPEAT; +"until" return UNTIL; +"function" { + yylval.vWord = lua_nfile-1; + return FUNCTION; + } +"end" return END; +"return" return RETURN; +"local" return LOCAL; +"nil" return NIL; +"and" return AND; +"or" return OR; +"not" return NOT; +"~=" return NE; +"<=" return LE; +">=" return GE; +".." return CONC; +\"[^\"]*\" | +\'[^\']*\' { + yylval.vWord = lua_findenclosedconstant (yytext); + return STRING; + } +[0-9]+("."[0-9]*)? | +([0-9]+)?"."[0-9]+ | +[0-9]+("."[0-9]*)?[dDeEgG][+-]?[0-9]+ | +([0-9]+)?"."[0-9]+[dDeEgG][+-]?[0-9]+ { + yylval.vFloat = atof(yytext); + return NUMBER; + } +[a-zA-Z_][a-zA-Z0-9_]* { + yylval.vWord = lua_findsymbol (yytext); + return NAME; + } +. return *yytext; + -- cgit v1.2.3-55-g6feb