[AgRule("Value", "OrdinaryQuestion")] static object OrdinaryQuestionValue(Ast n) { if (n.Type() == Types.ErrorType) { return(ErrorValue); } var acceptor = TypeToAcceptor(n.Type()); // acceptor is never null return(acceptor(n.GetValue()) ? n.GetValue() : ErrorValue); }
static ValueTypes ConstantType(Racr.AstNode n) { var val = n.GetValue(); if (val is bool) { return(ValueTypes.Boolean); } if (val is double) { return(ValueTypes.Number); } if (val is string) { return(ValueTypes.String); } return(ValueTypes.ErrorType); }
private static double EvalNumber(Racr.AstNode node) { return(node.GetValue()); }
[AgRule("Value", "Constant")] static object ConstantValue(Ast n) { return(n.Type() == Types.ErrorType ? ErrorValue : n.GetValue()); }
[AgRule("SExpr", "Constant")] static string ConstantSExpr(Ast n) { return("(~! " + Lexer.EscapeValue(n.GetValue()) + ")"); }
[AgRule("SExpr", "OrdinaryQuestion")] static string OrdinaryQuestionSExpr(Ast n) { return("(?? '" + n.GetName() + " " + Lexer.EscapeString(n.GetLabel()) + " " + n.Type() + " " + (n.GetValue() == ErrorValue ? "" : Lexer.EscapeValue(n.GetValue())) + ")"); }
[AgRule("Type", "Constant")] static Types ConstantType(Ast n) { return(ValueToType(n.GetValue())); }
static object ConstantValue(Racr.AstNode n) { return(n.GetValue()); }
static object OrdinaryQuestionValue(Racr.AstNode n) { return(n.GetValue()); }