public static Node parseTerm() { Node tree = parseFactor(); while ( tokens.actual.type == TokenType.MULTIPLY || tokens.actual.type == TokenType.DIVIDE || tokens.actual.type == TokenType.AND) { tree = new BinOp(tokens.actual.Copy(), new List <Node>() { tree }); tokens.selectNext(); tree.children.Add(parseFactor()); } return(tree); }
public static Node parseExpression() { Node tree = parseTerm(); while ( tokens.actual.type == TokenType.PLUS || tokens.actual.type == TokenType.MINUS || tokens.actual.type == TokenType.OR) { tree = new BinOp(tokens.actual.Copy(), new List <Node>() { tree }); tokens.selectNext(); tree.children.Add(parseTerm()); } return(tree); }
public static Node parseRelExpression() { Node output = parseExpression(); if ( (tokens.actual.type == TokenType.EQUAL) || (tokens.actual.type == TokenType.BIGGERTHEN) || (tokens.actual.type == TokenType.SMALLERTHEN) ) { output = new BinOp(tokens.actual.Copy(), new List <Node>() { output }); tokens.selectNext(); output.children.Add(parseExpression()); } return(output); }