List of usage examples for org.antlr.v4.runtime BufferedTokenStream getText
@Override
public String getText(RuleContext ctx)
From source file:org.pshdl.model.parser.SourceInfo.java
License:Open Source License
public SourceInfo(BufferedTokenStream tokens, ParserRuleContext context) { this.context = context; this.startLine = context.start.getLine(); this.totalOffset = context.start.getStartIndex(); this.startPosInLine = context.start.getCharPositionInLine(); if (context.stop != null) { this.endLine = context.stop.getLine(); this.endPosInLine = context.stop.getCharPositionInLine(); } else {//w ww. ja va 2s . c o m this.endLine = startLine; this.endPosInLine = startPosInLine; } if (tokens != null) { this.length = tokens.getText(context.getSourceInterval()).length(); final List<Token> hidden = tokens.getHiddenTokensToLeft(context.start.getTokenIndex(), PSHDLLangLexer.COMMENTS); if (hidden != null) { for (final Token token : hidden) { comments.add(token.getText()); } } } else { this.length = -1; } }