示例#1
0
        public static BinaryFileSchema ParseBfs(BinaryFileSchema schema, string source, IBfsErrorHandler errorHandler)
        {
            gotError = false;
            handler = errorHandler;
            BinaryFileSchemaParser.BinaryFileSchemaParser parser = new BinaryFileSchemaParser.BinaryFileSchemaParser();
            parser.Construct(source, new StreamErrorHandler(errorHandler) );
            bool matches = false;
            try
            {
                matches = parser.bfschema();
            }
            catch (PegException ex)
            {
                errorHandler.HandleMessage(ex.Message);
            }

            if (!matches)
            {
                ReportMessage("Schema didn't parse.");
                return null;
            }

            AstConvert converter = new AstConvert(schema,source);
            schema = converter.GetBFSTree(parser.GetRoot());
            schema = CheckBfs(schema,errorHandler);

            return schema;
        }