private Tree<S> parseSequence(Tree<S> currentTree) { // at this point, i have already seen at least an open parenthesis AND // an atom. If the next character is a character is a close parenthesis, // then I just return the input. NOTE: DO NOT MOVE THE TOKEN POINTER. String currentToken = tokens.get(currentTokenId); if (currentToken.equals(")")) { return currentTree; } else { // now we have something here. that should be an expression followed // by a sequence. Find the expression, attach it to the current // tree. Then give that combined tree to the sequence parser and // return whatever it gives. parseExpr(currentTree); return parseSequence(currentTree); } }
private Tree<S> parseSequence(Tree<S> currentTree) { // at this point, i have already seen at least an open parenthesis AND // an atom. If the next character is a character is a close parenthesis, // then I just return the input. NOTE: DO NOT MOVE THE TOKEN POINTER. String currentToken = tokens.get(currentTokenId); if (currentToken.equals(")")) { return currentTree; } else { // now we have something here. that should be an expression followed // by a sequence. Find the expression, attach it to the current // tree. Then give that combined tree to the sequence parser and // return whatever it gives. parseExpr(currentTree); return parseSequence(currentTree); } }
public Tree<S> parse(String treeString) { tokens = tokenize(treeString); currentTokenId = 0; Tree<S> tree = parseExpr(new Tree<S>()); Tree<S> t1 = tree.getChild(0); t1.makeParentNull(); return t1; }
public Tree<S> parse(String treeString) { tokens = tokenize(treeString); currentTokenId = 0; Tree<S> tree = parseExpr(new Tree<S>()); Tree<S> t1 = tree.getChild(0); t1.makeParentNull(); return t1; }