aboutsummaryrefslogtreecommitdiff
path: root/lua.lex
diff options
context:
space:
mode:
authorWaldemar Celes <celes@tecgraf.puc-rio.br>1993-12-17 16:53:41 -0200
committerWaldemar Celes <celes@tecgraf.puc-rio.br>1993-12-17 16:53:41 -0200
commiteca011188687bfacdfff221d8db190d817570599 (patch)
tree8fc3b49fb083964b3fe9620cdb53f332876004a1 /lua.lex
parent93683d530dde8ac24bce6a39af36ede9e142bb24 (diff)
downloadlua-eca011188687bfacdfff221d8db190d817570599.tar.gz
lua-eca011188687bfacdfff221d8db190d817570599.tar.bz2
lua-eca011188687bfacdfff221d8db190d817570599.zip
LUA lexis description
Diffstat (limited to 'lua.lex')
-rw-r--r--lua.lex85
1 files changed, 85 insertions, 0 deletions
diff --git a/lua.lex b/lua.lex
new file mode 100644
index 00000000..23a1d7b1
--- /dev/null
+++ b/lua.lex
@@ -0,0 +1,85 @@
1%{
2
3char *rcs_lualex = "$Id: $";
4
5#include <stdlib.h>
6#include <string.h>
7
8#include "opcode.h"
9#include "hash.h"
10#include "inout.h"
11#include "table.h"
12#include "y.tab.h"
13
14#undef input
15#undef unput
16
17static Input input;
18static Unput unput;
19
20void lua_setinput (Input fn)
21{
22 input = fn;
23}
24
25void lua_setunput (Unput fn)
26{
27 unput = fn;
28}
29
30char *lua_lasttext (void)
31{
32 return yytext;
33}
34
35%}
36
37
38%%
39[ \t]* ;
40^"$debug" {yylval.vInt = 1; return DEBUG;}
41^"$nodebug" {yylval.vInt = 0; return DEBUG;}
42\n lua_linenumber++;
43"--".* ;
44"local" return LOCAL;
45"if" return IF;
46"then" return THEN;
47"else" return ELSE;
48"elseif" return ELSEIF;
49"while" return WHILE;
50"do" return DO;
51"repeat" return REPEAT;
52"until" return UNTIL;
53"function" {
54 yylval.vWord = lua_nfile-1;
55 return FUNCTION;
56 }
57"end" return END;
58"return" return RETURN;
59"local" return LOCAL;
60"nil" return NIL;
61"and" return AND;
62"or" return OR;
63"not" return NOT;
64"~=" return NE;
65"<=" return LE;
66">=" return GE;
67".." return CONC;
68\"[^\"]*\" |
69\'[^\']*\' {
70 yylval.vWord = lua_findenclosedconstant (yytext);
71 return STRING;
72 }
73[0-9]+("."[0-9]*)? |
74([0-9]+)?"."[0-9]+ |
75[0-9]+("."[0-9]*)?[dDeEgG][+-]?[0-9]+ |
76([0-9]+)?"."[0-9]+[dDeEgG][+-]?[0-9]+ {
77 yylval.vFloat = atof(yytext);
78 return NUMBER;
79 }
80[a-zA-Z_][a-zA-Z0-9_]* {
81 yylval.vWord = lua_findsymbol (yytext);
82 return NAME;
83 }
84. return *yytext;
85