logoISU  

CS456 - Systems Programming

Spring 2025

Displaying ./code/lexyacc/example6.l

/*

Compile with :
> lex example6.l
> yacc --verbose -- debug -d example6.y
> gcc lex.yy.c y.tab.c -o example6

*/

%{
#include <stdio.h>
#include "y.tab.h"
%}

%%

zone			return ZONETOK;
file			return FILETOK;
[a-zA-Z][a-zA-Z0-9]*    yylval=strdup(yytext); return WORD;
[a-zA-Z0-9\/.-]+        yylval=strdup(yytext); return FILENAME;
\"                      return QUOTE;
\{                      return OBRACE;
\}                      return EBRACE;
;                       return SEMICOLON;
\n                      /* ignore EOL */;
[ \t]+                  /* ignore whitespace */;
%%