Solved

HI more lex and yacc

Posted on 1998-12-15
13
170 Views
Last Modified: 2010-04-15
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.
0
Comment
Question by:laeuchli
  • 6
  • 6
13 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1255169
if you have not missed the  %%  separator, please post the file.
0
 
LVL 5

Author Comment

by:laeuchli
ID: 1255170
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

0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1255171
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)

0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 5

Author Comment

by:laeuchli
ID: 1255172
explain the table sizes please. If that does not help I will try to get to code.
Thanks

0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1255173
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 :-(
0
 
LVL 5

Author Comment

by:laeuchli
ID: 1255174
%{
#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.



0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 100 total points
ID: 1255175
{ifj}      {return(V4);}
0
 
LVL 1

Expert Comment

by:lafanga
ID: 1255176
Guess!! this is something new for me.  
Is there any place where I can know more about this??

0
 
LVL 5

Author Comment

by:laeuchli
ID: 1255177
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.



0
 
LVL 51

Expert Comment

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

lafanga, how about:  man lex; man yacc
0
 
LVL 5

Author Comment

by:laeuchli
ID: 1255179
Yes I did and it worked. I would now like to know why?

0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1255180
read  man lex  ;-)
(at least one white space must seperate a rule from it's actions)
0
 
LVL 5

Author Comment

by:laeuchli
ID: 1255181
OHH, I feel dumb. Thanks a lot for your help.

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question