So I am having a problem with javacc and skipping comments. I have a multi line comment skip that can contain multiply comments within itself (A comment is anything that appears within /*
and a */
), I also use this code segement <"//" (~["
"])* "
">
to skip a single line comment. Both function independently of one another but when combined, the single line comment seems to break my multi line comment.
该名教授不再承认多线评论,而是将其与其他(<条码>/*条码>、ID等)的组合加以区别。
以下是我关于多线评论和单一线评论技巧的守则:
SKIP:
{
"/*" {commentnesting++;} : IN_COMMENT
}
<IN_COMMENT> SKIP :
{
"/*" {commentnesting++;}
| "*/" {commentnesting--;
if(commentnesting == 0) {
SwitchTo(DEFAULT);
}
}
| <~[]>
}
SKIP :
{
<"//" (~["
"])* "
">
}
我的问题是:
- How can the single line comment cause the multi line comment to break, when they to my relatively new eyes appear to have completely different regexes?
- Is their a way to write the single line comment skip , so that it performs the same function as before but doesn t break the multi line comment when the two are used together?