JavaCC lexical error on any type of whitespace

喜欢而已 提交于 2019-12-10 09:24:43

问题


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


回答1:


Make sure you have a colon between the SKIP and your bracket.

SKIP: { " " | "foo" | "bar" }




回答2:


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.



来源:https://stackoverflow.com/questions/7800493/javacc-lexical-error-on-any-type-of-whitespace

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!