Ejemplo n.º 1
0
    [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);
    }
Ejemplo n.º 2
0
    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);
    }
Ejemplo n.º 3
0
 private static double EvalNumber(Racr.AstNode node)
 {
     return(node.GetValue());
 }
Ejemplo n.º 4
0
 [AgRule("Value", "Constant")] static object ConstantValue(Ast n)
 {
     return(n.Type() == Types.ErrorType ? ErrorValue : n.GetValue());
 }
Ejemplo n.º 5
0
 [AgRule("SExpr", "Constant")] static string ConstantSExpr(Ast n)
 {
     return("(~! " + Lexer.EscapeValue(n.GetValue()) + ")");
 }
Ejemplo n.º 6
0
 [AgRule("SExpr", "OrdinaryQuestion")] static string OrdinaryQuestionSExpr(Ast n)
 {
     return("(?? '" + n.GetName() + " " + Lexer.EscapeString(n.GetLabel()) + " " + n.Type() + " " +
            (n.GetValue() == ErrorValue ? "" : Lexer.EscapeValue(n.GetValue())) + ")");
 }
Ejemplo n.º 7
0
 [AgRule("Type", "Constant")] static Types ConstantType(Ast n)
 {
     return(ValueToType(n.GetValue()));
 }
Ejemplo n.º 8
0
 static object ConstantValue(Racr.AstNode n)
 {
     return(n.GetValue());
 }
Ejemplo n.º 9
0
 static object OrdinaryQuestionValue(Racr.AstNode n)
 {
     return(n.GetValue());
 }