public static IContainerNode insertArgumentsBefore(IContainerNode argumentsNode, IASNode... nodes) { int originalLength = argumentsNode.getChildCount(); int extraLength = nodes.length; ContainerNode result = new ContainerNode(originalLength + extraLength); result.setSourcePath(argumentsNode.getSourcePath()); result.span(argumentsNode); result.setParent((NodeBase) argumentsNode.getParent()); for (int i = 0; i < extraLength; i++) { NodeBase node = (NodeBase) nodes[i]; node.setSourcePath(argumentsNode.getSourcePath()); result.addItem(node); } for (int i = 0; i < originalLength; i++) { result.addItem((NodeBase) argumentsNode.getChild(i)); } return result; }
@Override public IExpressionNode[] getConditionalExpressionNodes() { int childCount = conditionsStatementsNode.getChildCount(); ArrayList<IExpressionNode> retVal = new ArrayList<IExpressionNode>(3); for (int i = 0; i < childCount; i++) { IASNode child = conditionsStatementsNode.getChild(i); if (child instanceof IExpressionNode) retVal.add((IExpressionNode)child); } return retVal.toArray(new IExpressionNode[0]); }
/** * Adds a node to the list of children (really just a public wrapper around * addChild) * * @param child new child node */ public void addItem(NodeBase child) { addChild(child); }
public FunctionContentsPart() { super(); argumentsNode = new ContainerNode(2); argumentsNode.setContainerType(ContainerType.PARENTHESIS); contentsNode = new ScopedBlockNode(false); // Set the contents to implicit - the parser will set to BRACES if it // sees a function body contentsNode.setContainerType(ContainerType.SYNTHESIZED); }
/** * Check if the next attribute definition is gated with a configuration * condition variable. If it is, then return the evaluated result of the * condition. * * @param containerNode parent node * @return True if the attributed definition is enabled. */ protected final boolean isDefinitionEnabled(final ContainerNode containerNode) { assert containerNode != null : "Container node can't be null."; final int childCount = containerNode.getChildCount(); if (childCount > 0) { final IASNode lastChild = containerNode.getChild(childCount - 1); if (lastChild.getNodeID() == ASTNodeID.LiteralBooleanID) { // evaluate final boolean eval = Boolean.parseBoolean(((LiteralNode)lastChild).getValue()); // remove the configuration condition node containerNode.removeItem((NodeBase)lastChild); containerNode.setRemovedConditionalCompileNode(true); return eval; } } return true; }
c.addItem(node); forContainer = node.getConditionalsContainerNode(); b = node.getContentsNode(); forContainer.startAfter(lparenT); forContainer.addItem(fi); forCondition(forContainer); match(TOKEN_SEMICOLON); if (fi instanceof ContainerNode && fi.getChildCount() > 0 && ((ContainerNode)fi).getChild(0) instanceof ExpressionNodeBase) leftOfIn = (ExpressionNodeBase)((ContainerNode)fi).getChild(0); forContainer.addItem(inNode); if (forContainer.getChildCount() == 0 && fi != null) forContainer.addItem(fi); match(TOKEN_PAREN_CLOSE); forContainer.endBefore(rparenT);
/** * Matches the "step" part in a for loop. */ public final void forStep( ContainerNode c ) throws RecognitionException, TokenStreamException { ExpressionNodeBase e = null; try { // for error handling e=optExpression(); if (e != null) c.addItem(e); } catch (RecognitionException ex) { handleParsingError(ex); } }
/** * Copy constructor. * * @param other The node to copy. */ protected FunctionCallNode(FunctionCallNode other) { super(other); this.newKeywordNode = other.newKeywordNode != null ? new KeywordNode(other.newKeywordNode) : null; this.nameNode = other.nameNode != null ? other.nameNode.copy() : null; this.argumentsNode = new ContainerNode(other.argumentsNode.getChildCount()); for (IExpressionNode arg : other.getArgumentNodes()) { argumentsNode.addItem(((ExpressionNodeBase)arg).copy()); } }
final int size = contents.getChildCount(); final IASNode lastLiteralNode = contents.getChild(size - 1); if (lastLiteralNode.getNodeID() == ASTNodeID.LiteralXMLID) contents.addItem(newNode);
c = new ContainerNode(); c.setStart(v.getStart()); c.addItem(v); v = c; c.addItem(v1); c.setEnd(v1.getEnd());
final ContainerType type = cnode.getContainerType(); String postFix = ""; final int len = cnode.getChildCount(); for (int i = 0; i < len; i++) IASNode child = cnode.getChild(i); getWalker().walk(child); if (i < len - 1)
for (int i = 0; i < contents.getChildCount(); i++) final IASNode child = contents.getChild(i); if (child.getNodeID() == ASTNodeID.FunctionObjectID) container.addChild(((FunctionObjectNode)child).getFunctionNode()); else container.addChild((NodeBase)child);
/** * Constructor. */ public FunctionCallNode(ExpressionNodeBase nameNode) { newKeywordNode = null; this.nameNode = nameNode; argumentsNode = new ContainerNode(2); setSourceLocation(nameNode); }
/** * Find the iterator {@code VariableNode} in a {@code ForLoopNode}. * * <pre> * for (var it : String = "hello" in array) {...} * for each (var it : String = "hello" in array) {...} * </pre> * * @param for_loop_node "for" loop node. * @return {@code VariableNode} of the iterator variable. */ private static VariableNode findIteratorVariable(final ForLoopNode for_loop_node) { assert for_loop_node != null : "'for' loop node can't be null"; final IASNode conditionalStatement = for_loop_node.getConditionalsContainerNode().getChild(0); final BinaryOperatorInNode in_node = (BinaryOperatorInNode)conditionalStatement; final VariableExpressionNode var_expr_node = (VariableExpressionNode)in_node.getLeftOperandNode(); final VariableNode var_node = (VariableNode)var_expr_node.getChild(0); return var_node; }
@Override protected void setChildren(boolean fillInOffsets) { if (contentsNode != null) contentsNode.setParent(this); }
/** * Matches a sub-statement. */ public final void substatement( ContainerNode c ) throws RecognitionException, TokenStreamException { { if (((_tokenSet_1.member(LA(1))))&&( LA(1) != TOKEN_BLOCK_OPEN )) { statement(c,NO_END_TOKEN); } else if ((LA(1)==TOKEN_BLOCK_OPEN)) { block(c); } else if ((LA(1)==TOKEN_KEYWORD_VAR||LA(1)==TOKEN_KEYWORD_CONST)) { variableDefinition(c, null, null); } else { throw new NoViableAltException(LT(1), getFilename()); } } if (c.getContainerType() == ContainerType.SYNTHESIZED) c.setContainerType(ContainerType.IMPLICIT); }
@Override protected void addChildInOrder(NodeBase newChild, boolean fillInOffsets) { if (newChild instanceof IMetaTagNode) super.addChildInOrder(newChild, fillInOffsets); }
/** * Adds a node to the list of children (really just a public wrapper around * addChild) * * @param child new child node */ public void addItemAfterNormalization(NodeBase child) { addChildPostNormalize(child); }
/** * Adds a node to the list of children WITHOUT changing their real parent. * This is used by the PackageTypesNode (which is not a real parse tree * nodes) to hold onto various type nodes without mangling their original * parse tree relationships. * * @param child new child node */ public void addTemporaryItem(NodeBase child) { if (child != null) addTemporaryChild(child); }
c.addItem(node); forContainer = node.getConditionalsContainerNode(); b = node.getContentsNode(); forContainer.startAfter(lparenT); forContainer.addItem(fi); forCondition(forContainer); match(TOKEN_SEMICOLON); if (fi instanceof ContainerNode && fi.getChildCount() > 0 && ((ContainerNode)fi).getChild(0) instanceof ExpressionNodeBase) leftOfIn = (ExpressionNodeBase)((ContainerNode)fi).getChild(0); forContainer.addItem(inNode); if (forContainer.getChildCount() == 0 && fi != null) forContainer.addItem(fi); match(TOKEN_PAREN_CLOSE); forContainer.endBefore(rparenT);