List of usage examples for org.antlr.v4.runtime BufferedTokenStream getHiddenTokensToLeft
public List<Token> getHiddenTokensToLeft(int tokenIndex, int channel)
From source file:io.proleap.cobol.preprocessor.impl.CobolPreprocessorImpl.java
License:Open Source License
protected String getHiddenTokensToLeft(final BufferedTokenStream tokens, final int tokPos) { final List<Token> refChannel = tokens.getHiddenTokensToLeft(tokPos, Cobol85PreprocessorLexer.HIDDEN); final StringBuffer sb = new StringBuffer(); if (refChannel != null) { for (final Token refToken : refChannel) { final String text = refToken.getText(); sb.append(text);/* w w w . ja v a2 s.co m*/ } } return sb.toString(); }
From source file:io.proleap.cobol.preprocessor.sub.util.TokenUtils.java
License:Open Source License
public static String getHiddenTokensToLeft(final int tokPos, final BufferedTokenStream tokens) { final List<Token> refChannel = tokens.getHiddenTokensToLeft(tokPos, Cobol85PreprocessorLexer.HIDDEN); final StringBuffer sb = new StringBuffer(); if (refChannel != null) { for (final Token refToken : refChannel) { final String text = refToken.getText(); sb.append(text);//from w w w. ja v a 2 s . c o m } } return sb.toString(); }
From source file:net.maritimecloud.internal.msdl.parser.MsdlComment.java
License:Apache License
static MsdlComment parseComments(BufferedTokenStream bts, ParserRuleContext context) { return parseComments(bts.getHiddenTokensToLeft(context.getStart().getTokenIndex(), MsdlLexer.COMMENTS)); }
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 {/*from w ww. ja v a2 s . co 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; } }