Exemple #1
0
        public static Lisp LoadFile(string path)
        {
            StreamReader sr     = new StreamReader(path);
            string       txt    = sr.ReadToEnd();
            Sexp         parser = new Sexp(txt);

            return(parser.Read());
        }
Exemple #2
0
        public Form1()
        {
            InitializeComponent();
            string secdComp = File.ReadAllText("../../../Compilers/compiler7.secd");
            // Read the compiler object
            Sexp sx = new Sexp(secdComp);

            compiler = sx.Read();

            vm = new VM();
        }
Exemple #3
0
        private void Compile(object sender, EventArgs e)
        {
            vm.Clear();
            vm.SetProgram(compiler);

            Sexp src  = new Sexp(txtSource.Text);
            Lisp ssrc = src.Read();

            vm.SetInput(new Cons(ssrc, null));
            Run();
            txtObject.Text = vm.Printed() + vm.STop;
        }
Exemple #4
0
        public void SetAll(string s, string e, string c, string d)
        {
            Sexp xp;

            xp = new Sexp(s);
            S  = xp.Read();
            xp = new Sexp(e);
            E  = xp.Read();
            xp = new Sexp(c);
            C  = xp.Read();
            xp = new Sexp(d);
            D  = xp.Read();
        }
Exemple #5
0
        private void RunLisp(object sender, EventArgs e)
        {
            vm.Clear();
            Sexp sx   = new Sexp(txtObject.Text);
            Lisp prog = sx.Read();

            vm.SetProgram(prog);
            string argstr = txtArgs.Text.Trim();

            if (argstr != "")
            {
                Sexp args = new Sexp(argstr);
                vm.SetInput(args.Read());
            }
            else
            {
                vm.SetInput(null);
            }
            Run();
            txtResult.Text = vm.Printed() + vm.STop;
        }