Ejemplo n.º 1
0
        // Protected/Private methods --------------------------------------------------------
        protected override void Init(Stream streamHRF, string uriHRF, FileAccess mode)
        {
            tempfileName = null;

            if (mode == FileAccess.Read) {
                MemoryStream ms = new MemoryStream();
                Scanner s = new Scanner();

                if (streamHRF != null) s.Init(streamHRF);
                else s.Init(uriHRF);

                Parser p = new Parser(s);
                p.Parse(ms);

                if (p.ParserErrors.List.Count >0)
                    throw new BREException(p.ParserErrors.List.Count +
                                 		       " HRF Parser error(s), top one is: " +
                                               p.ParserErrors.List[0]);

                ms.Seek(0, SeekOrigin.Begin);
                base.Init(ms, null, FileAccess.Read);
            }
            else {
                if (streamHRF != null) resultStream = streamHRF;
                else resultStream = new FileStream(uriHRF, FileMode.Create);

                tempfileName = Path.GetTempFileName();
                base.Init(null, tempfileName, FileAccess.Write);
            }
        }
Ejemplo n.º 2
0
        private Token t; // last recognized token

        #endregion Fields

        #region Constructors

        /*------------------------------------------------------------------------*
         *----- SCANNER DESCRIPTION ----------------------------------------------*
         *------------------------------------------------------------------------*/
        public Parser(Scanner scanner)
        {
            errors = new Errors();
            this.scanner = scanner;
        }