public ASTBinaryTree append(ASTNode node) { if (comparePrecedence(root, node) >= 0) { ASTBinaryTree tree = new ASTBinaryTree(node); tree.left = this; return tree; } else { if (left == null) throw new RuntimeException("Missing left node"); if (right == null) { right = new ASTBinaryTree(node); } else { right = right.append(node); } return this; } }
public static Class getReturnType(ASTIterator input, boolean strongTyping) { ASTNode begin = input.firstNode(); if (begin == null) return Object.class; if (input.size() == 1) return begin.getEgressType(); return buildTree(input).getReturnType(strongTyping); }
public static ASTBinaryTree buildTree(ASTIterator input) { ASTIterator iter = new ASTLinkedList(input.firstNode()); ASTBinaryTree tree = new ASTBinaryTree(iter.nextNode()); while (iter.hasMoreNodes()) { ASTNode node = iter.nextNode(); if (node instanceof EndOfStatement) { if (iter.hasMoreNodes()) tree = new ASTBinaryTree(iter.nextNode()); } else { tree = tree.append(node); } } return tree; } }
public Class<?> getReturnType(boolean strongTyping) { if (!(root instanceof OperatorNode)) return root.getEgressType(); if (left == null || right == null) throw new RuntimeException("Malformed expression"); Class<?> leftType = left.getReturnType(strongTyping); Class<?> rightType = right.getReturnType(strongTyping); switch (((OperatorNode)root).getOperator()) { case CONTAINS:
public static Class getReturnType(ASTIterator input, boolean strongTyping) { ASTNode begin = input.firstNode(); if (begin == null) return Object.class; if (input.size() == 1) return begin.getEgressType(); return buildTree(input).getReturnType(strongTyping); }
public static ASTBinaryTree buildTree(ASTIterator input) { ASTIterator iter = new ASTLinkedList(input.firstNode()); ASTBinaryTree tree = new ASTBinaryTree(iter.nextNode()); while (iter.hasMoreNodes()) { ASTNode node = iter.nextNode(); if (node instanceof EndOfStatement) { if (iter.hasMoreNodes()) tree = new ASTBinaryTree(iter.nextNode()); } else { tree = tree.append(node); } } return tree; } }
public Class<?> getReturnType(boolean strongTyping) { if (!(root instanceof OperatorNode)) return root.getEgressType(); if (left == null || right == null) throw new RuntimeException("Malformed expression"); Class<?> leftType = left.getReturnType(strongTyping); Class<?> rightType = right.getReturnType(strongTyping); switch (((OperatorNode)root).getOperator()) { case CONTAINS:
public ASTBinaryTree append(ASTNode node) { if (comparePrecedence(root, node) >= 0) { ASTBinaryTree tree = new ASTBinaryTree(node); tree.left = this; return tree; } else { if (left == null) throw new RuntimeException("Missing left node"); if (right == null) { right = new ASTBinaryTree(node); } else { right = right.append(node); } return this; } }