X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Floader%2FParser.h;h=75cd5fec48740fe0bbf59638572dc7f3c852ee19;hb=107657a15613dfd6f02556e163abf6a4cb3cdd39;hp=9e4cbf4551de5bd5e71ffe133e9afdcc5a0c4498;hpb=322be5954c0f8df6a9e3aaeb2456783a814d52c3;p=l2e.git diff --git a/src/loader/Parser.h b/src/loader/Parser.h index 9e4cbf4..75cd5fe 100644 --- a/src/loader/Parser.h +++ b/src/loader/Parser.h @@ -1,13 +1,7 @@ -/* - * Parser.h - * - * Created on: Aug 26, 2012 - * Author: holy - */ - #ifndef LOADER_PARSER_H_ #define LOADER_PARSER_H_ +#include "fwd.h" #include "ParsedSource.h" #include "Tokenizer.h" @@ -18,15 +12,10 @@ namespace loader { -class Declaration; -class Definition; -class Literal; -class PropertyList; - class Parser { public: - Parser(const char *file, ParsedSource &product); + Parser(const std::string &file, ParsedSource &product); ~Parser() { } private: Parser(const Parser &); @@ -38,12 +27,13 @@ public: public: class Error: public std::runtime_error { public: - Error(const char *file, int line, const std::string &msg) + Error(const std::string &file, int line, const std::string &msg) : std::runtime_error(msg), file(file), line(line) { }; - const char *File() const { return file; } + ~Error() throw() { } + const std::string &File() const { return file; } int Line() const { return line; } private: - const char *file; + std::string file; int line; }; @@ -65,15 +55,19 @@ private: Literal *ParseArray(); Literal *ParseColor(); Literal *ParseVector(); + Literal *ParseScript(); private: void AssertTokenType(Tokenizer::Token::Type actual, Tokenizer::Token::Type expected); void AssertTokenType(Tokenizer::Token::Type actual, Tokenizer::Token::Type expected, const std::string &msg); bool BeginningOfLiteral(const Tokenizer::Token &) const; + bool BeginningOfPrimitiveLiteral(const Tokenizer::Token &) const; bool BeginOfPropertyList(const Tokenizer::Token &) const; + bool BeginningOfScriptLiteral(const Tokenizer::Token &) const; private: - const char *file; + std::string file; + std::string dirname; std::ifstream in; Tokenizer tok; ParsedSource &product;