X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Floader%2FParser.cpp;h=6e5cbe014918a74846b67e6de7f68759e11bb6ee;hb=32be49517984befd2f8bc4b8f7edc2fec963a1da;hp=d6abcc39561e4b70f8fce0ced7ce880580701ad0;hpb=322be5954c0f8df6a9e3aaeb2456783a814d52c3;p=l2e.git diff --git a/src/loader/Parser.cpp b/src/loader/Parser.cpp index d6abcc3..6e5cbe0 100644 --- a/src/loader/Parser.cpp +++ b/src/loader/Parser.cpp @@ -7,6 +7,8 @@ #include "Parser.h" +#include "utility.h" + #include #include @@ -17,9 +19,10 @@ using std::vector; namespace loader { -Parser::Parser(const char *file, ParsedSource &product) +Parser::Parser(const string &file, ParsedSource &product) : file(file) -, in(file) +, dirname(Dirname(file)) +, in(this->file.c_str()) , tok(in) , product(product) { if (!in) { @@ -74,7 +77,7 @@ void Parser::ParseExportDirective() { void Parser::ParseIncludeDirective() { Tokenizer::Token t(GetToken()); AssertTokenType(t.type, Tokenizer::Token::STRING); - Parser sub(t.str.c_str(), product); // TODO: resolve path name + Parser sub(CatPath(dirname, t.str), product); sub.Parse(); } @@ -104,6 +107,7 @@ Declaration *Parser::ProbeDefinition() { bool Parser::BeginningOfLiteral(const Tokenizer::Token &t) const { switch (t.type) { case Tokenizer::Token::CHEVRON_OPEN: + case Tokenizer::Token::COLON: case Tokenizer::Token::BRACKET_OPEN: case Tokenizer::Token::PARENTHESIS_OPEN: case Tokenizer::Token::NUMBER: @@ -202,6 +206,10 @@ Literal *Parser::ParseLiteral() { case Tokenizer::Token::CHEVRON_OPEN: tok.Putback(t); return ParseVector(); + case Tokenizer::Token::COLON: + t = GetToken(); + AssertTokenType(t.type, Tokenizer::Token::STRING); + return new Literal(dirname, t.str); case Tokenizer::Token::BRACKET_OPEN: tok.Putback(t); return ParseArray();