public final Label label_ref() throws RecognitionException { Label label = null; CommonTree SIMPLE_NAME106=null; try { // smaliTreeWalker.g:704:3: ( SIMPLE_NAME ) // smaliTreeWalker.g:704:5: SIMPLE_NAME { SIMPLE_NAME106=(CommonTree)match(input,SIMPLE_NAME,FOLLOW_SIMPLE_NAME_in_label_ref1817); label = method_stack.peek().methodBuilder.getLabel((SIMPLE_NAME106!=null?SIMPLE_NAME106.getText():null)); } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } return label; } // $ANTLR end "label_ref"
searcher.reset(); CommonTree rootNode = setCols; while (rootNode != null && rootNode.getType() != HiveParser.TOK_INSERT) { rootNode = rootNode.parent; setCols.token.setType(HiveParser.TOK_ALLCOLREF); return; for (int j = 0; j < rootNode.getChildCount(); ++j) { Tree child = rootNode.getChild(j); if (child.getType() == HiveParser.TOK_FROM) { fromNode = child; break; setCols.token.setType(HiveParser.TOK_ALLCOLREF); return; setCols.token.setType(HiveParser.TOK_ALLCOLREF); return; while (queryOfSelect != null && queryOfSelect.getType() != HiveParser.TOK_QUERY) { queryOfSelect = queryOfSelect.parent; Tree moreToTheLeft = queryOfSelect.parent.getChild(0); Preconditions.checkState(moreToTheLeft != queryOfSelect); ASTNode newSelect = searcher.simpleBreadthFirstSearchAny((ASTNode)moreToTheLeft,
@Override public ArrayList<Node> getChildren() { if (super.getChildCount() == 0) { return null; } ArrayList<Node> ret_vec = new ArrayList<Node>(); for (int i = 0; i < super.getChildCount(); ++i) { ret_vec.add((Node) super.getChild(i)); } return ret_vec; }
private CommonTree parseParamList(CommonToken paramListToken) { String paramList = paramListToken.getText(); CommonTree root = new CommonTree(); int startIndex = paramListToken.getStartIndex(); int i=0; while (i<paramList.length()) { CommonToken token = getParamListSubToken(paramListToken, paramList, i); root.addChild(new CommonTree(token)); i += token.getText().length(); } if (root.getChildCount() == 0) { return null; } return root; }
private void findTableNames(final Object obj, final Set<TableName> tableNames) { if (!(obj instanceof CommonTree)) { return; } final CommonTree tree = (CommonTree) obj; final int childCount = tree.getChildCount(); if ("TOK_TABNAME".equals(tree.getText())) { final TableName tableName; final boolean isInput = "TOK_TABREF".equals(tree.getParent().getText()); switch (childCount) { case 1 : tableName = new TableName(null, tree.getChild(0).getText(), isInput); break; case 2: tableName = new TableName(tree.getChild(0).getText(), tree.getChild(1).getText(), isInput); break; default: throw new IllegalStateException("TOK_TABNAME does not have expected children, childCount=" + childCount); } // If parent is TOK_TABREF, then it is an input table. tableNames.add(tableName); return; } for (int i = 0; i < childCount; i++) { findTableNames(tree.getChild(i), tableNames); } }
inst=(CommonTree)input.LT(1); if ( (input.LA(1) >= INSTRUCTION_FORMAT22c_FIELD && input.LA(1) <= INSTRUCTION_FORMAT22c_FIELD_ODEX) ) { input.consume(); state.errorRecovery=false; Opcode opcode = opcodes.getOpcodeByName((inst!=null?inst.getText():null)); byte regA = parseRegister_nibble((registerA!=null?registerA.getText():null)); byte regB = parseRegister_nibble((registerB!=null?registerB.getText():null)); method_stack.peek().methodBuilder.addInstruction(new BuilderInstruction22c(opcode, regA, regB, dexBuilder.internFieldReference(fieldReference)));
int LA30_0 = input.LA(1); if ( (LA30_0==NULL_LITERAL||LA30_0==STRING_LITERAL) ) { alt30=1; int LA27_0 = input.LA(1); if ( (LA27_0==NULL_LITERAL) ) { alt27=1; new NoViableAltException("", 27, 0, input); throw nvae; int LA28_0 = input.LA(1); if ( (LA28_0==ARRAY_TYPE_PREFIX||LA28_0==CLASS_DESCRIPTOR||LA28_0==PRIMITIVE_TYPE) ) { alt28=1; int registerNumber = parseRegister_short((REGISTER100!=null?REGISTER100.getText():null)); method_stack.peek().methodBuilder.addStartLocal(registerNumber, dexBuilder.internNullableStringReference(name), dexBuilder.internNullableTypeReference((nonvoid_type_descriptor101!=null?((smaliTreeWalker.nonvoid_type_descriptor_return)nonvoid_type_descriptor101).type:null)),
switch ( input.LA(1) ) { case CLASS_DESCRIPTOR: int LA37_1 = input.LA(2); if ( (LA37_1==UP) ) { alt37=1; int LA37_3 = input.LA(3); if ( (LA37_3==ARRAY_TYPE_PREFIX||LA37_3==CLASS_DESCRIPTOR||LA37_3==PRIMITIVE_TYPE) ) { alt37=2; new NoViableAltException("", 37, 3, input); throw nvae; } finally { input.consume(); NoViableAltException nvae = new NoViableAltException("", 37, 1, input); throw nvae; } finally { new NoViableAltException("", 37, 3, input); throw nvae; } finally { reference = new ImmutableTypeReference((CLASS_DESCRIPTOR110!=null?CLASS_DESCRIPTOR110.getText():null));
private static Expression<?>[] convertBeanSpecList(CommonTree node) throws SyntaxError { if (node.getType() == DatabeneScriptLexer.BEANSPEC) return new Expression<?>[] { convertBeanSpec(node) }; else if (node.isNil()) { int childCount = node.getChildCount(); Expression<?>[] specs = new Expression<?>[childCount]; for (int i = 0; i < childCount; i++) specs[i] = convertBeanSpec(childAt(i, node)); return specs; } else throw new SyntaxError("Unexpected token", node.getToken().getText(), node.getLine(), node.getCharPositionInLine()); }
int LA39_0 = input.LA(1); if ( (LA39_0==PRIMITIVE_TYPE) ) { alt39=1; new NoViableAltException("", 39, 0, input); throw nvae; type = (ARRAY_TYPE_PREFIX209!=null?ARRAY_TYPE_PREFIX209.getText():null) + (PRIMITIVE_TYPE210!=null?PRIMITIVE_TYPE210.getText():null); type = (ARRAY_TYPE_PREFIX209!=null?ARRAY_TYPE_PREFIX209.getText():null) + (CLASS_DESCRIPTOR211!=null?CLASS_DESCRIPTOR211.getText():null);
boolean ifNotExists = ast.getChild(0).getType() == HiveParser.TOK_IFNOTEXISTS; : WriteEntity.WriteType.DDL_SHARED)); int numCh = ast.getChildCount(); int start = ifNotExists ? 1 : 0; new AddPartitionDesc(tab.getDbName(), tab.getTableName(), ifNotExists); for (int num = start; num < numCh; num++) { ASTNode child = (ASTNode) ast.getChild(num); switch (child.getToken().getType()) { case HiveParser.TOK_PARTSPEC: if (currentPart != null) { throw new SemanticException("LOCATION clause illegal for view partition"); currentLocation = unescapeSQLString(child.getChild(0).getText()); inputs.add(toReadEntity(currentLocation)); break;
SemanticException(IntStream input, CommonTree tree, String errorMessage, Object... messageArguments) { super(); this.input = input; this.token = tree.getToken(); this.index = tree.getTokenStartIndex(); this.line = token.getLine(); this.charPositionInLine = token.getCharPositionInLine(); this.errorMessage = String.format(errorMessage, messageArguments); }
if (token.getChannel() == smaliParser.HIDDEN) { continue; System.out.println(smaliParser.tokenNames[token.getType()] + ": " + token.getText()); System.out.println(t.toStringTree());
private boolean isDecimal(CommonTree node) { if (node != null) { if (Objects.equals(".", node.getText())) { return true; } if (node.getType() == JPA2Lexer.INT_NUMERAL && node.childIndex > 0) { Tree prevNode = node.parent.getChild(node.childIndex - 1); return prevNode != null && Objects.equals(".", prevNode.getText()); } } return false; }
public final smaliTreeWalker.subannotation_return subannotation() throws RecognitionException { smaliTreeWalker.subannotation_return retval = new smaliTreeWalker.subannotation_return(); retval.start = input.LT(1); while (true) { int alt47=2; int LA47_0 = input.LA(1); if ( (LA47_0==I_ANNOTATION_ELEMENT) ) { alt47=1; retval.annotationType = (CLASS_DESCRIPTOR240!=null?CLASS_DESCRIPTOR240.getText():null); retval.elements = elements;
import org.antlr.runtime.*; import org.antlr.runtime.tree.*; public class Main { public static void main(String args[]) throws Exception { INTcLexer lex = new INTcLexer(new ANTLRStringStream("true and false\n")); CommonTokenStream tokens = new CommonTokenStream(lex); INTcParser parser = new INTcParser(tokens); CommonTree t = (CommonTree)parser.prog().getTree(); CommonTreeNodeStream nodes = new CommonTreeNodeStream(t); INTcWalker evaluator = new INTcWalker(nodes); System.out.println(t.toStringTree()); CommonTree tr; while(true) { Token token = ((CommonTree)nodes.nextElement()).getToken(); if(token.getType() == INTcParser.EOF) break; System.out.printf("%-10s '%s'\n", INTcParser.tokenNames[token.getType()], token.getText()); } System.out.println("\nresult=" + evaluator.getResult()); } }
public void visit(Object t) { CommonTree a = (CommonTree)t; CommonTree action = null; if ( a.getChildCount()==2 ) action = (CommonTree)a.getChild(1); else if ( a.getChildCount()==3 ) action = (CommonTree)a.getChild(2); if ( action.getType()==ANTLRv3Parser.ACTION ) { tokens.delete(a.getTokenStartIndex(), a.getTokenStopIndex()); killTrailingNewline(tokens, action.getTokenStopIndex()); } } });
@Override public void visit(Object t) { CommonTree a = (CommonTree)t; if ( a.getParent().getType()==ANTLRv3Parser.RULE_REF ) { tokens.delete(a.getTokenStartIndex(), a.getTokenStopIndex()); } } });