aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src/ANSI_C.l
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--LuaSL/src/ANSI_C.l182
1 files changed, 0 insertions, 182 deletions
diff --git a/LuaSL/src/ANSI_C.l b/LuaSL/src/ANSI_C.l
deleted file mode 100644
index 8a6b435..0000000
--- a/LuaSL/src/ANSI_C.l
+++ /dev/null
@@ -1,182 +0,0 @@
1D [0-9]
2L [a-zA-Z_]
3H [a-fA-F0-9]
4E [Ee][+-]?{D}+
5P [Pp][+-]?{D}+
6FS (f|F|l|L)
7IS ((u|U)|(u|U)?(l|L|ll|LL)|(l|L|ll|LL)(u|U))
8
9%{
10#include <stdio.h>
11#include "y.tab.h"
12
13void count(void);
14%}
15
16%%
17"/*" { comment(); }
18"//"[^\n]* { /* consume //-comment */ }
19
20
21"auto" { count(); return(AUTO); }
22"_Bool" { count(); return(BOOL); }
23"break" { count(); return(BREAK); }
24"case" { count(); return(CASE); }
25"char" { count(); return(CHAR); }
26"_Complex" { count(); return(COMPLEX); }
27"const" { count(); return(CONST); }
28"continue" { count(); return(CONTINUE); }
29"default" { count(); return(DEFAULT); }
30"do" { count(); return(DO); }
31"double" { count(); return(DOUBLE); }
32"else" { count(); return(ELSE); }
33"enum" { count(); return(ENUM); }
34"extern" { count(); return(EXTERN); }
35"float" { count(); return(FLOAT); }
36"for" { count(); return(FOR); }
37"goto" { count(); return(GOTO); }
38"if" { count(); return(IF); }
39"_Imaginary" { count(); return(IMAGINARY); }
40"inline" { count(); return(INLINE); }
41"int" { count(); return(INT); }
42"long" { count(); return(LONG); }
43"register" { count(); return(REGISTER); }
44"restrict" { count(); return(RESTRICT); }
45"return" { count(); return(RETURN); }
46"short" { count(); return(SHORT); }
47"signed" { count(); return(SIGNED); }
48"sizeof" { count(); return(SIZEOF); }
49"static" { count(); return(STATIC); }
50"struct" { count(); return(STRUCT); }
51"switch" { count(); return(SWITCH); }
52"typedef" { count(); return(TYPEDEF); }
53"union" { count(); return(UNION); }
54"unsigned" { count(); return(UNSIGNED); }
55"void" { count(); return(VOID); }
56"volatile" { count(); return(VOLATILE); }
57"while" { count(); return(WHILE); }
58
59{L}({L}|{D})* { count(); return(check_type()); }
60
610[xX]{H}+{IS}? { count(); return(CONSTANT); }
620{D}+{IS}? { count(); return(CONSTANT); }
63{D}+{IS}? { count(); return(CONSTANT); }
64L?'(\\.|[^\\'\n])+' { count(); return(CONSTANT); }
65
66{D}+{E}{FS}? { count(); return(CONSTANT); }
67{D}*"."{D}+({E})?{FS}? { count(); return(CONSTANT); }
68{D}+"."{D}*({E})?{FS}? { count(); return(CONSTANT); }
690[xX]{H}+{P}{FS}? { count(); return(CONSTANT); }
700[xX]{H}*"."{H}+({P})?{FS}? { count(); return(CONSTANT); }
710[xX]{H}+"."{H}*({P})?{FS}? { count(); return(CONSTANT); }
72
73
74L?\"(\\.|[^\\"\n])*\" { count(); return(STRING_LITERAL); }
75
76"..." { count(); return(ELLIPSIS); }
77">>=" { count(); return(RIGHT_ASSIGN); }
78"<<=" { count(); return(LEFT_ASSIGN); }
79"+=" { count(); return(ADD_ASSIGN); }
80"-=" { count(); return(SUB_ASSIGN); }
81"*=" { count(); return(MUL_ASSIGN); }
82"/=" { count(); return(DIV_ASSIGN); }
83"%=" { count(); return(MOD_ASSIGN); }
84"&=" { count(); return(AND_ASSIGN); }
85"^=" { count(); return(XOR_ASSIGN); }
86"|=" { count(); return(OR_ASSIGN); }
87">>" { count(); return(RIGHT_OP); }
88"<<" { count(); return(LEFT_OP); }
89"++" { count(); return(INC_OP); }
90"--" { count(); return(DEC_OP); }
91"->" { count(); return(PTR_OP); }
92"&&" { count(); return(AND_OP); }
93"||" { count(); return(OR_OP); }
94"<=" { count(); return(LE_OP); }
95">=" { count(); return(GE_OP); }
96"==" { count(); return(EQ_OP); }
97"!=" { count(); return(NE_OP); }
98";" { count(); return(';'); }
99("{"|"<%") { count(); return('{'); }
100("}"|"%>") { count(); return('}'); }
101"," { count(); return(','); }
102":" { count(); return(':'); }
103"=" { count(); return('='); }
104"(" { count(); return('('); }
105")" { count(); return(')'); }
106("["|"<:") { count(); return('['); }
107("]"|":>") { count(); return(']'); }
108"." { count(); return('.'); }
109"&" { count(); return('&'); }
110"!" { count(); return('!'); }
111"~" { count(); return('~'); }
112"-" { count(); return('-'); }
113"+" { count(); return('+'); }
114"*" { count(); return('*'); }
115"/" { count(); return('/'); }
116"%" { count(); return('%'); }
117"<" { count(); return('<'); }
118">" { count(); return('>'); }
119"^" { count(); return('^'); }
120"|" { count(); return('|'); }
121"?" { count(); return('?'); }
122
123[ \t\v\n\f] { count(); }
124. { /* Add code to complain about unmatched characters */ }
125
126%%
127
128int yywrap(void)
129{
130 return 1;
131}
132
133
134void comment(void)
135{
136 char c, prev = 0;
137
138 while ((c = input()) != 0) /* (EOF maps to 0) */
139 {
140 if (c == '/' && prev == '*')
141 return;
142 prev = c;
143 }
144 error("unterminated comment");
145}
146
147
148int column = 0;
149
150void count(void)
151{
152 int i;
153
154 for (i = 0; yytext[i] != '\0'; i++)
155 if (yytext[i] == '\n')
156 column = 0;
157 else if (yytext[i] == '\t')
158 column += 8 - (column % 8);
159 else
160 column++;
161
162 ECHO;
163}
164
165
166int check_type(void)
167{
168/*
169* pseudo code --- this is what it should check
170*
171* if (yytext == type_name)
172* return TYPE_NAME;
173*
174* return IDENTIFIER;
175*/
176
177/*
178* it actually will only return IDENTIFIER
179*/
180
181 return IDENTIFIER;
182}