aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-dataloader/v2script/Grammar.cpp
diff options
context:
space:
mode:
author Spartan322 <Megacake1234@gmail.com>2023-07-28 06:52:00 +0200
committer Spartan322 <Megacake1234@gmail.com>2023-09-02 14:28:21 +0200
commit7440a5d1433eec4bf87e3723022db187e7f61b1a (patch)
tree2bb062c320fa2227b18956617b94d0e8800420d8 /src/openvic-dataloader/v2script/Grammar.cpp
parente941573f47fb867ff75c8a2cf78302b754ffbeee (diff)
Rework Grammar and Parser
Add proper headless binary construction: Includes basic validation Add Error and Warning structs to Parser Add FileNode pointer getter to Parser Change all `char8_t*` and `const char8_t` to `const char*` in Parser Add Parser move operators and Parser deconstructor Add BufferHandler PIMPL object to Parser Add UTF-8 file Warning to v2script Add proper Grammar value retrieval Add AbstractSyntaxTree for v2script data parser: Has compile-time embedded type information accessible at compile-time and runtime Has Tab-based print functionality Fix wrong environment reference for headless construction in SConstruct Add error retrieval Add BasicCallbackOStreamBuffer for callback streaming Add CallbackStreamBuffer for char Add CallbackWStreamBuffer for wchar_t Add BasicCallbackStream Add CallbackStream for char Add CallbackWStream for wchar_t Add grammar for events and decisions Add event_parse to Parser Add decision_parse to Parser Add .clang-format Ignore dirty lexy module Add CSV parser and grammar: Creates std::vector<csv::LineObject> for a list of lines Add BasicParser and BasicBufferHandler to reduce code reduplication
Diffstat (limited to 'src/openvic-dataloader/v2script/Grammar.cpp')
-rw-r--r--src/openvic-dataloader/v2script/Grammar.cpp74
1 files changed, 0 insertions, 74 deletions
diff --git a/src/openvic-dataloader/v2script/Grammar.cpp b/src/openvic-dataloader/v2script/Grammar.cpp
deleted file mode 100644
index ec9fac2..0000000
--- a/src/openvic-dataloader/v2script/Grammar.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-#include <lexy/dsl.hpp>
-#include <openvic-dataloader/v2script/Parser.hpp>
-
-using namespace ovdl::v2script;
-
-// Node Definitions //
-namespace dsl = lexy::dsl;
-
-namespace ovdl::v2script::nodes {
- struct StatementListBlock;
-
- static constexpr auto whitespace_specifier = dsl::code_point.range<0x09, 0x0A>() / dsl::lit_cp<0x0D> / dsl::lit_cp<0x20>;
- static constexpr auto comment_specifier = LEXY_LIT("#") >> dsl::until(dsl::newline).or_eof();
-
- static constexpr auto data_specifier =
- dsl::ascii::alpha_digit_underscore /
- dsl::code_point.range<0x25, 0x27>() / dsl::lit_cp<0x2B> / dsl::code_point.range<0x2D, 0x2E>() /
- dsl::lit_cp<0x3A> /
- dsl::lit_cp<0x8A> / dsl::lit_cp<0x8C> / dsl::lit_cp<0x8E> /
- dsl::lit_cp<0x92> / dsl::lit_cp<0x9A> / dsl::lit_cp<0x9C> / dsl::code_point.range<0x9E, 0x9F>() /
- dsl::code_point.range<0xC0, 0xD6>() / dsl::code_point.range<0xD8, 0xF6>() / dsl::code_point.range<0xF8, 0xFF>();
-
- static constexpr auto data_char_class = LEXY_CHAR_CLASS("DataSpecifier", data_specifier);
-
- struct Identifier {
- static constexpr auto rule = dsl::identifier(data_char_class);
- };
-
- struct StringExpression {
- static constexpr auto escaped_symbols = lexy::symbol_table<char> //
- .map<'"'>('"')
- .map<'\''>('\'')
- .map<'\\'>('\\')
- .map<'/'>('/')
- .map<'b'>('\b')
- .map<'f'>('\f')
- .map<'n'>('\n')
- .map<'r'>('\r')
- .map<'t'>('\t');
- static constexpr auto rule = [] {
- // Arbitrary code points that aren't control characters.
- auto c = -dsl::unicode::control;
-
- // Escape sequences start with a backlash.
- // They either map one of the symbols,
- // or a Unicode code point of the form uXXXX.
- auto escape = dsl::backslash_escape //
- .symbol<escaped_symbols>()
- .rule(dsl::lit_c<'u'> >> dsl::code_point_id<4>);
- return dsl::quoted(c, escape);
- }();
- };
-
- struct AssignmentStatement {
- static constexpr auto rule = dsl::p<Identifier> >>
- (dsl::equal_sign >>
- (dsl::p<Identifier> | dsl::p<StringExpression> | dsl::recurse_branch<StatementListBlock>) |
- dsl::else_ >> dsl::return_);
- };
-
- struct StatementListBlock {
- static constexpr auto rule =
- dsl::curly_bracketed.open() >>
- dsl::opt(dsl::list(dsl::p<AssignmentStatement>)) + dsl::opt(dsl::semicolon) +
- dsl::curly_bracketed.close();
- };
-
- struct File {
- // Allow arbitrary spaces between individual tokens.
- static constexpr auto whitespace = whitespace_specifier | comment_specifier;
-
- static constexpr auto rule = dsl::terminator(dsl::eof).list(dsl::p<AssignmentStatement>);
- };
-}