Example #1
0
    public static int Main(string[] args)
    {
        // Create scanner that reads from standard input
        Scanner scanner = new Scanner(Console.In);

        if (args.Length > 1 ||
            (args.Length == 1 && ! args[0].Equals("-d")))
        {
            Console.Error.WriteLine("Usage: mono SPP [-d]");
            return 1;
        }

        // If command line option -d is provided, debug the scanner.
        if (args.Length == 1 && args[0].Equals("-d"))
        {
            // Console.Write("Scheme 4101> ");
            Token tok = scanner.getNextToken();
            while (tok != null)
            {
                TokenType tt = tok.getType();

                Console.Write(tt);
                if (tt == TokenType.INT)
                    Console.WriteLine(", intVal = " + tok.getIntVal());
                else if (tt == TokenType.STRING)
                    Console.WriteLine(", stringVal = " + tok.getStringVal());
                else if (tt == TokenType.IDENT)
                    Console.WriteLine(", name = " + tok.getName());
                else
                    Console.WriteLine();

                // Console.Write("Scheme 4101> ");
                tok = scanner.getNextToken();
            }
            return 0;
        }

        // Create parser
        TreeBuilder builder = new TreeBuilder();
        Parser parser = new Parser(scanner, builder);
        Node root;

        // TODO: Create and populate the built-in environment and
        // create the top-level environment
        var env = new Tree.Environment(); // create built in environment for scheme functions
        var id = new Ident("car");
        // TODO: create lines for definitions of built in functions from first page of docs
        id = new Ident("b+");
        env.define(id, new BuiltIn(id)); // populates environment--puts car into built in environment--define manages tree for you
        env = new Tree.Environment(env); //
        root = (Node) parser.parseExp();
        while (root != null)
        {
            root.print(0);
            root = (Node) parser.parseExp();
        }

        return 0;
    }
