public String parseFormula(String formula,Node node){
  String subformula;
  String restFormula;
  Node left;
  Node right;
  char op;
  if (formula == null) {
    return null;
  }
  subformula=parseValue(formula,node);
  if (subformula == null || subformula.length() == 0) {
    return null;
  }
  if (subformula.equals(formula)) {
    return formula;
  }
switch (op=subformula.charAt(0)) {
case 0:
    return null;
case ')':
  return subformula;
case '+':
case '*':
case '-':
case '/':
restFormula=subformula.substring(1);
subformula=parseValue(restFormula,right=new Node());
if (subformula == null ? restFormula != null : !subformula.equals(restFormula)) {
left=new Node(node);
node.left=left;
node.right=right;
node.op=op;
node.type=Node.OP;
return subformula;
}
 else {
return formula;
}
default :
return formula;
}
}

public String parseFormula ( String formula , Node node ) { String subformula ; String restFormula ; Node left ; Node right ; char op ; if ( formula == null ) { return null ; } subformula = parseValue ( formula , node ) ; if ( subformula == null || subformula . length ( ) == 0 ) { return null ; } if ( subformula . equals ( formula ) ) { return formula ; } switch ( op = subformula . charAt ( 0 ) ) { case 0 : return null ; case ')' : return subformula ; case '+' : case '*' : case '-' : case '/' : restFormula = subformula . substring ( 1 ) ; subformula = parseValue ( restFormula , right = new Node ( ) ) ; if ( subformula == null ? restFormula != null : ! subformula . equals ( restFormula ) ) { left = new Node ( node ) ; node . left = left ; node . right = right ; node . op = op ; node . type = Node . OP ; return subformula ; } else { return formula ; } default : return formula ; } }
parse a spreadsheet formula . the syntax is defined as : formula - > value formula - > value op value value - > ' ( ' formula ' ) ' value - > cell value - > < number > op - > ' + ' | ' * ' | ' / ' | ' - ' cell - > < letter > < number >
