Link to home
Start Free TrialLog in
Avatar of laeuchli
laeuchli

asked on

HI more lex and yacc

Hi, sometimes my lex compiler refuses to let me make a new rule for example something like this abc "abc"
{abc}{return(V1);}
It will say rule abc not know. It's driving me nut, please help.
Avatar of ahoffmann
ahoffmann
Flag of Germany image

if you have not missed the  %%  separator, please post the file.
Avatar of laeuchli
laeuchli

ASKER

The file is a little long to post, and besides that it is on a linux filesystem. I would just like to know what can make lex do that.
jesse

will be hard to analyze without having the code :(
Anyway, check with  lex -v  what are the tables sizes used(needeed in you program, probably you need to adjust them (see %p %n %a %e %k %o)

explain the table sizes please. If that does not help I will try to get to code.
Thanks

If you use -v option to lex, it print a statistic about lex's internal table usage and sizes. These table sizes can be preset with the spezial %p etc. keywords. Please read lex's man-page for details, it's to much to explain here.
I'm not shure if this is your problem, just an assumtion, 'cause you do give any errors or code :-(
%{
#include <stdio.h>
#include <stdlib.h>
#include "os.h"
int k=0;
%}

bootc "void main()"  
equal "="
par ["]
ifj "ifj"
word [A-Za-z0-9]*
num [0-9]*
exit "QUIT"
partb "char"
lb "["
rb "]"
semi [;]
%%
{exit}  {exit(0);}
{partb} {return(V1);}
{lb}    {return(V2);}
{rb}    {return(V3);}
{par}   {return(V4);}
{bootc} {return(BOOTC);}
{ifj}{return(V9);}
{equal} {return(V5);}
{semi}  {return(V6);}
{num} {return(V7);}
{word} {
strcpy(yylval.hold,yytext);
return(V8);
}
%%


Here is the code.  I still can'r get it to compile.



ASKER CERTIFIED SOLUTION
Avatar of ahoffmann
ahoffmann
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Guess!! this is something new for me.  
Is there any place where I can know more about this??

ahoffmann what do you want me to do about the think that I am already returning with V4. Why would I do this? Please tell me more.  lafanga look at my bio and look at the ? looking in a file.



laeuchli, did you replace you rule with the one i posted?
It's slightly different (blanks ;-)

lafanga, how about:  man lex; man yacc
Yes I did and it worked. I would now like to know why?

read  man lex  ;-)
(at least one white space must seperate a rule from it's actions)
OHH, I feel dumb. Thanks a lot for your help.