-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathch1-03.l
85 lines (71 loc) · 948 Bytes
/
ch1-03.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
76
77
78
79
80
81
82
83
84
85
%{
/*
* We expand upon the first example by adding recognition of some other
* parts of speech.
*/
%}
%%
[\t ]+ /* ignore white space */ ;
is |
am |
are |
were |
was |
be |
being |
been |
do |
does |
did |
will |
would |
should |
can |
could |
has |
have |
had |
go { printf("%s: is a verb\n", yytext); }
very |
simply |
gently |
quietly |
calmly |
angrily { printf("%s: is an adverb\n", yytext); }
to |
from |
behind |
above |
between |
below { printf("%s: is a preposition\n", yytext); }
if |
then |
and |
but |
or { printf("%s: is a conjunction\n", yytext); }
their |
my |
your |
his |
her |
its { printf("%s: is an adjective\n", yytext); }
I |
you |
he |
she |
we |
they { printf("%s: in a pronoun\n", yytext); }
[a-zA-Z]+ {
printf("%s: don't recognize, might be a noun\n", yytext);
}
\&.|\n { ECHO; /* normal default anyway */ }
%%
int main()
{
yylex();
return 0;
}
int yywrap()
{
return 1;
}