Esempio n. 1
0
        MonaProgram MkProgram(object decls, object header = null)
        {
            var pgm = new MonaProgram(header as Token, (Cons <MonaDecl>)decls, GlobalDecls, vars0, vars1, vars2, varsT);

            program = pgm;
            return(pgm);
        }
Esempio n. 2
0
        /// <summary>
        /// Parses a Mona program from a given file.
        /// </summary>
        public static MonaProgram ParseFromFile(string filename)
        {
            Stream      stream = null;
            MonaProgram pgm    = null;

            try
            {
                stream = File.OpenRead(filename);
                pgm    = Parse(stream, filename);
            }
            finally
            {
                if (stream != null)
                {
                    stream.Dispose();
                }
            }
            return(pgm);
        }
Esempio n. 3
0
        /// <summary>
        /// Parses a Mona program from a given text string.
        /// </summary>
        public static MonaProgram Parse(string text)
        {
            MemoryStream mstr = null;
            MonaProgram  pgm  = null;

            try
            {
                mstr          = new MemoryStream(Encoding.UTF8.GetBytes(text));
                mstr.Position = 0;
                pgm           = Parse(mstr, null);
            }
            finally
            {
                if (mstr != null)
                {
                    mstr.Dispose();
                }
            }
            return(pgm);
        }