blob: 885946dfdcc3c930ab1cf60e73427ae94c1d6ee3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#pragma once
#include <cstddef>
#include <filesystem>
#include <memory>
#include <string_view>
#include <openvic-dataloader/ParseError.hpp>
#include <openvic-dataloader/ParseWarning.hpp>
#include <openvic-dataloader/detail/BasicParser.hpp>
#include <openvic-dataloader/detail/Concepts.hpp>
#include <openvic-dataloader/v2script/AbstractSyntaxTree.hpp>
namespace ovdl::v2script {
using FileNode = ast::FileNode;
class Parser final : public detail::BasicParser {
public:
Parser();
static Parser from_buffer(const char* data, std::size_t size);
static Parser from_buffer(const char* start, const char* end);
static Parser from_string(const std::string_view string);
static Parser from_file(const char* path);
static Parser from_file(const std::filesystem::path& path);
constexpr Parser& load_from_buffer(const char* data, std::size_t size);
constexpr Parser& load_from_buffer(const char* start, const char* end);
constexpr Parser& load_from_string(const std::string_view string);
constexpr Parser& load_from_file(const char* path);
Parser& load_from_file(const std::filesystem::path& path);
constexpr Parser& load_from_file(const detail::Has_c_str auto& path);
bool simple_parse();
bool event_parse();
bool decision_parse();
bool lua_defines_parse();
const FileNode* get_file_node() const;
void generate_node_location_map();
const ast::Node::line_col get_node_begin(const ast::NodeCPtr node) const;
const ast::Node::line_col get_node_end(const ast::NodeCPtr node) const;
Parser(Parser&&);
Parser& operator=(Parser&&);
~Parser();
private:
friend class ::ovdl::v2script::ast::Node;
class BufferHandler;
std::unique_ptr<BufferHandler> _buffer_handler;
std::unique_ptr<FileNode> _file_node;
template<typename... Args>
constexpr void _run_load_func(detail::LoadCallback<BufferHandler, Args...> auto func, Args... args);
};
}
|