Skip to content

Commit

Permalink
feat: stream toggle keyword (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy authored Oct 15, 2024
1 parent 3d9b2dd commit 4dd05d4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ecsact/detail/grammar.hh
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,11 @@ struct system_component_statement {
static constexpr auto value = lexy::constant(ECSACT_SYS_CAP_REMOVES);
};

struct stream_toggle_keyword : lexy::token_production {
static constexpr auto rule = LEXY_LIT("stream_toggle");
static constexpr auto value = lexy::constant(ECSACT_SYS_CAP_STREAM_TOGGLE);
};

struct filter {
static constexpr auto rule = lexy::dsl::p<include_keyword> |
lexy::dsl::p<exclude_keyword>;
Expand Down Expand Up @@ -695,7 +700,8 @@ struct system_component_statement {
};

static constexpr auto capability = lexy::dsl::p<filter> |
lexy::dsl::p<access> | lexy::dsl::p<assignment>;
lexy::dsl::p<access> | lexy::dsl::p<assignment> |
lexy::dsl::p<stream_toggle_keyword>;

static constexpr auto rule = capability >> lexy::dsl::p<type_name> >>
lexy::dsl::opt(lexy::dsl::p<with_keyword> >> lexy::dsl::p<with_fields>);
Expand Down
5 changes: 5 additions & 0 deletions test/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ register_toolchains(
"@llvm_toolchain//:all",
dev_dependency = True,
)

local_path_override(
module_name = "ecsact_runtime",
path = "../../ecsact_runtime",
)
9 changes: 9 additions & 0 deletions test/parse_test_system_component_statement.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,15 @@ TEST(Parse, RemovesSystemComponent) {
);
}

TEST(Parse, StreamToggleSystemComponent) {
TestValidSystemComponent(
"stream_toggle ExampleComponent;"s,
ECSACT_SYS_CAP_STREAM_TOGGLE,
"ExampleComponent",
empty_list
);
}

///////////////////////////////////
// 'with' keyword //
///////////////////////////////////
Expand Down

0 comments on commit 4dd05d4

Please sign in to comment.