/** This is the entry point for parsing when you have source stream and the textual name of that stream, and is also called */ bool ZASParser::sParse(const ZFileSpec& iFileSpec, const ZStreamR& iStream, ParseHandler& iParseHandler, const StreamProvider& iStreamProvider, const ErrorHandler& iErrorHandler, IncludeHandler* iIncludeHandler) { try { Parser theParser(iParseHandler, iStreamProvider, iErrorHandler, iIncludeHandler); iParseHandler.StartParse(); theParser.Parse(iFileSpec, iStream); iParseHandler.EndParse(); return true; } catch (NestedParse& ex) { printf("EX4\n"); iErrorHandler.ReportError(ex.GetSources(), ex.GetMessage()); } catch (exception& ex) { printf("EX5\n"); iErrorHandler.ReportError(ex.what()); } catch (...) { iErrorHandler.ReportError("Unknown exception"); } return false; }
/** This is the entry point for parsing when you have a source file's path. It just attempts to open the file and passes it on to the stream-taking sParse, which is responsible for actually catching and reporting parse exceptions. */ bool ZASParser::sParse(const string& iPath, ParseHandler& iParseHandler, const StreamProvider& iStreamProvider, const ErrorHandler& iErrorHandler, IncludeHandler* iIncludeHandler) { ZFileSpec fileSpecUsed; if (ZRef<ZStreamerR> theStreamer = iStreamProvider.ProvideStreamSource(ZFileSpec(), iPath, true, fileSpecUsed)) { return sParse(fileSpecUsed, theStreamer->GetStreamR(), iParseHandler, iStreamProvider, iErrorHandler, iIncludeHandler); } else { iErrorHandler.ReportError("Could not open source file \"" + iPath + "\""); } return false; }