1 %{
2 #include "expr.cpp.h"
3 
4 #ifndef __GNUC__
5 #include <io.h>
6 #define isatty _isatty
7 #define fileno _fileno
8 #endif
9 
10 char *exprString;
11 int exprCol;
12 
13 #define YY_INPUT(buf,result,max_size) \
14     { \
15     int c = *exprString++; \
16     exprCol++;\
17     result = (c == 0) ? YY_NULL : (buf[0] = c, 1); \
18     }
19 %}
20 
21 %option nomain
22 %option noyywrap
23 %option nounput
24 
25 SIZEOF "sizeof"
26 ID [a-zA-Z_][a-zA-Z0-9_]*
27 NUM [0-9]+
28 DOT "."
29 ARROW "->"
30 STAR "*"
31 ADDR "&"
32 
33 %%
34 
35 {SIZEOF} {
36         return TOKEN_SIZEOF;
37 }
38 
39 {ID} {
40         return TOKEN_IDENTIFIER;
41 }
42 
43 {NUM} {
44         return TOKEN_NUMBER;
45 }
46 
47 {DOT} {
48         return TOKEN_DOT;
49 }
50 
51 {ARROW} {
52         return TOKEN_ARROW;
53 }
54 
55 {ADDR} {
56         return TOKEN_ADDR;
57 }
58 
59 {STAR} {
60         return TOKEN_STAR;
61 }
62 
63 [ \t\n]+
64 
65 . return *yytext;
66 
67 %%
68 
69 void exprCleanBuffer()
70 {
71   yy_delete_buffer(YY_CURRENT_BUFFER);
72   yy_init = 1;
73 }
74