help-bison
[Top][All Lists]
Advanced

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

RE: Parser called from lexer


From: REFSTRUP,JACOB (HP-Vancouver,ex1)
Subject: RE: Parser called from lexer
Date: Tue, 18 Jun 2002 16:08:17 -0700

I've hacked together a bison skeleton (async.bison) that keeps calling the
lexer until -1 is returned (next token unavailable). When that happens
yyparse returns -1 to indicate it can't continue before more "input" is
available.

This simulates a push model and is very similar to bison.simple as it is
based on that file. With a little bit of effort bison.simple and bison.async
could be combined.

I have been using this "asynchronous" version of bison for about 2 months
now so it's gone through quite a bit of testing though I haven't done any
regression testing on it with existing bison tests.

For those interested I simply took all the local variables in yyparse() and
placed them in a structure; I added  yyinit() and also an extra parameter to
yyparse(). The structure is allocated on the heap and is automatically
destroy when parsing completes (either with an error or successfully). I
worked off bison v1.35. If bison.async is merged with bison then care would
have to be taken to ensure that performance doesn't suffer for the "normal"
synchronous case (we want the local variables in registers and that won't
happen if they are inside a struct).

I hope this helps other people in the community. Let me know if you have
questions and/or comments,

Jacob Refstrup

-----Original Message-----
From: Odd Arild Olsen [mailto:address@hidden
Sent: Tuesday, June 04, 2002 12:12 AM
To: address@hidden
Subject: Parser called from lexer



I need a parser implemented as a function called with the next token as 
argument. This is the oposite of what Bison generated parsers do, they call
a 
function to get the next token.

I have hacked bison.simple to do what I want. However, I assume someone has 
made a more elegant "push" parser available. Anyone? 

-- 

O. A. Olsen

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

Attachment: bison.async
Description: Binary data


reply via email to

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