]> git.localhorst.tv Git - l2e.git/blobdiff - src/loader/Parser.cpp
resolve inclusion path name in Parser
[l2e.git] / src / loader / Parser.cpp
index d6abcc39561e4b70f8fce0ced7ce880580701ad0..bd65200ab8bc674bf983d4791962231d5ab21a40 100644 (file)
@@ -7,6 +7,8 @@
 
 #include "Parser.h"
 
+#include "utility.h"
+
 #include <auto_ptr.h>
 #include <fstream>
 
@@ -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();
 }