Skip to content

Commit

Permalink
Allow multiple operations in with blocks (#45)
Browse files Browse the repository at this point in the history
* Allow multiple operations in `with` blocks

* Update docs

* Add tests, fix miss-indentation

---------

Co-authored-by: Capypara <[email protected]>
  • Loading branch information
tech-ticks and theCapypara authored Jul 19, 2024
1 parent 53b135c commit 4c71a7e
Show file tree
Hide file tree
Showing 6 changed files with 724 additions and 577 deletions.
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

0 comments on commit 4c71a7e

Please sign in to comment.