[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Problem with scanner buffer when parser exits using YYACCEPT
From: |
Anouar LACHHEB |
Subject: |
Problem with scanner buffer when parser exits using YYACCEPT |
Date: |
Mon, 4 Sep 2006 11:57:17 +0200 |
Hi
I created a parser using Bison v 2.1 calling a scanner written using Flex v
2.5.4a.
The problem is that my parser is used for two purposes:
1- Parse to identify file format (only first line).
2- Parse to generate intermediate files from that file.
I have no problem with (1). However when the parser is called again (2) to
parse the same file, I got a syntax error. I read Bison doc and I deduced
that is a known problem ($ 11.2 How Can I Reset the Parser).
Below is a part of my parser code:
...
%parse-param {int xIdentification}
...
%start S
%%
S : /* empty */
| S Tag
;
Tag : {
if ( xIdentification == 0 )
{
...
}
ID_TAG
{ if ( xIdentification == 1 )
if ( strcmp ( $2, "<ID_TAG>" ) == 0
)
{
YYACCEPT;
}
Id_Tag SLASH_ID_TAG
Loop_Die_Id
;
...
My question is: how can I reset the scanner input buffer from the parser
before calling YYACCEPT.
Best regards,
AnL.
- Problem with scanner buffer when parser exits using YYACCEPT,
Anouar LACHHEB <=