next up previous
Next: The file expressionTree.y Up: A detailed example Previous: The file type.h

The file expressionTree.l

%{
#include "type.h"
#include "y.tab.h"

//extern int yylval;
#include <stdlib.h>
%}

PLUS            [\+]
TIMES           [\*]
DIGIT           [0-9]
NUMBER          [0-9]+
ID              [a-zA-Z]
WS              [ \t]*
LP              "("
RP              ")"
RET             [\n]

%%

{WS}            {
                /* eat up white space */
                }
{NUMBER}        {
                yylval.intvalue = atoi( yytext ); 
                return TOK_NUMBER;
                }
{ID}            {
                yylval.charvalue = yytext[0];
                return TOK_ID;
                }
{PLUS}          {
                return TOK_PLUS;
                }
{TIMES}         {
                return TOK_TIMES;
                }
{LP}            {
                return TOK_LP;
                }
{RP}            {
                return TOK_RP;
                }
.               {
                }
{RET}           {
                return yytext[0];
                }


next up previous
Next: The file expressionTree.y Up: A detailed example Previous: The file type.h
Marc Moreno Maza
2004-12-02