[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: reentrant parser - how?
From: |
Hans Aberg |
Subject: |
Re: reentrant parser - how? |
Date: |
Sun, 8 May 2005 15:02:39 +0200 |
[Please keep the Help-Bison cc, so that others can help.]
At 13:28 +0200 2005/05/08, Carsten Krüger wrote:
HA> I recall Paul Eggert said that the Bison generated parser, which he
HA> wrote, now is fully pure.
Which parser?
The C-parser skeleton file. But your subsequent
explanations suggests that this is not a question
for Paul (sorry).
HA> If you have some data to be passed to the
HA> parser, that should be done via the arguments to yyparse, and there
HA> are some macros for doing that; see the Bison manual. If yyparse
HA> needs some local data, then there might not be support for doing that
HA> right now. Then you need to figure out how to make the Flex generated
HA> lexer to become pure; for that, check in the Help-Flex list
HA> <address@hidden>.
Can you explain it a litte bit more?
I do not use a fully pure parser, and I use a C++
parser. So you will have to hope from more input
from somebody else.
I try to explain my problem.
My bison grammar has a BEGIN and an END token and I want to parse many
inputfiles consecutively.
Example.
file1:
START
some command
...
STOP
file2:
START
some command
...
STOP
Then you do not need fully pure parser.
If I use only:
yyin=fptr_1;
yyparse();
yyin=fptr_2;
yyparse();
The second yyparse()-call tells me, START is unexpected.
The parser don't know, that the inputfile has changed.
This might be usefull for include-files in C, I think.
Most likely, this is a problem that the lexer has
not been reset. Read the Flex manual, or ask in
the Help-Flex list. I use something like
"lexer_.initialize(isp_)", but I do not know if
that is the original Flex lexer function. The
parser function yyparse() will be reset every
time it is called anew. It only parses tokens,
not streams.
--
Hans Aberg