diff options
author | Lua Team <team@lua.org> | 1994-07-08 12:00:00 +0000 |
---|---|---|
committer | repogen <> | 1994-07-08 12:00:00 +0000 |
commit | 944fc7d7d95575f2b8023c1f3d4ac19e1369fc76 (patch) | |
tree | eabf0822f2058229cd0d49c7928683b8cf0ed88e /src/yacc/lua.lex | |
parent | 8b5979a7e8b9732aa2883d2384f853d87b594770 (diff) | |
download | lua-github-1.1.tar.gz |
Lua 1.11.1
Diffstat (limited to 'src/yacc/lua.lex')
-rw-r--r-- | src/yacc/lua.lex | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/src/yacc/lua.lex b/src/yacc/lua.lex new file mode 100644 index 00000000..cbb0232a --- /dev/null +++ b/src/yacc/lua.lex @@ -0,0 +1,85 @@ +%{ + +char *rcs_lualex = "$Id: lua.lex,v 1.1 1993/12/17 18:53:41 celes Exp $"; + +#include <stdlib.h> +#include <string.h> + +#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; + |