diff options
author | Hop311 <Hop3114@gmail.com> | 2023-10-12 21:24:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-12 21:24:19 +0200 |
commit | 92c67f318114771999a73b05659023b59b103e06 (patch) | |
tree | 13683fd58e9ef79e388fba9b3067cc1f5cc345ed /src/openvic-dataloader/v2script/Parser.cpp | |
parent | 4009e1d576ad177aff59c8fce0339963303fc6e5 (diff) | |
parent | 5aacd90c3ef565c5bcd3c337dfd444a8fccc03f8 (diff) |
Merge pull request #24 from OpenVicProject/support/lua-defines
Add Lua Defines parsing
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(); } |