-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscan.l
More file actions
33 lines (27 loc) · 670 Bytes
/
scan.l
File metadata and controls
33 lines (27 loc) · 670 Bytes
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
/*Jonathan Lawrence
*CS3377.501
*jml160230@utdallas.edu
*scan.l - program4 flex
*/
%option noyywrap
%option nounput
%option noinput
%{
#include <stdlib.h>
#include "y.tab.h"
%}
%%
/* regex for token detection */
[ \t\r]+ {/*ignore whitespace*/}
\n {return EOL;}
, {return COMMA;}
- {return DASH;}
# {return HASH;}
Sr. {return SR;}
Jr. {return JR;}
[MDCLXVI]+ {yylval.str = strdup(yytext); return ROMAN;}
[0123456789]+ {yylval.value = atoi(yytext); return INT;}
[A-Z][a-z]+ {yylval.str = strdup(yytext); return NAME;}
[A-z0-9]{2,} {yylval.str = strdup(yytext); return ID;}
^[A-Z]\.? {yylval.str = strdup(yytext); return NAME_INITIAL;}
%%