【发布时间】:2021-03-19 15:46:18
【问题描述】:
在我的输入中,以* 开头的行是注释行,除非它以*+ 或*- 开头。我可以忽略 cmets,但需要获取其他的。
这是我的词法分析器规则:
WhiteSpaces : [ \t]+;
Newlines : [\r\n]+;
Commnent : '*' .*? Newlines -> skip ;
SkipTokens : (WhiteSpaces | Newlines) -> skip;
一个例子:
* this is a comment line
** another comment line
*+ type value
所以,前两个是注释行,我可以跳过它。但我不知道要定义可以捕获最后一行的词法分析器/解析器规则。
【问题讨论】: