xref: /minix3/external/bsd/flex/dist/examples/manual/front.lex (revision 357f1050293be536ca8309aae20889945ce99fc1)
1*357f1050SThomas Veerman %{
2*357f1050SThomas Veerman #include <stdio.h>
3*357f1050SThomas Veerman #include <string.h>
4*357f1050SThomas Veerman #include "y.tab.h"                 /* this comes from bison        */
5*357f1050SThomas Veerman 
6*357f1050SThomas Veerman #define TRUE  1
7*357f1050SThomas Veerman #define FALSE 0
8*357f1050SThomas Veerman 
9*357f1050SThomas Veerman #define copy_and_return(token_type) { strcpy(yylval.name,yytext); \
10*357f1050SThomas Veerman                                       return(token_type); }
11*357f1050SThomas Veerman 
12*357f1050SThomas Veerman int             yylexlinenum = 0;  /* so we can count lines        */
13*357f1050SThomas Veerman %}
14*357f1050SThomas Veerman 
15*357f1050SThomas Veerman %%
16*357f1050SThomas Veerman                             /* Lexical scanning rules begin from here.  */
17*357f1050SThomas Veerman 
18*357f1050SThomas Veerman MEN|WOMEN|STOCKS|TREES      copy_and_return(NOUN)
19*357f1050SThomas Veerman MISTAKES|GNUS|EMPLOYEES     copy_and_return(NOUN)
20*357f1050SThomas Veerman LOSERS|USERS|CARS|WINDOWS   copy_and_return(NOUN)
21*357f1050SThomas Veerman 
22*357f1050SThomas Veerman DATABASE|NETWORK|FSF|GNU    copy_and_return(PROPER_NOUN)
23*357f1050SThomas Veerman COMPANY|HOUSE|OFFICE|LPF    copy_and_return(PROPER_NOUN)
24*357f1050SThomas Veerman 
25*357f1050SThomas Veerman THE|THIS|THAT|THOSE         copy_and_return(DECLARATIVE)
26*357f1050SThomas Veerman 
27*357f1050SThomas Veerman ALL|FIRST|LAST              copy_and_return(CONDITIONAL)
28*357f1050SThomas Veerman 
29*357f1050SThomas Veerman FIND|SEARCH|SORT|ERASE|KILL copy_and_return(VERB)
30*357f1050SThomas Veerman ADD|REMOVE|DELETE|PRINT     copy_and_return(VERB)
31*357f1050SThomas Veerman 
32*357f1050SThomas Veerman QUICKLY|SLOWLY|CAREFULLY    copy_and_return(ADVERB)
33*357f1050SThomas Veerman 
34*357f1050SThomas Veerman IN|AT|ON|AROUND|INSIDE|ON   copy_and_return(POSITIONAL)
35*357f1050SThomas Veerman 
36*357f1050SThomas Veerman "."                         return(PERIOD);
37*357f1050SThomas Veerman "\n"                        yylexlinenum++; return(NEWLINE);
38*357f1050SThomas Veerman .
39*357f1050SThomas Veerman %%
40*357f1050SThomas Veerman 
41