-
Notifications
You must be signed in to change notification settings - Fork 74
/
cdlex.l
75 lines (70 loc) · 2.33 KB
/
cdlex.l
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
%{
/* Lexical analyzer description for ANSI and C++ cdecl. */
/* The output of this file is included */
/* into the C file cdecl.c. */
char cdlexsccsid[] = "@(#)cdlex.l 2.2 3/30/88";
%}
N [0-9]
A [A-Z_a-z]
AN [0-9A-Z_a-z]
%%
array return ARRAY;
as return AS;
cast return CAST;
declare return DECLARE;
exit return 0;
explain return EXPLAIN;
function return FUNCTION;
func return FUNCTION;
block return BLOCK;
help return HELP;
into return INTO;
member return MEMBER;
of return OF;
pointer return POINTER;
quit return 0;
reference return REFERENCE;
ref return REFERENCE;
returning return RETURNING;
ret return RETURNING;
set return SET;
to return TO;
vector return ARRAY;
:: return DOUBLECOLON;
[?] return HELP;
[,] return COMMA;
auto { yylval.dynstr = ds(yytext); return AUTO; }
character { yylval.dynstr = ds("char"); return CHAR; }
char { yylval.dynstr = ds(yytext); return CHAR; }
class { yylval.dynstr = ds(yytext); return CLASS; }
constant { yylval.dynstr = ds("const"); return CONSTVOLATILE; }
const { yylval.dynstr = ds(yytext); return CONSTVOLATILE; }
double { yylval.dynstr = ds(yytext); return DOUBLE; }
enumeration { yylval.dynstr = ds("enum"); return ENUM; }
enum { yylval.dynstr = ds(yytext); return ENUM; }
extern { yylval.dynstr = ds(yytext); return EXTERN; }
float { yylval.dynstr = ds(yytext); return FLOAT; }
integer { yylval.dynstr = ds("int"); return INT; }
int { yylval.dynstr = ds(yytext); return INT; }
long { yylval.dynstr = ds(yytext); return LONG; }
noalias { yylval.dynstr = ds(yytext); return CONSTVOLATILE; }
register { yylval.dynstr = ds(yytext); return REGISTER; }
short { yylval.dynstr = ds(yytext); return SHORT; }
signed { yylval.dynstr = ds(yytext); return SIGNED; }
static { yylval.dynstr = ds(yytext); return STATIC; }
structure { yylval.dynstr = ds("struct"); return STRUCT; }
struct { yylval.dynstr = ds(yytext); return STRUCT; }
union { yylval.dynstr = ds(yytext); return UNION; }
unsigned { yylval.dynstr = ds(yytext); return UNSIGNED; }
void { yylval.dynstr = ds(yytext); return VOID; }
volatile { yylval.dynstr = ds(yytext); return CONSTVOLATILE; }
{A}{AN}* { yylval.dynstr = ds(yytext); return NAME; }
{N}+ { yylval.dynstr = ds(yytext); return NUMBER; }
[#].* ;
[\t ] ;
[&*[\]();^\n] return *yytext;
. {
(void) printf("bad character '%s'\n",visible(*yytext));
return *yytext;
}
%%