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.





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

Reply via email to