help-bison
[Top][All Lists]
Advanced

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

Interactive continuation prompting


From: Grant McKenzie
Subject: Interactive continuation prompting
Date: Wed, 18 Jun 2014 22:53:06 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

Hello,

I have been going through the very nice "A Complete C++ Example" in the bison manual and extending it to implement a trivial language. I have a question about the parsing driver design on this page:

http://www.gnu.org/software/bison/manual/html_node/Calc_002b_002b-Parsing-Driver.html#Calc_002b_002b-Parsing-Driver

I would eventually like to implement a simple command line interface to my little language. I understand that I can set yyin to some stream that I control from as-yet-to-be-implemented command line interface. That interface would also manage command line history etc. I'm struggling to understand however how bash / python style continuation prompting would work ( e.g. python sets it's prompt in an interactive session to '...' when syntax is incomplete ). In order to be able to manage these prompts, I somehow need to send an indication from bison to flex to my interface that syntax is incomplete.

The driver provided in the example does not include any parsing state that I could use as this indication.

I can think of a few approaches to get what I want:

1. use the push-parser design described here http://www.gnu.org/software/bison/manual/html_node/Push-Decl.html

2. change my YY_DECL to pass parsing state to yylex - the interesting things that I'd like to pass such as yystack_ are private though ( my thinking here was that I could examine the stack depth each time yylex was called ).

3. Dive much deeper into Bison than I intended to and spend some time learning how to customize behaviour using the C or C++ API.

I have been through the list archives and other Internet resources and although I can find similar questions posted, I have not been able to find answers ( or perhaps I do not understand enough yet to parse the answers. ) Thanks for putting up with my newbiness.

Thanks.







reply via email to

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