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.
我想将换行符 ("\n")、分号 (";") 或 eof 匹配为有效的语句结尾。前两个很明显,例如
eos = "\n" | ";";
但我不确定如何以同样的方式匹配 eof 。
有什么方法可以匹配eof吗?我想知道是否empty可行,但我不确定如何使用它。
empty
这是一台对语句结束终止符或 EOF 执行操作的小型机器。
%%{ machine test; eos = (';' | '\n') ${ /* terminator code here */ } >eof{ /* eof code here */ }; main := ('a' 'b' eos)*; write data; write init; write exec; }%%