Add initial support for block statements

We needed to add `end` versions of the block identifiers or else the
lexer would identify them as generic tokens.
This commit is contained in:
Kevin 2024-05-21 17:05:47 -04:00
parent eeaeeec591
commit 36d3d4214c
2 changed files with 18 additions and 10 deletions

View File

@ -8,6 +8,7 @@ start : expressions;
expression
: inline_statement
| block_statement
;
expressions : expression*;
@ -25,6 +26,11 @@ list_literal_value
variable_name : IDENTIFIER;
statement_block
:
STATEMENT_ID_BLOCK SP IDENTIFIER
;
statement_include_template
: STRING_LITERAL
| list_literal
@ -61,23 +67,23 @@ statement_import
| STATEMENT_ID_FROM SP statement_import_file SP STATEMENT_ID_IMPORT SP statement_import_variable_list (SP statement_include_context)?
;
block_statement_id
: STATEMENT_ID_BLOCK
| STATEMENT_ID_SET
block_end_statement_id
: STATEMENT_END_ID_BLOCK
| STATEMENT_END_ID_SET
;
block_statement_with_parameters
: block_statement_id
| block_statement_id
;
// block_statement_with_parameters
// : block_statement_id
// | block_statement_id
// ;
block_statement_without_parameters
: block_statement_id
: statement_block
;
block_statement_start_content
: block_statement_without_parameters
| block_statement_with_parameters
// | block_statement_with_parameters
;
inline_statement_content
@ -88,6 +94,6 @@ inline_statement_content
inline_statement : STATEMENT_OPEN inline_statement_content STATEMENT_CLOSE;
block_statement_start : STATEMENT_OPEN block_statement_start_content STATEMENT_CLOSE;
block_statement_end : STATEMENT_OPEN END_STATEMENT_ID_PREFIX block_statement_id STATEMENT_CLOSE;
block_statement_end : STATEMENT_OPEN block_end_statement_id STATEMENT_CLOSE;
block_statement : block_statement_start expressions block_statement_end;

View File

@ -79,11 +79,13 @@ SP : [ \t\f]+;
// Statement identifiers for built-in statements
STATEMENT_ID_BLOCK : 'block';
STATEMENT_END_ID_BLOCK : 'endblock';
STATEMENT_ID_FROM : 'from';
STATEMENT_ID_IMPORT : 'import';
STATEMENT_ID_INCLUDE : 'include';
STATEMENT_ID_RAW : 'raw';
STATEMENT_ID_SET : 'set';
STATEMENT_END_ID_SET : 'endset';
STATEMENT_ID_IMPORT_AS : 'as';