package com.nationwide.pc.is.tpi.web.action;
import java.util.Enumeration;
Java.g4 has this.
WS : [ \t\r\n\u000C]+ -> skip
;
COMMENT
: '/*' .*? '*/' -> skip
;
LINE_COMMENT
: '//' ~[\r\n]* -> skip
;
--
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
WS : [ \t\r\n\u000C]+ -> channel(HIDDEN)
;
I tried this.
The standard code I find by searching is this. Whether I use DEFAULT_CHANNEL or HIDDEN_CHANNEL I still see the code. I thought DEFAULT_CHANNEL
should have only code without whitespaces and HIDDEN_CHANNEL should have only spaces.
public void enterMethodDeclaration( JavaParser.MethodDeclarationContext ctx){
ParserRuleContext parent = ctx.getParent();
while (parent!=null && !(parent instanceof JavaParser.ClassBodyDeclarationContext)) {
parent = parent.getParent();
}
if (parent == null) {
parent = ctx;
}
Token start = parent.start;
// work backwards in token stream to include all preceding whitespace and comments
int tokenIndex = start.getTokenIndex();
while ( tokenIndex > 0 && tokens.get(tokenIndex-1).getChannel() != Token.DEFAULT_CHANNEL ) {
tokenIndex--;
}
int startIndex = start.getStartIndex();
int endIndex = ctx.stop.getStopIndex();
Interval interval = new Interval(startIndex,endIndex);}
Mohan
((CommonTokenStream) tokens).getHiddenTokensToLeft( classOrInterfaceModifierContext.getStart().getTokenIndex(),
Token.HIDDEN_CHANNEL);
I get the comments and whitespaces before each method.
--
You received this message because you are subscribed to a topic in the Google Groups "antlr-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/antlr-discussion/YWsVT-ntD1U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to antlr-discussion+unsubscribe@googlegroups.com.