예제 #1
0
        internal LispObject Evaluate(string command)
        {
            getInterpreter();
            LispObject cmd    = Lisp.readObjectFromString(command);
            LispObject result = Lisp.eval(cmd);

            return(result);
        }
예제 #2
0
        public override object Eval(object p)
        {
            //ClientManager.debugLevel = 2;
            getInterpreter();
            WriteLine("ABCL EVAL: " + ToStr(p));
            try
            {
                if (p is LispObject)
                {
                    return(Lisp.eval((LispObject)p));
                }
            }

            catch (Exception e)
            {
                WriteLine(e.ToString());
            }
            return(p);
        }
예제 #3
0
 internal void ExecuteFile(string p)
 {
     getInterpreter();
     Lisp.eval(new Cons(Symbol.LOAD, new Cons(new SimpleString(p), Lisp.NIL)));
 }
예제 #4
0
        static void Main(string[] args)
        {
            //LispTest.UnitTest();

            bool needHelp = true;

            for (int i = 0; i < args.Length; ++i)
            {
                switch (args[i])
                {
                case "-include":
                    // 読み込むファイルが指定されている。
                    eval(args[i + 1], true);
                    needHelp = false;
                    ++i;
                    break;

                case "-import":
                    // 読み込むファイルが指定されている。
                    eval(args[i + 1], false);
                    needHelp = false;
                    ++i;
                    break;

                case "-test":
                    // UnitTest
                    LispTest.UnitTest();
                    needHelp = false;
                    break;

                // http://d.hatena.ne.jp/ak11/20091122 のpatch
                case "-compile":
                    try
                    {
                        string filename = args[++i];
                        string output   = args[++i];
                        // 出力ファイルよりソースファイルが新しい時のみ処理
                        if (!File.Exists(output) ||
                            File.GetLastWriteTime(output) < File.GetLastWriteTime(filename))
                        {
                            Console.WriteLine(filename + " => " + output);
                            var lisp = new Lisp();
                            lisp.setVar("outfile", new SExp {
                                elms = output
                            });
                            SExp ret = lisp.eval(new ConvSExp().import(filename));
                            //	Console.WriteLine(lisp.SExp2string(ret));
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                    needHelp = false;
                    break;


                case "-help":
                case "-h":
                    Help();
                    needHelp = false;
                    break;
                }
            }

            if (needHelp)
            {
                Help();
            }
        }
예제 #5
0
        public Symbol Intern(string p, object globalcogbotTextForm, List <object> exceptFor, java.lang.Class ic, int depth)
        {
            Package pkg = CurrentPackage();

            if (p == null)
            {
                p = ic.getName();
                p = p.ToString();
            }
            p = p.ToUpper();
            Symbol     s  = Lisp.intern(p, pkg);
            LispObject sv = s.getSymbolValue();

            if (sv is JavaObject)
            {
                if (sv.javaInstance() == globalcogbotTextForm)
                {
                    return(s);
                }
            }
            Symbol fun  = pkg.findAccessibleSymbol("SYMBOL-JOBJECT");
            String mask = String.Format("{0} {1}", p, ic.getName());

            if (fun != null && !allExceptFor.Contains(mask))
            {
                allExceptFor.Add(mask);
                LispObject vtemp = s.getSymbolValue();
                s.setSymbolValue(s);
                var jclass = JavaObject.getInstance(ic);
                Lisp.eval(Lisp.list4(fun, new SimpleString(p), s, jclass));
                s.setSymbolValue(vtemp);
                depth++;
            }
            if (globalcogbotTextForm != null)
            {
                LispObject jo = JavaObject.getInstance(globalcogbotTextForm);
                s.setSymbolValue(jo);

                if (exceptFor.Contains(globalcogbotTextForm))
                {
                    return(s);
                }
                exceptFor.Add(globalcogbotTextForm);
            }

            if (true)
            {
                return(s);
            }

            String ns = ic.getName();

            if (!useClassname(ns))
            {
                return(s);
            }
            if (depth > 0)
            {
                AddMembers(p, s, ic, exceptFor, depth - 1);
            }
            return(s);
        }