Cleanup and support for relative paths

This commit is contained in:
Borna Rajković committed 2022-04-12 23:37:05 +02:00
1 parent 389113722e
commit c17fbd2dcf
11 files changed
+339 -73

No files matched your search

+1 -2
View File
@@ -1016,8 +1016,7 @@ PResult<ValueNode> ComdelParser::parseValue() {
return unexpected();
}
//return spanner(value);
return value;
return spanner(value);
}
std::optional<SchemaNode> ComdelParser::parseSchema() {
+12 -1
View File
@@ -5,6 +5,7 @@
#include <iostream>
#include <fstream>
#include <string>
#include <QDir>
std::optional<LibraryNode> loadLibraryFromFile(ParseContext * parseContext,
const char* name,
@@ -75,7 +76,17 @@ std::optional<SchemaNode> loadSchemaFromFile(ParseContext * parseContext,
}
if(unit->source) {
unit->library = loadLibraryFromFile(parseContext, unit->source->asString().c_str(), stream);
QFileInfo info(name);
auto filepath = info.absolutePath();
QDir dir;
dir.setCurrent(filepath);
auto libraryPath = dir.absoluteFilePath(QString::fromStdString(unit->source->asString()));
unit->library = loadLibraryFromFile(parseContext, libraryPath.toUtf8().data(), stream);
if(unit->library == std::nullopt) {
return std::nullopt;
}
}