List of usage examples for org.antlr.v4.runtime BufferedTokenStream consume
@Override public void consume()
From source file:com.cisco.yangide.core.parser.YangParserUtil.java
License:Open Source License
public static String formatYangSource(YangFormattingPreferences preferences, char[] content, int indentationLevel, String lineSeparator) { ANTLRInputStream input = new ANTLRInputStream(content, content.length); final YangLexer lexer = new YangLexer(input) { @Override/*from www . j a v a2s. c o m*/ public void skip() { // disable skipping of comment tokens } }; LexerErrorListener errorListener = new LexerErrorListener(); lexer.addErrorListener(errorListener); final BufferedTokenStream tokens = new BufferedTokenStream(lexer); final ITokenFormatter formatter = new YangTokenFormatter(preferences, indentationLevel, lineSeparator); while (tokens.LT(1).getType() != IntStream.EOF) { formatter.process(tokens.LT(1)); tokens.consume(); } if (errorListener.isErrorDetected()) { // Source that contains parsing errors should never be formatted return String.valueOf(content); } return formatter.getFormattedContent(); }