-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathscanner.l
46 lines (37 loc) · 935 Bytes
/
scanner.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
%{
#include <ctype.h>
#define YYSTYPE char *
#include "y.tab.h"
static void skip_comment(void);
static void skip_blank(void);
%}
%%
("class"|"instance"|"type"|"name"|"role") yylval = strdup(yytext); return CRITERION;
= return EQUALS;
\"([^\"\\]*(\\.[^\"\\]*)*)\" yylval = strdup(yytext); return STRING;
^[ \t]+([^\r\n\t\f ](([^\n\\])|(\\(.|\n)))+) yylval=strdup(yytext); return COMMAND;
\n return NEWLINE;
[[:blank:]] skip_blank();
<<EOF>> return END;
"#".* skip_comment();
. { fprintf(stderr, "Ignoring unexpected character '%c'\n", *yytext); }
%%
static void
skip_comment(void)
{
int c;
c = input();
while (c != '\n' && c != EOF)
c = input();
if (c == EOF)
unput(c);
}
static void
skip_blank(void)
{
int c;
c = input();
while (isblank(c) && c != EOF)
c = input();
unput(c);
}