本文介绍了任何类型的空格上的 JavaCC 词法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我清楚地在我的 SKIP 令牌中定义了 unicode 空白字符,如下所示:
I cleary have the unicode whitespace characters defined in my SKIP token like so:
SKIP {
" "
| "\r"
| "\n"
| "\t"
}
但是,当我运行 Java CC 时,它会很好地解析所有标记,直到我遇到上述任何一个空格字符并抛出以下错误:
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"
所以你可以看到它运行良好,直到它遇到\r".我用"、\n"和\t"得到同样的错误.有什么想法吗?谢谢
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
推荐答案
确保在 SKIP 和括号之间有一个冒号.
Make sure you have a colon between the SKIP and your bracket.
跳过:{""|富"|酒吧"}
SKIP: { " "| "foo"| "bar"}
这篇关于任何类型的空格上的 JavaCC 词法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!