X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Floader%2FParser.h;h=b4f1b8d270b17ff93a02e2388bec310d0609743c;hb=8d3decb97c252bc7b0ba4b9b5def0b04dfcb8e00;hp=923a42439bdb828b99bb57bee2a7d19077708880;hpb=af9e0b57dac45dc5591f16fb34236b1356cda8a2;p=l2e.git diff --git a/src/loader/Parser.h b/src/loader/Parser.h index 923a424..b4f1b8d 100644 --- a/src/loader/Parser.h +++ b/src/loader/Parser.h @@ -11,6 +11,7 @@ #include "ParsedSource.h" #include "Tokenizer.h" +#include #include #include #include @@ -25,7 +26,8 @@ class PropertyList; class Parser { public: - Parser(std::istream &in, ParsedSource &product) : tok(in), product(product) { } + Parser(const char *file, ParsedSource &product) + : file(file), in(file), tok(in), product(product) { } ~Parser() { } private: Parser(const Parser &); @@ -35,12 +37,19 @@ public: void Parse(); public: - class ParseError: public std::runtime_error { + class Error: public std::runtime_error { public: - explicit ParseError(const std::string &msg) : std::runtime_error(msg) { }; + Error(const char *file, int line, const std::string &msg) + : std::runtime_error(msg), file(file), line(line) { }; + const char *File() const { return file; } + int Line() const { return line; } + private: + const char *file; + int line; }; private: + Tokenizer::Token GetToken(); void ParseStatement(); void ParseExportDirective(); void ParseIncludeDirective(); @@ -65,6 +74,8 @@ private: bool BeginOfPropertyList(const Tokenizer::Token &) const; private: + const char *file; + std::ifstream in; Tokenizer tok; ParsedSource &product;