任何类型的空格上的 JavaCC 词法错误
我清楚地在我的 SKIP 令牌中定义了 unicode 空白字符,如下所示:
SKIP {
" "
| "\r"
| "\n"
| "\t"
}
但是,当我运行 Java CC 时,它会很好地解析所有令牌,直到我遇到上述任何空白字符并抛出以下错误:
Exception in thread "main" prjct1.TokenMgrError: Lexical error at line 1, column 25. Encountered: "\r" (13), after : "Random:Word:Here"
所以你可以看到它运行良好,直到它到达“\r”。我对“”、“\n”和“\t”也遇到同样的错误。有什么想法吗?谢谢
I cleary have the unicode whitespace characters defined in my SKIP token like so:
SKIP {
" "
| "\r"
| "\n"
| "\t"
}
However, when I run Java CC it parses all the tokens fine until I hit any of the above mentioning white space characters and it throws the following error:
Exception in thread "main" prjct1.TokenMgrError: Lexical error at line 1, column 25. Encountered: "\r" (13), after : "Random:Word:Here"
So as you can see it runs fine until it hits the "\r". I get the same error with " ", "\n", and "\t". Any thoughts? thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
确保 SKIP 和括号之间有一个冒号。
跳过: {
” “
| “富”
| “酒吧”
}
Make sure you have a colon between the SKIP and your bracket.
SKIP: {
" "
| "foo"
| "bar"
}
我有类似的问题。检查你的报价。它们是中性引号,例如“或左/右双引号”吗?
我有双引号,在将它们设为中性引号后,这个错误就消失了。
I had similar problem. Check your quotes. Are they neutral quotes such as " or left/right double quotes”?
I had double quotes, after making them neutral quote, this error was gone.