org.antlr.v4.runtime.misc.IntegerStack Java Examples
The following examples show how to use
org.antlr.v4.runtime.misc.IntegerStack.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BQLCompiler.java From linden with Apache License 2.0 | 5 votes |
private static TerminalNode getStartNode(ParseTree tree) { if (tree instanceof TerminalNode) { return (TerminalNode) tree; } Deque<ParseTree> workList = new ArrayDeque<ParseTree>(); IntegerStack workIndexStack = new IntegerStack(); workList.push(tree); workIndexStack.push(0); while (!workList.isEmpty()) { ParseTree currentTree = workList.peek(); int currentIndex = workIndexStack.peek(); if (currentIndex == currentTree.getChildCount()) { workList.pop(); workIndexStack.pop(); continue; } // move work list to next child workIndexStack.push(workIndexStack.pop() + 1); // process the current child ParseTree child = currentTree.getChild(currentIndex); if (child instanceof TerminalNode) { return (TerminalNode) child; } workList.push(child); workIndexStack.push(0); } return null; }
Example #2
Source File: ECLexer.java From editorconfig-netbeans with MIT License | 4 votes |
public LexerState(int mode, IntegerStack stack) { Mode = mode; Stack = new IntegerStack(stack); }
Example #3
Source File: ANTLRv4LexerState.java From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License | 4 votes |
public ANTLRv4LexerState(int mode, IntegerStack modeStack, int currentRuleType) { super(mode, modeStack); this.currentRuleType = currentRuleType; }
Example #4
Source File: ANTLRLexerState.java From antlr4-intellij-adaptor with BSD 2-Clause "Simplified" License | 2 votes |
/** * Constructs a new instance of {@link ANTLRLexerState} * containing the mode and mode stack information for an ANTLR * lexer. * * @param mode The current lexer mode, {@link Lexer#_mode}. * @param modeStack The lexer mode stack, {@link Lexer#_modeStack}, or {@code null} . */ public ANTLRLexerState(int mode, @Nullable IntegerStack modeStack) { this.mode = mode; this.modeStack = modeStack != null ? modeStack.toArray() : null; }