diff options
Diffstat (limited to 'src/openvic-dataloader/v2script/Parser.cpp')
-rw-r--r-- | src/openvic-dataloader/v2script/Parser.cpp | 23 |
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(); } |