Example #2
0
    public static int Main(string[] args)
    {
        // Create scanner that reads from standard input
        Scanner scanner = new Scanner(Console.In);

        /*
         * if (args.Length > 1 ||
         *  (args.Length == 1 && ! args[0].Equals("-d")))
         * {
         *  Console.Error.WriteLine("Usage: mono SPP [-d]");
         *  return 1;
         * }
         *
         * // If command line option -d is provided, debug the scanner.
         * if (args.Length == 1 && args[0].Equals("-d"))
         * {
         *  // Console.Write("Scheme 4101> ");
         *  Token tok = scanner.getNextToken();
         *  while (tok != null)
         *  {
         *      TokenType tt = tok.getType();
         *
         *      Console.Write(tt);
         *      if (tt == TokenType.INT)
         *          Console.WriteLine(", intVal = " + tok.getIntVal());
         *      else if (tt == TokenType.STRING)
         *          Console.WriteLine(", stringVal = " + tok.getStringVal());
         *      else if (tt == TokenType.IDENT)
         *          Console.WriteLine(", name = " + tok.getName());
         *      else
         *          Console.WriteLine();
         *
         *      // Console.Write("Scheme 4101> ");
         *      tok = scanner.getNextToken();
         *  }
         *  return 0;
         * }
         */
        // Create parser
        Parser parser = new Parser(scanner);
        Node   root;
        // TODO: Create and populate the built-in environment and
        // create the top-level environment

        // Read-eval-print loop

        // TODO: print prompt and evaluate the expression
        TreeBuilder builder = new TreeBuilder();

        Tree.Environment env = new Tree.Environment();

        Console.Write("Scheme 4101> ");
        root = parser.parseExp();
        while (root != null)
        {
Example #3
0
        public static int Main(string[] args)
        {
            // Create scanner that reads from standard input
            Scanner scanner = new Scanner(Console.In);

            if (args.Length > 1 ||
                (args.Length == 1 && ! args[0].Equals("-d")))
            {
                Console.Error.WriteLine("Usage: mono SPP [-d]");
                return 1;
            }

            // If command line option -d is provided, debug the scanner.
            if (args.Length == 1 && args[0].Equals("-d"))
            {
                // Console.Write("Scheme 4101> ");
                Token tok = scanner.getNextToken();
                while (tok != null)
                {
                    TokenType tt = tok.getType();

                    Console.Write(tt);
                    if (tt == TokenType.INT)
                        Console.WriteLine(", intVal = " + tok.getIntVal());
                    else if (tt == TokenType.STRING)
                        Console.WriteLine(", stringVal = " + tok.getStringVal());
                    else if (tt == TokenType.IDENT)
                        Console.WriteLine(", name = " + tok.getName());
                    else
                        Console.WriteLine();

                    // Console.Write("Scheme 4101> ");
                    tok = scanner.getNextToken();
                }
                return 0;
            }

            // Create parser
            TreeBuilder builder = new TreeBuilder();
            Parser parser = new Parser(scanner, builder);
            Node root;

            // TODO: Create and populate the built-in environment and
            // create the top-level environment
            // Read-eval-print loop
            Tree.Environment env = new Tree.Environment();
            Node id = new Ident("car");
            env.define(id, new BuiltIn(id));
            id = new Ident("cdr");
            env.define(id, new BuiltIn(id));
            id = new Ident("cons");
            env.define(id, new BuiltIn(id));
            id = new Ident("set-car!");
            env.define(id, new BuiltIn(id));
            id = new Ident("set-cdr!");
            env.define(id, new BuiltIn(id));
            id = new Ident("null?");
            env.define(id, new BuiltIn(id));
            id = new Ident("pair?");
            env.define(id, new BuiltIn(id));
            id = new Ident("eq?");
            env.define(id, new BuiltIn(id));
            id = new Ident("symbol?");
            env.define(id, new BuiltIn(id));
            id = new Ident("number?");
            env.define(id, new BuiltIn(id));
            id = new Ident("b+");
            env.define(id, new BuiltIn(id));
            id = new Ident("b-");
            env.define(id, new BuiltIn(id));
            id = new Ident("b*");
            env.define(id, new BuiltIn(id));
            id = new Ident("b/");
            env.define(id, new BuiltIn(id));
            id = new Ident("b=");
            env.define(id, new BuiltIn(id));
            id = new Ident("b<");
            env.define(id, new BuiltIn(id));
            id = new Ident("procedure?");
            env.define(id, new BuiltIn(id));
            id = new Ident("read");
            env.define(id, new BuiltIn(id));
            id = new Ident("write");
            env.define(id, new BuiltIn(id));
            id = new Ident("display");
            env.define(id, new BuiltIn(id));
            id = new Ident("newline");
            env.define(id, new BuiltIn(id));
            id = new Ident("eval");
            env.define(id, new BuiltIn(id));
            id = new Ident("apply");
            env.define(id, new BuiltIn(id));
            id = new Ident("interaction-environment");
            env.define(id, new BuiltIn(id));
            env = new Tree.Environment(env);

            // TODO: print prompt and evaluate the expression
            root = (Node) parser.parseExp();
            while (root != null)
            {
                root.eval(env).print(0);
                root = (Node) parser.parseExp();
            }
            return 0;
        }
Example #4
0
    public static int Main(string[] args)
    {
        // Create scanner that reads from standard input
        Scanner scanner = new Scanner(Console.In);

        if (args.Length > 1 ||
            (args.Length == 1 && !args[0].Equals("-d")))
        {
            Console.Error.WriteLine("Usage: mono SPP [-d]");
            return(1);
        }

        // If command line option -d is provided, debug the scanner.
        if (args.Length == 1 && args[0].Equals("-d"))
        {
            // Console.Write("Scheme 4101> ");
            Token tok = scanner.getNextToken();
            while (tok != null)
            {
                TokenType tt = tok.getType();

                Console.Write(tt);
                if (tt == TokenType.INT)
                {
                    Console.WriteLine(", intVal = " + tok.getIntVal());
                }
                else if (tt == TokenType.STRING)
                {
                    Console.WriteLine(", stringVal = " + tok.getStringVal());
                }
                else if (tt == TokenType.IDENT)
                {
                    Console.WriteLine(", name = " + tok.getName());
                }
                else
                {
                    Console.WriteLine();
                }

                // Console.Write("Scheme 4101> ");
                tok = scanner.getNextToken();
            }
            return(0);
        }

        // Create parser
        TreeBuilder builder = new TreeBuilder();
        Parser      parser  = new Parser(scanner, builder);
        Node        root;

        // Read-eval-print loop

        Tree.Environment builtin = new Tree.Environment();

        Ident id = new Ident("symbol?");

        builtin.define(id, new BuiltIn(id));
        id = new Ident("number?");
        builtin.define(id, new BuiltIn(id));
        id = new Ident("b+");
        builtin.define(id, new BuiltIn(id));
        id = new Ident("b-");
        builtin.define(id, new BuiltIn(id));
        id = new Ident("b*");
        builtin.define(id, new BuiltIn(id));
        id = new Ident("b/");
        builtin.define(id, new BuiltIn(id));
        id = new Ident("b=");
        builtin.define(id, new BuiltIn(id));
        id = new Ident("b<");
        builtin.define(id, new BuiltIn(id));
        id = new Ident("car");
        builtin.define(id, new BuiltIn(id));
        id = new Ident("cdr");
        builtin.define(id, new BuiltIn(id));
        id = new Ident("set-car!");
        builtin.define(id, new BuiltIn(id));
        id = new Ident("set-cdr!");
        builtin.define(id, new BuiltIn(id));
        id = new Ident("null?");
        builtin.define(id, new BuiltIn(id));
        id = new Ident("pair?");
        builtin.define(id, new BuiltIn(id));
        id = new Ident("eq?");
        builtin.define(id, new BuiltIn(id));
        id = new Ident("procedure?");
        builtin.define(id, new BuiltIn(id));
        id = new Ident("read");
        builtin.define(id, new BuiltIn(id));
        id = new Ident("write");
        builtin.define(id, new BuiltIn(id));
        id = new Ident("display");
        builtin.define(id, new BuiltIn(id));
        id = new Ident("newline");
        builtin.define(id, new BuiltIn(id));
        id = new Ident("eval");
        builtin.define(id, new BuiltIn(id));
        id = new Ident("apply");
        builtin.define(id, new BuiltIn(id));
        id = new Ident("interaction-environment");
        builtin.define(id, new BuiltIn(id));


        Tree.Environment env = new Tree.Environment(builtin);
        root = (Node)parser.parseExp();
        while (root != null)
        {
            root.eval(env).print(0);
            root = (Node)parser.parseExp();
        }

        return(0);
    }
Example #5
0
    public static int Main(string[] args)
    {
        // Create scanner that reads from standard input
        Scanner scanner = new Scanner(Console.In);

        if (args.Length > 1 ||
            (args.Length == 1 && !args[0].Equals("-d")))
        {
            Console.Error.WriteLine("Usage: mono SPP [-d]");
            return(1);
        }

        // If command line option -d is provided, debug the scanner.
        if (args.Length == 1 && args[0].Equals("-d"))
        {
            // Console.Write("Scheme 4101> ");
            Token tok = scanner.getNextToken();
            while (tok != null)
            {
                TokenType tt = tok.getType();

                Console.Write(tt);
                if (tt == TokenType.INT)
                {
                    Console.WriteLine(", intVal = " + tok.getIntVal());
                }
                else if (tt == TokenType.STRING)
                {
                    Console.WriteLine(", stringVal = " + tok.getStringVal());
                }
                else if (tt == TokenType.IDENT)
                {
                    Console.WriteLine(", name = " + tok.getName());
                }
                else
                {
                    Console.WriteLine();
                }

                // Console.Write("Scheme 4101> ");
                tok = scanner.getNextToken();
            }
            return(0);
        }

        // Create parser
        TreeBuilder builder = new TreeBuilder();
        Parser      parser  = new Parser(scanner, builder);
        Node        root;

        // TODO: Create and populate the built-in environment and
        // create the top-level environment
        var env = new Tree.Environment(); // create built in environment for scheme functions
        var id  = new Ident("car");

        // TODO: create lines for definitions of built in functions from first page of docs
        id = new Ident("b+");
        env.define(id, new BuiltIn(id));  // populates environment--puts car into built in environment--define manages tree for you
        env  = new Tree.Environment(env); //
        root = (Node)parser.parseExp();
        while (root != null)
        {
            root.print(0);
            root = (Node)parser.parseExp();
        }

        return(0);
    }
Example #6
0
    public static int Main(string[] args)
    {
        // Create scanner that reads from standard input
        Scanner scanner = new Scanner(Console.In);

        if (args.Length > 1 ||
            (args.Length == 1 && !args[0].Equals("-d")))
        {
            Console.Error.WriteLine("Usage: mono SPP [-d]");
            return(1);
        }

        // If command line option -d is provided, debug the scanner.
        if (args.Length == 1 && args[0].Equals("-d"))
        {
            // Console.Write("Scheme 4101> ");
            Token tok = scanner.getNextToken();
            while (tok != null)
            {
                TokenType tt = tok.getType();

                Console.Write(tt);
                if (tt == TokenType.INT)
                {
                    Console.WriteLine(", intVal = " + tok.getIntVal());
                }
                else if (tt == TokenType.STRING)
                {
                    Console.WriteLine(", stringVal = " + tok.getStringVal());
                }
                else if (tt == TokenType.IDENT)
                {
                    Console.WriteLine(", name = " + tok.getName());
                }
                else
                {
                    Console.WriteLine();
                }

                // Console.Write("Scheme 4101> ");
                tok = scanner.getNextToken();
            }
            return(0);
        }

        // Create parser
        TreeBuilder builder = new TreeBuilder();
        Parser      parser  = new Parser(scanner, builder);
        Node        root;

        string[] builtInFunctions = new string[24]
        {
            "symbol?",
            "number?",
            "b+",
            "b-",
            "b*",
            "b/",
            "b=",
            "b<",
            "car",
            "cdr",
            "cons",
            "set-car!",
            "set-cdr!",
            "null?",
            "pair?",
            "eq?",
            "procedure?",
            "read",
            "write",
            "display",
            "newline",
            "eval",
            "apply",
            "interaction-environment"
        };
        env = new Tree.Environment();
        foreach (var function in builtInFunctions)
        {
            var ident = new Ident(function);
            env.define(ident, new BuiltIn(ident));
        }

        env = new Tree.Environment(env);

        Console.Write("> ");
        root = (Node)parser.parseExp();
        while (root != null)
        {
            root.eval(env).print(0);
            Console.Write("> ");
            root = (Node)parser.parseExp();
        }

        return(0);
    }
Example #7
0
    public static int Main(string[] args)
    {
        // Create scanner that reads from standard input
        Scanner scanner = new Scanner(Console.In);

        if (args.Length > 1 ||
            (args.Length == 1 && ! args[0].Equals("-d")))
        {
            Console.Error.WriteLine("Usage: mono SPP [-d]");
            return 1;
        }

        // If command line option -d is provided, debug the scanner.
        if (args.Length == 1 && args[0].Equals("-d"))
        {
            // Console.Write("Scheme 4101> ");
            Token tok = scanner.getNextToken();
            while (tok != null)
            {
                TokenType tt = tok.getType();

                Console.Write(tt);
                if (tt == TokenType.INT)
                    Console.WriteLine(", intVal = " + tok.getIntVal());
                else if (tt == TokenType.STRING)
                    Console.WriteLine(", stringVal = " + tok.getStringVal());
                else if (tt == TokenType.IDENT)
                    Console.WriteLine(", name = " + tok.getName());
                else
                    Console.WriteLine();

                // Console.Write("Scheme 4101> ");
                tok = scanner.getNextToken();
            }
            return 0;
        }

        // Create parser
        TreeBuilder builder = new TreeBuilder();
        Parser parser = new Parser(scanner, builder);
        Node root = new Node();

        // TODO: Create and populate the built-in environment and
        // create the top-level environment
        Tree.Environment env = new Tree.Environment();
        Ident id = new Ident("b+");
        env.define(id, new BuiltIn(id));
        env = new Tree.Environment(env);

        Ident test = new Ident("xxxx");
        IntLit test2 = new IntLit(3);

        env.define(test, test2);

        root = (Node) parser.parseExp();
        while (root != null)
        {
            root.eval(env).print(0);
            root = (Node) parser.parseExp();
        }

        // Read-eval-print loop

        // TODO: print prompt and evaluate the expression
        /*
        root = (Node) parser.parseExp();
        while (root != null)
        {
            root.print(0);
            root = (Node) parser.parseExp();
        }
        */

        return 0;
    }
Example #8
0
    public static int Main(string[] args)
    {
        // Create scanner that reads from standard input
        Scanner scanner = new Scanner(Console.In);

        if (args.Length > 1 ||
            (args.Length == 1 && !args[0].Equals("-d")))
        {
            Console.Error.WriteLine("Usage: mono SPP [-d]");
            return(1);
        }

        // If command line option -d is provided, debug the scanner.
        if (args.Length == 1 && args[0].Equals("-d"))
        {
            // Console.Write("Scheme 4101> ");
            Token tok = scanner.getNextToken();
            while (tok != null)
            {
                TokenType tt = tok.getType();

                Console.Write(tt);
                if (tt == TokenType.INT)
                {
                    Console.WriteLine(", intVal = " + tok.getIntVal());
                }
                else if (tt == TokenType.STRING)
                {
                    Console.WriteLine(", stringVal = " + tok.getStringVal());
                }
                else if (tt == TokenType.IDENT)
                {
                    Console.WriteLine(", name = " + tok.getName());
                }
                else
                {
                    Console.WriteLine();
                }

                // Console.Write("Scheme 4101> ");
                tok = scanner.getNextToken();
            }
            return(0);
        }

        // Create parser
        TreeBuilder builder = new TreeBuilder();
        Parser      parser  = new Parser(scanner, builder);
        Node        root    = new Node(parser);

        // TODO: Create and populate the built-in environment and
        Tree.Environment globalEnv = new Tree.Environment();

        Ident id = new Ident("begin");

        globalEnv.define(id, new BuiltIn(id));
        id = new Ident("cond");
        globalEnv.define(id, new BuiltIn(id));
        id = new Ident("if");
        globalEnv.define(id, new BuiltIn(id));
        id = new Ident("let");
        globalEnv.define(id, new BuiltIn(id));
        id = new Ident("read");
        globalEnv.define(id, new BuiltIn(id));
        id = new Ident("quote");
        globalEnv.define(id, new BuiltIn(id));

        id = new Ident("b+");
        globalEnv.define(id, new BuiltIn(id));
        id = new Ident("b-");
        globalEnv.define(id, new BuiltIn(id));
        id = new Ident("b/");
        globalEnv.define(id, new BuiltIn(id));
        id = new Ident("b*");
        globalEnv.define(id, new BuiltIn(id));
        id = new Ident("b=");
        globalEnv.define(id, new BuiltIn(id));
        id = new Ident("b<");
        globalEnv.define(id, new BuiltIn(id));

        // create the top-level environment
        Tree.Environment topEnv = new Tree.Environment(globalEnv);

        // Read-eval-print loop

        root = (Node)parser.parseExp();
        while (root != null)
        {
            root.eval(topEnv).print(0);
            root = (Node)parser.parseExp();
        }

        /*
         * // TODO: print prompt and evaluate the expression
         * root = (Node) parser.parseExp();
         * while (root != null)
         * {
         *  root.print(0);
         *  root = (Node) parser.parseExp();
         * }
         */
        return(0);
    }
Example #9
0
    public static int Main(string[] args)
    {
        // Create scanner that reads from standard input
        Scanner scanner = new Scanner(Console.In);

        if (args.Length > 1 ||
            (args.Length == 1 && !args[0].Equals("-d")))
        {
            Console.Error.WriteLine("Usage: mono SPP [-d]");
            return(1);
        }

        // If command line option -d is provided, debug the scanner.
        if (args.Length == 1 && args[0].Equals("-d"))
        {
            // Console.Write("Scheme 4101> ");
            Token tok = scanner.getNextToken();
            while (tok != null)
            {
                TokenType tt = tok.getType();

                Console.Write(tt);
                if (tt == TokenType.INT)
                {
                    Console.WriteLine(", intVal = " + tok.getIntVal());
                }
                else if (tt == TokenType.STRING)
                {
                    Console.WriteLine(", stringVal = " + tok.getStringVal());
                }
                else if (tt == TokenType.IDENT)
                {
                    Console.WriteLine(", name = " + tok.getName());
                }
                else
                {
                    Console.WriteLine();
                }

                // Console.Write("Scheme 4101> ");
                tok = scanner.getNextToken();
            }
            return(0);
        }

        // set this to false as default setting.
        Tree.BuiltIn.builtIn_display__do_not_print_double_quotes = false;

        // Create parser
        TreeBuilder builder = new TreeBuilder();

        parser = new Parser(scanner, builder);
        Node root;

        // Create and populate the built-in environment and

        // create the top-level environment

        // Read-eval-print loop

        root = (Node)parser.parseExp();

        Tree.Environment env_global = new Tree.Environment();
        // define environment as an identifier   for future access in scheme
        env_global.define(new Ident("global-environment"), env_global);

        Ident globalEnvIdent = new Ident("global-environment");


        Ident readBuiltIn = new Ident("read");

        env_global.define(readBuiltIn, new BuiltIn(readBuiltIn));

        Ident writeBuiltIn = new Ident("write");

        env_global.define(writeBuiltIn, new BuiltIn(writeBuiltIn));

        Ident displayBuiltIn = new Ident("display");

        env_global.define(displayBuiltIn, new BuiltIn(displayBuiltIn));

        Ident newLineBuiltIn = new Ident("newline");

        env_global.define(newLineBuiltIn, new BuiltIn(newLineBuiltIn));

        Ident evalBuiltIn = new Ident("eval");

        env_global.define(evalBuiltIn, new BuiltIn(evalBuiltIn));

        Ident eofBuiltIn = new Ident("eof-object?");

        env_global.define(eofBuiltIn, new BuiltIn(eofBuiltIn));


        Ident pred_null = new Ident("null?");

        env_global.define(pred_null, new BuiltIn(pred_null));

        Ident pred_symbol = new Ident("symbol?");

        env_global.define(pred_symbol, new BuiltIn(pred_symbol));

        Ident pred_number = new Ident("number?");

        env_global.define(pred_number, new BuiltIn(pred_number));

        Ident pred_boolean = new Ident("boolean?");

        env_global.define(pred_boolean, new BuiltIn(pred_boolean));

        Ident pred_procedure = new Ident("procedure?");

        env_global.define(pred_procedure, new BuiltIn(pred_procedure));

        Ident pred_pair = new Ident("pair?");

        env_global.define(pred_pair, new BuiltIn(pred_pair));

        Ident pred_environment = new Ident("environment?");

        env_global.define(pred_environment, new BuiltIn(pred_environment));

        Ident pred_string = new Ident("string?");

        env_global.define(pred_string, new BuiltIn(pred_string));

        Ident binary_add = new Ident("b+");

        env_global.define(binary_add, new BuiltIn(binary_add));

        Ident plus_op = new Ident("+");

        env_global.define(plus_op, binary_add);

        Ident binary_sub = new Ident("b-");

        env_global.define(binary_sub, new BuiltIn(binary_sub));

        Ident subtract_op = new Ident("-");

        env_global.define(subtract_op, binary_sub);

        Ident binary_multiplic = new Ident("b*");

        env_global.define(binary_multiplic, new BuiltIn(binary_multiplic));

        Ident multiply_op = new Ident("*");

        env_global.define(multiply_op, binary_multiplic);

        Ident binary_division = new Ident("b/");

        env_global.define(binary_division, new BuiltIn(binary_division));

        Ident divide_op = new Ident("/");

        env_global.define(divide_op, binary_division);

        Ident binary_equality = new Ident("b=");

        env_global.define(binary_equality, new BuiltIn(binary_equality));

        Ident equality_op = new Ident("=");

        env_global.define(equality_op, binary_equality);

        Ident binary_lessthan = new Ident("b<");

        env_global.define(binary_lessthan, new BuiltIn(binary_lessthan));

        Ident lessthan_op = new Ident("<");

        env_global.define(lessthan_op, binary_lessthan);

        Ident binary_greaterthan = new Ident("b>");

        env_global.define(binary_greaterthan, new BuiltIn(binary_greaterthan));

        Ident greaterthan_op = new Ident(">");

        env_global.define(greaterthan_op, binary_greaterthan);

        Ident binary_lessthanEq = new Ident("b<=");

        env_global.define(binary_lessthanEq, new BuiltIn(binary_lessthanEq));

        Ident lessthanEq_op = new Ident("<=");

        env_global.define(lessthanEq_op, binary_lessthanEq);

        Ident binary_greaterthanEq = new Ident("b>=");

        env_global.define(binary_greaterthanEq, new BuiltIn(binary_greaterthanEq));

        Ident greaterthanEq_op = new Ident(">=");

        env_global.define(greaterthanEq_op, binary_greaterthanEq);


        Ident not_op = new Ident("not");

        env_global.define(not_op, new BuiltIn(not_op));


        Ident pred_equal = new Ident("eq?");

        env_global.define(pred_equal, new BuiltIn(pred_equal));

        Ident listBuiltIn = new Ident("list");

        env_global.define(listBuiltIn, new BuiltIn(listBuiltIn));

        Ident carBuiltIn = new Ident("car");

        env_global.define(carBuiltIn, new BuiltIn(carBuiltIn));

        Ident cdrBuiltIn = new Ident("cdr");

        env_global.define(cdrBuiltIn, new BuiltIn(cdrBuiltIn));

        Ident consBuiltIn = new Ident("cons");

        env_global.define(consBuiltIn, new BuiltIn(consBuiltIn));

        Ident setCarBuiltIn = new Ident("set-car!");

        env_global.define(setCarBuiltIn, new BuiltIn(setCarBuiltIn));

        Ident setCdrBuiltIn = new Ident("set-cdr!");

        env_global.define(setCdrBuiltIn, new BuiltIn(setCdrBuiltIn));



        // working on top level loop
        Tree.Environment top_level = new Tree.Environment(env_global);

        // define top-level Scheme scm function

        // lets define the S-expression for (define (Scheme) ... func )

        Ident defineIdent = new Ident("define");

        Ident SchemeIdent = new Ident("Scheme");

        Cons cons_holdingSchemeIdent = new Cons(SchemeIdent, Nil.getInstance());



        StringLit printpromptScheme = new StringLit("Scheme 4101> ");

        Cons cons_holding_display_promptStr = new Cons(displayBuiltIn, new Cons(printpromptScheme, Nil.getInstance()));


        Ident LetIdent = new Ident("let");

        Ident InputIdent = new Ident("input");

        Ident If_Ident = new Ident("if");

        Cons cons_holding_assocList = new Cons(new Cons(InputIdent, new Cons(new Cons(readBuiltIn, Nil.getInstance()), Nil.getInstance())), Nil.getInstance());

        Ident BeginIdent = new Ident("begin");



        Cons cons_holding_write_SchemeCode = new Cons(writeBuiltIn, new Cons(new Cons(evalBuiltIn, new Cons(InputIdent, new Cons(globalEnvIdent, Nil.getInstance()))), Nil.getInstance()));

        Cons cons_holding_begin_SchemeCode = new Cons(BeginIdent, new Cons(cons_holding_write_SchemeCode,

                                                                           new Cons(new Cons(newLineBuiltIn, Nil.getInstance()), new Cons(new Cons(SchemeIdent, Nil.getInstance()), Nil.getInstance()))));


        Cons cons_holding_newline = new Cons(new Cons(newLineBuiltIn, Nil.getInstance()), Nil.getInstance());


        Cons cons_holding_not = new Cons(not_op, new Cons(new Cons(eofBuiltIn, new Cons(InputIdent, Nil.getInstance())), Nil.getInstance()));

        Cons cons_holding_if_SchemeCode = new Cons(If_Ident, new Cons(cons_holding_not, new Cons(cons_holding_begin_SchemeCode, cons_holding_newline)));


        Cons cons_holding_let_SchemeCode = new Cons(LetIdent, new Cons(cons_holding_assocList, new Cons(cons_holding_if_SchemeCode, Nil.getInstance())));

        // done defining subcomponents of  top-level Scheme scm function

        // here is a parse tree defining func (Scheme)...
        Cons define_Scheme = new Cons(defineIdent, new Cons(cons_holdingSchemeIdent, new Cons(cons_holding_display_promptStr,
                                                                                              new Cons(cons_holding_let_SchemeCode, Nil.getInstance()))));


        define_Scheme.eval(top_level);


        cons_holdingSchemeIdent.eval(top_level);



        return(0);
    }