how to push token back for Bison to consider it?

Milan Durovic <mdurovic@vcisnet.net>
13 Apr 2003 12:40:22 -0400

          From comp.compilers

Related articles
how to push token back for Bison to consider it? mdurovic@vcisnet.net (Milan Durovic) (2003-04-13)
Re: how to push token back for Bison to consider it? jyrixx@astro.temple.edu (2003-05-06)
Re: how to push token back for Bison to consider it? blackmarlin@asean-mail.com (2003-05-15)
| List of all articles for this month |
From: Milan Durovic <mdurovic@vcisnet.net>
Newsgroups: comp.compilers
Date: 13 Apr 2003 12:40:22 -0400
Organization: Pacific Internet (Australia)
Keywords: yacc, parse, question, comment
Posted-Date: 13 Apr 2003 12:40:21 EDT

Hi All,


I want to do the following: when a certain grammar rule is matched I
want to, in the action part, read all the tokens until a certain token
is read, and then give the control back to the parser, who should
continue with that token as the next token. In other words, I am doing
something like:




ruleBlah: nonterm1 nonterm2
                        {
                          while( yylex() != SOME_PARTICULAR_TOKEN )
                          { do_something(); }
                        }


ruleBlah2: SOME_PARTICULAR_TOKEN nonterm3 nonterm4


The problem is that the code above "swallows" SOME_PARTICULAR_TOKEN
token, and the generated parser never sees it. This causes the parser
never to match "ruleBlah2" that requires that token.


I tried using YYBACKUP( token, value ), but it did not work the way I
expected.


Any advice is much appreciated.


Regards,


Milan
[You have to write your own routine that sits between the yylex() that
the parser calls and the real lexer that can queue tokens. It's not
hard. -John]


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.