help-bison
[Top][All Lists]
Advanced

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

Re: Interactive continuation prompting


From: Ron Burk
Subject: Re: Interactive continuation prompting
Date: Wed, 25 Jun 2014 10:07:11 -0700

> I somehow need to send an indication from bison to flex to my interface
that syntax is incomplete.

Yes. Any number of ways of moving that bit, any way that pleases you will
work.

> my thinking here was that I could examine the stack depth each time yylex
was called

Probably not the way you want to make that decision.You might want to think
more along the lines of:

S :  lines ;

lines : %empty | lines line ;

line : {global_flag=INCOMPLETE;}    expr    {global_flag=COMPLETE;}  '\n'  ;

When the flag is INCOMPLETE, the lexer eats newlines and prompts with "...".
When the flag is COMPLETE, the lexer returns newlines and prompts with the
normal prompt.

In some situations, you may have to be aware of how much
lookahead occurs where, but that goes with the territory of
interactive parsing. The lexer would have to be careful not to
examine the flag until the last possible moment before prompting
for more input, since the flag will only get set to COMPLETE
after the lexer has returned a newline to the parser.


reply via email to

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