summaryrefslogtreecommitdiff
path: root/examples/manual/front.lex
blob: 449cb007bcb2c84d3fe7cfb77476334f9854247e (plain)
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
%{
#include <stdio.h>
#include <string.h>
#include "y.tab.h"                 /* this comes from bison        */

#define TRUE  1
#define FALSE 0

#define copy_and_return(token_type) { strcpy(yylval.name,yytext); \
                                      return(token_type); }

int             yylexlinenum = 0;  /* so we can count lines        */
%}

%%
                            /* Lexical scanning rules begin from here.  */

MEN|WOMEN|STOCKS|TREES      copy_and_return(NOUN)
MISTAKES|GNUS|EMPLOYEES     copy_and_return(NOUN)
LOSERS|USERS|CARS|WINDOWS   copy_and_return(NOUN)

DATABASE|NETWORK|FSF|GNU    copy_and_return(PROPER_NOUN)
COMPANY|HOUSE|OFFICE|LPF    copy_and_return(PROPER_NOUN)

THE|THIS|THAT|THOSE         copy_and_return(DECLARATIVE)

ALL|FIRST|LAST              copy_and_return(CONDITIONAL)

FIND|SEARCH|SORT|ERASE|KILL copy_and_return(VERB)
ADD|REMOVE|DELETE|PRINT     copy_and_return(VERB)

QUICKLY|SLOWLY|CAREFULLY    copy_and_return(ADVERB)

IN|AT|ON|AROUND|INSIDE|ON   copy_and_return(POSITIONAL)

"."                         return(PERIOD);                             
"\n"                        yylexlinenum++; return(NEWLINE);            
.                                                                       
%%