On 25 Jul 2011, at 16:22, Ludovic Courtès wrote:
> However, with a pure API, I don’t see how to get yyresult back from user
> code? The code snippet in the manual pushes tokens but never asks for
> the result.
Typically one adds the value as an extra argument, as a reference in C++ or
pointer in C. Check out the C++ example.
My program with syntax on top of Guile uses
%parse-param { parser& driver }
%lex-param { parser& driver }
which means that the function will have 'driver' as extra function name. Then,
in a suitable action (near the sentences symbol), I use
%%
unit:
statement { driver.result = $1; YYACCEPT; };
| "∎" { driver.result = eval(driver.result); YYACCEPT; };
| error { std::cout << "Parser error!" << std::endl;
driver.result = unspecified; yyrestart(stdin); YYABORT; }
;
...
Hans
_______________________________________________
[email protected] https://lists.gnu.org/mailman/listinfo/help-bison