Ast.UnaryExpression ParseUnaryExpr(ParseTreeNode node) { if (node.Term.Name == "UnaryExpr") { Ast.IExpression expr = ParseExpression(node.ChildNodes[1]); var opNode = node.ChildNodes[0].ChildNodes[0]; Ast.UnaryOp op = Ast.UnaryOp.Invert; switch (opNode.Token.ValueString) { case "not": op = Ast.UnaryOp.Negate; break; case "-": op = Ast.UnaryOp.Invert; break; case "#": op = Ast.UnaryOp.Length; break; } return(new Ast.UnaryExpression() { Expression = expr, Operation = op }); } throw new Exception("Invalid UnaryExpr node"); }
public UnaryOp(Ast.UnaryOp operation, Expression operand) { Operation = operation; Operand = operand; }