예제 #1
0
        static void Main(string[] args)
        {
            DisPoseLine dp = new DisPoseLine("Function: littlemm\r\nvar\r\na1, a2, n, sum, const1: integer;\r\n\r\nbegin\r\na1:= 1;\r\na2:= 1;\r\nn:= 3;\r\n\r\nsum:= 0;\r\nconst1:= 1;\r\n\r\nif n = const1 then\r\nsum:= 1\r\nelse\r\nsum:= 1;\r\nbegin \r\n\twhile n> const1\r\n\tdo \r\n\tbegin sum:= sum + a2; temp:= a1; a1:= a2; a2:= a2 + temp; n:= n - 1 end\r\nend\r\nend  ");

            dp.Dispose();

            Semantic s = new Semantic(dp);

            s.Dispose();

            foreach (FourPart f in s.fourparts)
            {
                Console.WriteLine(" < " + f.Op + " , " + f.StrLeft + " , " + f.StrRight + " , " + f.JumpNum + " >");
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            DisPoseLine disPoseLine = new DisPoseLine("\r\nFunction : littlemm\r\nvar\r\nsum,b,temp: integer;\r\n \r\nbegin\r\nsum:=1;\r\nb:=4;\r\ntemp:=0;\r\nwhile b>temp\r\ndo begin sum:=sum*b;b:=b-1 end\r\n;\r\nend ");

            //  DisPoseLine disPoseLine = new DisPoseLine("Function : littlemm\r\nvar\r\na,b,n: integer;\r\n \r\nbegin\r\na:=10;\r\nb:=20;\r\nif a>b\r\nthen begin a:=10;b:=11; end\r\nelse begin a:=20;b:=a+20; end\r\n;\r\nwhile a>b\r\ndo begin a:=a-1; end\r\n;\r\nend ");
            disPoseLine.Dispose();
            Semantic semantic = new Semantic(disPoseLine);

            semantic.Dispose();

            string s     = JsonConvert.SerializeObject(semantic.fourparts);
            string fuhao = JsonConvert.SerializeObject(semantic.symbles);

            ScriptRuntime pyrun = Python.CreateRuntime();
            dynamic       py    = pyrun.UseFile("../../Interpreter.py");
            var           re    = py.Interprete(s, fuhao);
            //var path = py.path();
            //  var v = py.v();
            //var pys = py.String(s);
        }