Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple operations in with blocks #45

Merged
merged 3 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions docs/language_spec.rst
Original file line number Diff line number Diff line change
Expand Up @@ -368,15 +368,19 @@ with-Blocks
~~~~~~~~~~~
Runs a statement in the context of an actor, an object or
a performer. Only simple statements are allowed, no blocks
or labels. The blocks can only contain exactly one statement.
or labels.
The keywords ``actor``, ``object`` or ``performer`` can be used
to specify the type. As identifiers for their IDs integers and
constants can be used.
``with`` blocks can contain multiple operations for convenience,
but unlike code in targeted routines, operations in the block are
not executed concurrently.

.. code:: ExplorerScript

with (actor ACTOR_HELLO_WORLD) {
operation();
operation1();
operation2();
}

if-Blocks
Expand Down
3 changes: 1 addition & 2 deletions explorerscript/antlr/ExplorerScript.g4
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ jump: JUMP AT IDENTIFIER;
call: CALL AT IDENTIFIER;
macro_call: MACRO_CALL OPEN_PAREN arglist? CLOSE_PAREN ';';

// a ctx block needs exactly one simple statement, we enforce this on parser level.
// warning: the parser also accepts labels, which isn't valid!
ctx_block: WITH OPEN_PAREN ctx_header CLOSE_PAREN OPEN_BRACE simple_stmt CLOSE_BRACE;
ctx_block: WITH OPEN_PAREN ctx_header CLOSE_PAREN OPEN_BRACE simple_stmt* CLOSE_BRACE;

if_block: IF NOT? OPEN_PAREN if_header (OR if_header)* CLOSE_PAREN OPEN_BRACE stmt* CLOSE_BRACE elseif_block* else_block?;
elseif_block: ELSEIF NOT? OPEN_PAREN if_header (OR if_header)* CLOSE_PAREN OPEN_BRACE stmt* CLOSE_BRACE;
Expand Down
2 changes: 1 addition & 1 deletion explorerscript/antlr/ExplorerScript.interp

Large diffs are not rendered by default.

Loading