aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Spartan322 <Megacake1234@gmail.com>2023-09-10 00:40:11 +0200
committer Spartan322 <Megacake1234@gmail.com>2023-09-10 00:40:11 +0200
commit579ad42ce99848639bc0eccebc198466d04aef0d (patch)
tree6d80bc66903d148c38d763e95697d847ea1be954
parent870068cf33057348000b1422d4bf40772aaf0b87 (diff)
Add requirement comments
Moved compound value expression to ValueExpression rule Fulfills: DAT-23, DAT-26, DAT-28, DAT-29, DAT-626, DAT-627, DAT-628, DAT-630, DAT-631, DAT-632, DAT-633, DAT-634, DAT-635, DAT-636, DAT-638, DAT-639, DAT-640, DAT-641, DAT-642, DAT-643
-rw-r--r--src/openvic-dataloader/v2script/Parser.cpp6
-rw-r--r--src/openvic-dataloader/v2script/SimpleGrammar.hpp31
2 files changed, 35 insertions, 2 deletions
diff --git a/src/openvic-dataloader/v2script/Parser.cpp b/src/openvic-dataloader/v2script/Parser.cpp
index 1258bca..0ff7612 100644
--- a/src/openvic-dataloader/v2script/Parser.cpp
+++ b/src/openvic-dataloader/v2script/Parser.cpp
@@ -160,6 +160,12 @@ constexpr Parser& Parser::load_from_file(const detail::Has_c_str auto& path) {
return load_from_file(path.c_str());
}
+/* REQUIREMENTS:
+ * DAT-23
+ * DAT-26
+ * DAT-28
+ * DAT-29
+ */
bool Parser::simple_parse() {
if (!_buffer_handler->is_valid()) {
return false;
diff --git a/src/openvic-dataloader/v2script/SimpleGrammar.hpp b/src/openvic-dataloader/v2script/SimpleGrammar.hpp
index 3e9a96e..d478bdf 100644
--- a/src/openvic-dataloader/v2script/SimpleGrammar.hpp
+++ b/src/openvic-dataloader/v2script/SimpleGrammar.hpp
@@ -12,12 +12,27 @@
#include "detail/LexyLitRange.hpp"
// Grammar Definitions //
+/* REQUIREMENTS:
+ * DAT-626
+ * DAT-627
+ * DAT-628
+ * DAT-636
+ * DAT-641
+ * DAT-642
+ * DAT-643
+ */
namespace ovdl::v2script::grammar {
struct StatementListBlock;
+ /* REQUIREMENTS: DAT-630 */
static constexpr auto whitespace_specifier = lexy::dsl::ascii::blank / lexy::dsl::ascii::newline;
+ /* REQUIREMENTS: DAT-631 */
static constexpr auto comment_specifier = LEXY_LIT("#") >> lexy::dsl::until(lexy::dsl::newline).or_eof();
+ /* REQUIREMENTS:
+ * DAT-632
+ * DAT-635
+ */
static constexpr auto data_specifier =
lexy::dsl::ascii::alpha_digit_underscore /
LEXY_ASCII_ONE_OF("%&'") / lexy::dsl::lit_c<0x2B> / LEXY_ASCII_ONE_OF("-.") /
@@ -39,6 +54,10 @@ namespace ovdl::v2script::grammar {
});
};
+ /* REQUIREMENTS:
+ * DAT-633
+ * DAT-634
+ */
struct StringExpression {
static constexpr auto escaped_symbols = lexy::symbol_table<char> //
.map<'"'>('"')
@@ -70,11 +89,17 @@ namespace ovdl::v2script::grammar {
});
};
+ /* REQUIREMENTS: DAT-638 */
+ struct ValueExpression {
+ static constexpr auto rule = lexy::dsl::p<Identifier> | lexy::dsl::p<StringExpression>;
+ static constexpr auto value = lexy::forward<ast::NodePtr>;
+ };
+
struct SimpleAssignmentStatement {
static constexpr auto rule =
lexy::dsl::position(lexy::dsl::p<Identifier>) >>
lexy::dsl::equal_sign +
- (lexy::dsl::p<Identifier> | lexy::dsl::p<StringExpression> | lexy::dsl::recurse_branch<StatementListBlock>);
+ (lexy::dsl::p<ValueExpression> | lexy::dsl::recurse_branch<StatementListBlock>);
static constexpr auto value = lexy::callback<ast::NodePtr>(
[](const char* pos, auto name, auto&& initalizer) {
@@ -82,11 +107,12 @@ namespace ovdl::v2script::grammar {
});
};
+ /* REQUIREMENTS: DAT-639 */
struct AssignmentStatement {
static constexpr auto rule =
lexy::dsl::position(lexy::dsl::p<Identifier>) >>
(lexy::dsl::equal_sign >>
- (lexy::dsl::p<Identifier> | lexy::dsl::p<StringExpression> | lexy::dsl::recurse_branch<StatementListBlock>) |
+ (lexy::dsl::p<ValueExpression> | lexy::dsl::recurse_branch<StatementListBlock>) |
lexy::dsl::else_ >> lexy::dsl::return_) |
lexy::dsl::p<StringExpression>;
@@ -102,6 +128,7 @@ namespace ovdl::v2script::grammar {
});
};
+ /* REQUIREMENTS: DAT-640 */
struct StatementListBlock {
static constexpr auto rule =
lexy::dsl::position(lexy::dsl::curly_bracketed.open()) >>