[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
yy_top_state question
From: |
Aaron Jackson |
Subject: |
yy_top_state question |
Date: |
Sat, 6 Apr 2013 20:00:49 -0400 |
I don't know if this is a bug in flex, or how I'm trying to do things, but I've
had some trouble using the yy_top_state function. I'm using flex 2.5.35 on
Linux raspberrypi 3.2.27+. For the generated scanner, yy_top_state is defined
as:
static int yy_top_state (yyscan_t yyscanner)
/* %endif */
/* %if-c++-only */
/* %endif */
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyg->yy_start_stack[yyg->yy_start_stack_ptr - 1];
}
This seems like a bug to me. For example, if my program encounters a parse
error, I want to empty out the start stack and end up in the INITIAL state.
However, if you call yy_top_state and the stack pointer is at 0, then you get
an unpredictable result. So, doing something like
while (yy_top_state(yyscanner))
yy_pop_state(yyscanner);
results in a "start-condition stack underflow" error unless there is something
already on the stack. Is this a bug, or am I just using it wrong?
Aaron
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- yy_top_state question,
Aaron Jackson <=