开发者

Bison - additional parameter to a push and pure parser

开发者 https://www.devze.com 2023-02-26 13:46 出处:网络
How can I pass one aditional parameter (not the token minor of type YYSTYPE) to the yypush_parse() function?

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 %dire开发者_开发百科ctive 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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号