On 15/12/05, Bob Rossi <[EMAIL PROTECTED]> wrote:
> > The lemon parser generator uses "inverted flow-of-control", the
> > user/lexer calls the parser for each input token.
> >
> > See http://www.hwaci.com/sw/lemon/
>
> Wow, OK, Thanks! Do you know where I would find a lexer to replace flex
> that can do the same?

I think you don't have to replace flex at all. I was a bit inaccurate
about the control flow. The Lexer doesn't call the parser directly.
>From the lemon documentation:

   ParseFile(){
      pParser = ParseAlloc( malloc );
      while( GetNextToken(pTokenizer,&hTokenId, &sToken) ){
         Parse(pParser, hTokenId, sToken);
      }
      Parse(pParser, 0, sToken);
      ParseFree(pParser, free );
   }

So you just have to replace GetNextToken() with yylex, define YY_DECL
for the extra arguments, store the return types of your flexer rules
in hTokenID and the token value in sToken.

> I'm assuming it's impossible to change bison to act like this, short of
> changing the entire generated parser to not be recursive descent. Is
> that true?

Changing bison would be painfull. But i think the type of control flow
(scanner calls parser vs. parser calls scanner) has nothing to do
about whether the parser is top-down (recursive deschent, LL, ...) or
bottom-up (LALR like bison).


_______________________________________________
Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to