Unlike in flex, /* */ and \\

don't seem to work in jlex. They give the error, "Missing brace at start of lexical action."

有帮助吗?

解决方案

You can include comments in the first and third sections of your JLex specification (which are the definition and java code sections), but not in the second (rules) part, because JLex will think they are part of a pattern.

Write %state DUMMY

in the declaration section and then writing comments in the rules section like this:

<DUMMY>. { /* this is my comment */ }

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top