Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
根据文档,可以向词法分析器规则传递状态参数。
但是有没有办法将先前的状态传递给下一个规则应用程序?
例如,假设我想返回FOO令牌,但只要"foo"找到 a 就改变状态......我该怎么做?
FOO
"foo"
rule main fooCount = parse | ... | "foo" { FOO (fooCount) // Ignored main (fooCount + 1) lexbuf }