Esempio n. 1
0
        public static Object Load(Cons args, Environment environment)
        {
            object filename = args.First();

            if (filename is string)
            {
                TextReader textReader = new StreamReader((string)filename);

                string buffer = textReader.ReadToEnd();

                textReader.Close();

                // We want to evaluate the whole file, so there is an implicit do
                // which we now make explicit
                string expression = string.Format("(do {0})", buffer);

                object input  = Reader.Read(new StringReader(expression), ReadTable.DefaultReadTable());
                object output = Runtime.Eval(input, environment);

                return(output);
            }
            throw new LSharpException(String.Format("Using: {0} is not a string", filename));
        }
Esempio n. 2
0
        public void InitialiseLSharpBindings()
        {
            isresetting = true;

            foreach (Extension e in extensions)
            {
                InitSymbols(e.type, e.delegatetype);
                extmark++;
            }

            // leppie: should this not be Assign() ?
            // read table
            Assign(Symbol.FromName("*readtable*"), ReadTable.DefaultReadTable());

            // Macros
            foreach (Type t in macroextensions)
            {
                InitMacros(t);
            }


            isresetting = false;
        }