for (int i = 0; i < partSpecTree.getChildCount(); ++i) { CommonTree partSpecSingleKey = (CommonTree) partSpecTree.getChild(i); assert (partSpecSingleKey.getType() == HiveParser.TOK_PARTVAL); String key = stripIdentifierQuotes(partSpecSingleKey.getChild(0).getText()).toLowerCase(); String operator = partSpecSingleKey.getChild(1).getText();
for (int i = 0; i < partSpecTree.getChildCount(); ++i) { CommonTree partSpecSingleKey = (CommonTree) partSpecTree.getChild(i); assert (partSpecSingleKey.getType() == HiveParser.TOK_PARTVAL); String key = stripIdentifierQuotes(partSpecSingleKey.getChild(0).getText()).toLowerCase(); String operator = partSpecSingleKey.getChild(1).getText();
public int getGeneralType() { if ( generalType==-3 ) { generalType = generalizeTokenType(super.getType()); } return generalType; }
private static Assignment[] parseFieldAssignments(List<CommonTree> nodes, int firstIndex) throws SyntaxError { Assignment[] assignments = new Assignment[nodes.size() - firstIndex]; for (int i = firstIndex; i < nodes.size(); i++) { CommonTree assignmentNode = nodes.get(i); CommonTree nameNode = childAt(0, assignmentNode); String name = (nameNode.getType() == DatabeneScriptLexer.QUALIFIEDNAME ? childAt(0, nameNode).getText() : nameNode.getText()); CommonTree exNode = childAt(1, assignmentNode); Expression<?> ex = convertNode(exNode); assignments[i - firstIndex] = new Assignment(name, ex); } return assignments; }
public AddToLabelList getAddToListOpIfListLabelPresent(LabeledOp op, GrammarAST label) { AddToLabelList labelOp = null; if ( label!=null && label.parent.getType()==ANTLRParser.PLUS_ASSIGN ) { String listLabel = gen.getTarget().getListLabel(label.getText()); labelOp = new AddToLabelList(this, listLabel, op.getLabels().get(0)); } return labelOp; }
public AddToLabelList getAddToListOpIfListLabelPresent(LabeledOp op, GrammarAST label) { AddToLabelList labelOp = null; if ( label!=null && label.parent.getType()==ANTLRParser.PLUS_ASSIGN ) { String listLabel = gen.getTarget().getListLabel(label.getText()); labelOp = new AddToLabelList(this, listLabel, op.getLabels().get(0)); } return labelOp; }
public AddToLabelList getAddToListOpIfListLabelPresent(LabeledOp op, GrammarAST label) { AddToLabelList labelOp = null; if ( label!=null && label.parent.getType()==ANTLRParser.PLUS_ASSIGN ) { String listLabel = gen.getTarget().getListLabel(label.getText()); labelOp = new AddToLabelList(this, listLabel, op.getLabels().get(0)); } return labelOp; }
private static void convertTableDetail(CommonTree node, DBTable table, DatabaseDialect dialect) { switch (node.getType()) { case SQLLexer.COLUMN_SPEC: convertColumnSpec(node, table); break; case SQLLexer.PRIMARY: convertInlinePK(node, table, dialect); break; default: throw new ParseException("Unknown table detail token type", String.valueOf(node.getText()), node.getLine(), node.getCharPositionInLine()); } }
private Quantifier convertQuantifier(CommonTree node) throws SyntaxError { switch (node.getType()) { case RegexLexer.SIMPLEQUANTIFIER : return convertSimpleQuantifier(node); case RegexLexer.QUANT : return convertExplicitQuantifier(node); default: throw new SyntaxError("Error parsing quantifier", node.getText(), node.getCharPositionInLine(), node.getLine()); } }
public void visit(Object t) { CommonTree a = (CommonTree)t; CommonTree child = (CommonTree)a.getChild(0); int stop = child.getTokenStopIndex(); if ( child.getType()==ANTLRv3Parser.SEMPRED ) { CommonTree rew = (CommonTree)a.getChild(1); stop = rew.getTokenStopIndex(); } tokens.delete(a.token.getTokenIndex(), stop); killTrailingNewline(tokens, stop); } });
public void visit(Object t) { CommonTree a = (CommonTree)t; CommonTree child = (CommonTree)a.getChild(0); int stop = child.getTokenStopIndex(); if ( child.getType()==ANTLRv3Parser.SEMPRED ) { CommonTree rew = (CommonTree)a.getChild(1); stop = rew.getTokenStopIndex(); } tokens.delete(a.token.getTokenIndex(), stop); killTrailingNewline(tokens, stop); } });
private static Quantifier convertQuantifier(CommonTree node) throws SyntaxError { switch (node.getType()) { case RegexLexer.SIMPLEQUANTIFIER : return convertSimpleQuantifier(node); case RegexLexer.QUANT : return convertExplicitQuantifier(node); default: throw new SyntaxError("Error parsing quantifier", node.getText(), node.getCharPositionInLine(), node.getLine()); } }
private static Quantifier convertSimpleQuantifier(CommonTree node) throws SyntaxError { Assert.equals(RegexLexer.SIMPLEQUANTIFIER, node.getType(), "node is not an simple quantifier"); char letter = node.getText().charAt(0); switch (letter) { case '?' : return new Quantifier(0, 1); case '*' : return new Quantifier(0, null); case '+' : return new Quantifier(1, null); default: throw new SyntaxError("Error parsing simple quantifier", node.getText(), node.getCharPositionInLine(), node.getLine()); } }
private static Expression<?> convertLike(CommonTree node) { Expression<?> valueEx = convertExpressionNode(childAt(0, node)); CommonTree child1 = childAt(1, node); boolean not = (child1.getType() == SQLLexer.NOT); int collectionIndex = (not ? 2 : 1); Expression<?> refEx = convertExpressionNode(childAt(collectionIndex, node)); Expression<?> result = new LikeExpression(valueEx, refEx); if (not) result = new LogicalComplementExpression(result); return result; }
private static Expression<?> convertIn(CommonTree node) { Expression<?> valueEx = convertExpressionNode(childAt(0, node)); CommonTree child1 = childAt(1, node); boolean not = (child1.getType() == SQLLexer.NOT); int collectionIndex = (not ? 2 : 1); Expression<? extends Collection<?>> collEx = convertValueList(childAt(collectionIndex, node)); Expression<?> result = new ValueCollectionContainsExpression("IN", valueEx, collEx); if (not) result = new LogicalComplementExpression(result); return result; }
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()); } } });
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()); } } });
private static WeightedTransition convertTransition(CommonTree node) throws SyntaxError { Assert.isTrue(node.getType() == DatabeneScriptLexer.ARROW, "expected transition, found: " + node.getToken()); Expression<?> from = convertNode(childAt(0, node)); Expression<?> to = convertNode(childAt(1, node)); Expression<Double> weight; if (node.getChildCount() > 2) weight = new TypeConvertingExpression<Double>(convertNode(childAt(2, node)), Double.class); else weight = new ConstantExpression<Double>(1.); return new WeightedTransition(from.evaluate(null), to.evaluate(null), weight.evaluate(null)); }