Bison - 推送和纯解析器的附加参数
如何向 yypush_parse()
函数传递一个附加参数(不是 YYSTYPE
类型的标记次要参数)?
解析器确实是可重入的,但是这个附加变量对于我需要集成解析器的应用程序的线程安全至关重要(它是一个 PHP 扩展,所以我们正在讨论 TSRM)。
我不能直接删除该参数,因为在操作代码中,我将调用将以用户可访问的形式生成 AST 的函数。
我尝试破解 YYPUSH_DECLS
,就声明函数而言它是有效的,但是 yypush_parse
的实现需要几千个 LOC,我可以'没有看到任何方法来覆盖 yypush_parse 实现开始处的函数签名。
YYPARSE_PARAM
仅在解析器不是推送式解析器时使用(据我所知),但在我的情况下,我需要它是推送式的,因为我必须在处理循环中执行一些操作,在词法分析之后和将新标记添加到解析堆栈之前。
所以我想知道是否有 %directive
或者其他可能有帮助的东西。
另一方面,我确实认为 YYPARSE_PARAM
应该按照定义使用,无论它是什么类型的解析器。遗憾的是事实并非如此。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
%parse-param
。YYPARSE_PARAM
已弃用,不应使用。%parse-param
.YYPARSE_PARAM
is deprecated and shouldn't be used.