flex/examples/manual/front.lex
Eric S. Raymond 8d0162b80a Update all the examples to use the new API elements.
Add a fully reentrant example.  And update to TODO file.
2020-10-12 21:07:14 -04:00

38 lines
1.2 KiB
Plaintext

%{
#include <stdio.h>
#include <string.h>
#include "y.tab.h" /* this comes from bison */
#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);
.
%%