help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: parser stack overflow


From: Ketan Parekh
Subject: RE: parser stack overflow
Date: Thu, 27 Nov 2003 18:22:25 +0530

When using recursion in a rule, always put the call to the name of the rule
as the leftmost entry in the rule (as it is in the preceding example). If
the call to the name of the rule occurs later in the line, such as in the
following example, the parser may run out of internal stack space and stop.:
rule    :       EndCase
        |       EndCase rule
The following example defines the line rule as one or more combinations of a
string followed by a newline character (\n ):
lines   :        line
        |        lines line
        ;

Regards
Ketan


-----Original Message-----
From: Nosnos [mailto:address@hidden
Sent: Thursday, November 27, 2003 5:08 PM
To: address@hidden
Subject: parser stack overflow


hi,

I must make a real time parser/lexer (bison/flex), that lex/parse the stdin
stream.

The parser must work in continuous without stoping.

My first rule was something like that :

frame : FRAME other frame
      | FRAME other
      ;

other : [...]


Of course, i get a stack overflow.

So i want to know how to prevent this ? :

- Maybe with a better set of rules, but I don't know how (precision my file
come from a sniffer, so the file contains lot a part separate by the work
frame).
- I thought about having a loop outside the parser that always called
yyparse ...
  the starting rules will be so :
  frame : FRAME other   { return 0;} 
        |               { ERROR ; return -1;}

- ???

Is the second solution a possible way ?
Have you other better suggestion ?

thx a lot


_______________________________________________
address@hidden http://mail.gnu.org/mailman/listinfo/help-bison




reply via email to

[Prev in Thread] Current Thread [Next in Thread]