Flex的折返与启动条件 [英] Flex reentrant with start conditions
问题描述
我试图做一个折返扫描仪,它依赖于启动条件。
我正沿着类似这样的家伙问题下面的东西
和作为一张海报提到的,扫描仪会工作,如果你明确地创建 yyscan_t
,并把它作为一个额外的参数。不过,我仍然在使用时,你得到 YYG不宣
错误信息 BEGIN< SC>
等操纵启动条件。
这是一个错误吗?我应该明确地使用 yy_push_state
和 yy_pop_state
国家职能呢?
看起来当您使用%选择折返
您只能使用 BEGIN像
和 YY_START
在你的词法分析器的动作部分,而不是在code部分。有意义的,因为操纵解析器状态需要访问解析器状态,但 BEGIN
不带任何参数,所以没有办法提供。使用%选择堆栈
和 yy_push
/ pop_state
似乎是一个合理的解决办法。
I am trying to make a reentrant scanner that relies on start conditions.
I was following along something similar to this guys question:
Writing re-entrant lexer with Flex
And as the one poster mentioned, the scanner will work if you explicitly create the yyscan_t
and pass it as an extra argument. However, I still get the yyg undeclared
error message when using BEGIN <sc>
, etc to manipulate the start condition.
Is this a bug? Should I explicity use the yy_push_state
and yy_pop_state
state functions instead?
Looks like when you use %option reentrant
you can only use BEGIN
and YY_START
in the actions section of your lexer, and not in the code section. Makes sense as manipulating the parser state requires access to the parser state, but BEGIN
doesn't take any arguments, so there's no way to provide it. Using %option stack
and yy_push
/pop_state
seems like a reasonable workaround.
这篇关于Flex的折返与启动条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!