private Node factor() { Node node = null; switch (currentToken.type) { case "integer": node = new IntNode(currentToken); match(Token.INT); break; case "string": node = new StrNode(currentToken); match(Token.STRING); break; case "boolean": node = new BoolNode(currentToken); match(Token.BOOL); break; case "identifier": node = new IdNode(currentToken); match(Token.ID); break; case "lpar": nextToken(); node = expr(); match(Token.RPAR); break; case "negation": node = new UnOpNode(currentToken); match(Token.NEG); node.addChild(factor()); break; default: new SyntaxError(currentToken, "Syntax Error: Expected integer, string, bool, identifier or (, got " + currentToken.value); break; } return(node); }
object IVisitor <object> .visit(BoolNode node) { node.type = Token.BOOL; return(node.type); }
object IVisitor <object> .visit(BoolNode node) { return(null); }
object IVisitor <object> .visit(BoolNode node) { return(Convert.ToBoolean(node.value)); }