Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bison - additional parameter to a push and pure parser

How can I pass one aditional parameter (not the token minor of type YYSTYPE) to the yypush_parse() function?

The parser is indeed reentrant, but this one aditional variable is crucial for the thread-safety of the application I need to integrate my parser in (it's a PHP extension, so we're talking about TSRM).

I cannot just get rid of that parameter because inside the action code I'm going to call functions which will generate an AST in a userland-accessible form.

I've tried to hack around YYPUSH_DECLS and it works as far as declaring the function is concerned, BUT a few thousand LOCs down comes the implementation of yypush_parse, and I can't see any way to overwrite the function signature where the implementation of yypush_parse starts.

YYPARSE_PARAM is only used when the parser is not a push one (as far as I can tell), but in my case I NEED it be push because of the things I have to do in the processing loop, after lexing and prior to adding a new token to the parsing stack.

So I am wondering if there's a %directive or something that may help.

On the other side, I really think YYPARSE_PARAM should be used as far as it's defined, no matter what type of parser it is. It's a pity it's not.

like image 696
Flavius Avatar asked Apr 15 '11 12:04

Flavius


1 Answers

%parse-param. YYPARSE_PARAM is deprecated and shouldn't be used.

like image 93
Flavius Avatar answered Sep 29 '22 07:09

Flavius