public static StringExpression Analyze(Parsing.SAtom expr) { string text = expr.Text; string literal = text.Substring(1, text.Length - 2); // Discards the opening & closing double quotes return(new StringExpression(literal)); }
public void AddAndClearCache() { var symbol = new SAtom(cache.ToString()); stack.Peek().Add(symbol); cache.Clear(); }
public static Variable Analyze(Parsing.SAtom expr) { if (Utils.IsValidIdentifier(expr.Text)) { return(new Variable(expr.Text)); } else { throw new BadSyntaxException("variable", "Invalid identifier", expr.Text); } }
public static Expression Analyze(Parsing.SAtom sExpr) { if (sExpr.Text == "#t") { return(new BooleanExpression(true)); } else if (sExpr.Text == "#f") { return(new BooleanExpression(false)); } // This case should have been intercepted before entering this function else { throw new ArgumentException($"Unknown boolean literal: {sExpr.Text}"); } }
public static bool IsInstance(Parsing.SAtom sExpr) { return(sExpr.Text == "#t" || sExpr.Text == "#f"); }
public static bool IsInstance(Parsing.SAtom expr) { string text = expr.Text; return(text.Length >= 2 && text[0] == '\"' && text[text.Length - 1] == '\"'); }
public static bool IsInstance(Parsing.SAtom expr) { return(BigInteger.TryParse(expr.Text, out _)); }
public static NumberExpression Analyze(Parsing.SAtom expr) { return(new NumberExpression(expr.Text)); }