コード例 #1
0
        public string GenerateCode(string txt, string initialDisplay, bool debug, out Program p, out CodePiece cp)
        {
            p = GenerateAst(txt) as Program;

            GenerateTime = Environment.TickCount;
            cp           = p.GenerateCode(initialDisplay);
            GenerateTime = Environment.TickCount - GenerateTime;

            string result;

            if (debug)
            {
                result = cp.ToString();
            }
            else
            {
                result = cp.ToSimpleString();
            }

            return(result);
        }
コード例 #2
0
        public bool TryParse(string txt, string disp, out BefunGenException err, out Program prog)
        {
            ParseTime = Environment.TickCount;

            Program result = null;

            try
            {
                result = (Program)Parse(txt);
            }
            catch (BefunGenException e)
            {
                err  = e;
                prog = null;
                return(false);
            }
            catch (Exception e)
            {
                err  = new NativeException(e);
                prog = null;
                return(false);
            }

            if (result == null)
            {
                err  = new WTFException();
                prog = null;
                return(false);
            }

            try
            {
                result.Prepare();
            }
            catch (BefunGenException e)
            {
                err  = e;
                prog = null;
                return(false);
            }
            catch (Exception e)
            {
                err  = new NativeException(e);
                prog = null;
                return(false);
            }

            try
            {
                result.GenerateCode(disp);
            }
            catch (BefunGenException e)
            {
                err  = e;
                prog = null;
                return(false);
            }
            catch (Exception e)
            {
                err  = new NativeException(e);
                prog = null;
                return(false);
            }

            ParseTime = Environment.TickCount - ParseTime;

            err  = null;
            prog = result;
            return(true);
        }