aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-dataloader/v2script/Parser.cpp
diff options
context:
space:
mode:
author Spartan322 <Megacake1234@gmail.com>2023-10-09 12:00:12 +0200
committer Spartan322 <Megacake1234@gmail.com>2023-10-12 17:29:10 +0200
commit5aacd90c3ef565c5bcd3c337dfd444a8fccc03f8 (patch)
tree13683fd58e9ef79e388fba9b3067cc1f5cc345ed /src/openvic-dataloader/v2script/Parser.cpp
parent4009e1d576ad177aff59c8fce0339963303fc6e5 (diff)
Add Lua Defines parsing
Diffstat (limited to 'src/openvic-dataloader/v2script/Parser.cpp')
-rw-r--r--src/openvic-dataloader/v2script/Parser.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/openvic-dataloader/v2script/Parser.cpp b/src/openvic-dataloader/v2script/Parser.cpp
index 9e74e32..d7e4106 100644
--- a/src/openvic-dataloader/v2script/Parser.cpp
+++ b/src/openvic-dataloader/v2script/Parser.cpp
@@ -31,6 +31,7 @@
#include "detail/Warnings.hpp"
#include "v2script/DecisionGrammar.hpp"
#include "v2script/EventGrammar.hpp"
+#include "v2script/LuaDefinesGrammar.hpp"
using namespace ovdl;
using namespace ovdl::v2script;
@@ -232,6 +233,28 @@ bool Parser::decision_parse() {
return true;
}
+bool Parser::lua_defines_parse() {
+ if (!_buffer_handler->is_valid()) {
+ return false;
+ }
+
+ if (_buffer_handler->is_exclusive_utf8()) {
+ _warnings.push_back(warnings::make_utf8_warning(_file_path));
+ }
+
+ auto errors = _buffer_handler->parse<lua::grammar::File<>>(ovdl::detail::ReporError.path(_file_path).to(detail::OStreamOutputIterator { _error_stream }));
+ if (errors) {
+ _errors.reserve(errors->size());
+ for (auto& err : errors.value()) {
+ _has_fatal_error |= err.type == ParseError::Type::Fatal;
+ _errors.push_back(err);
+ }
+ return false;
+ }
+ _file_node.reset(static_cast<ast::FileNode*>(_buffer_handler->get_root().release()));
+ return true;
+}
+
const FileNode* Parser::get_file_node() const {
return _file_node.get();
}