I am reading in a file and for some reason i get a syntax error when i try an expression
like 5+5
however, if i do this 5 + 5
it works good. I am baffled why it would do this?
Here is my lex file( i will leave out main that reads in a file):
%{
#include "y.tab.h"
#include "stdio.h"
#include <stdlib.h>
%}
%%
(\/\*([^*]|(\*+([^*/]|[\r\n])))*\*+\/)+ {}
\/\/[^\n]*\n {}
fd { return FD; }
[\r\t\n]+ {}
[ ]* {}
bk { return BK;}
setc {return SETC;}
[-+]?[0-9]+ { yylval = atoi(yytext); return NUMBER;}
fd[0-9]+ { }
rt {return RT;}
pink {return COLOR_TYPE;}
magenta {return COLOR_TYPE; }
if {return IF; }
ifelse {return IFELSE; }
\[ {return LBRACKET; }
\] {return RBRACKET; }
\< {return LESS_THAN; }
\> {return GREATER_THAN; }
\+ {return PLUS; }
\- {return MINUS; }
\/ {return DIVIDE; }
\* {return MULT; }
\( {return LPAREN;}
\) {return RPAREN;}
\= {return EQ;}
%%
Here is part of my yacc file that deals with the expression:
expr : NUMBER { printf("EXPR-->NUMBER: %d\n", $1);}
|expr PLUS expr {$$ = $1 + $3; printf("EXPR-->expression PLUS expression: %d\n", $$);}
|expr DIVIDE expr {$$ = $1 / $3; printf("EXPR-->expression DIVIDE expression %d\n", $$);}
|expr MULT expr {$$ = $1 * $3; printf("EXPR-->expression MULTIPLY expression %d\n", $$);}
|expr MINUS expr {$$ = $1 - $3; printf("EXPR-->expression MINUS expression %d\n", $$);}
|COLOR_TYPE {printf("EXPR-->COLOR\n");}
;
would the problem be in the lex file?