Exemple #1
0
        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));
        }
Exemple #2
0
            public void AddAndClearCache()
            {
                var symbol = new SAtom(cache.ToString());

                stack.Peek().Add(symbol);
                cache.Clear();
            }
Exemple #3
0
 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);
     }
 }
Exemple #4
0
 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}");
     }
 }
Exemple #5
0
 public static bool IsInstance(Parsing.SAtom sExpr)
 {
     return(sExpr.Text == "#t" || sExpr.Text == "#f");
 }
Exemple #6
0
        public static bool IsInstance(Parsing.SAtom expr)
        {
            string text = expr.Text;

            return(text.Length >= 2 && text[0] == '\"' && text[text.Length - 1] == '\"');
        }
Exemple #7
0
 public static bool IsInstance(Parsing.SAtom expr)
 {
     return(BigInteger.TryParse(expr.Text, out _));
 }
Exemple #8
0
 public static NumberExpression Analyze(Parsing.SAtom expr)
 {
     return(new NumberExpression(expr.Text));
 }