ELPL Initializing . . .
Formal Language Reference

The ELPL Grammar

Every rule that defines ELPL — from top-level program structure down to the lexical layer — presented as a canonical EBNF grammar.

nonterminal 'terminal' [character class] ? * + | ( )
🏛️

Program & Imports

6 rules
program ::=
package_decl? sep* ( top_item sep* )*
'package' qualified_name ';'?
top_item ::=
import_decl | class_decl | interface_decl | enum_decl | struct_decl | extern_decl | function_decl | statement
'use' ( string_lit | library_path )
identifier ( '.' ( identifier | '*' ) )*
use_stmt ::=
import_decl
🔧

Modifiers

2 rules
modifiers ::=
modifier*
modifier ::=
'public' | 'private' | 'protected' | 'static' | 'abstract' | 'final' | '@override'
🧩

Type Declarations

9 rules
modifiers 'class' identifier ( 'extends' qualified_name )? ( 'implements' type ( ',' type )* )? '{' sep* ( class_member sep* )* '}'
modifiers ( class_decl | interface_decl | enum_decl | struct_decl | function_decl | field_decl )
variable_decl
modifiers 'interface' identifier ( 'extends' identifier )? '{' sep* ( function_decl sep* )* '}'
enum_decl ::=
modifiers 'enum' identifier ( '(' identifier ( ',' identifier )* ')' )? '{' sep* ( enum_constant ','? sep* )* '}'
identifier ( '(' expr_list? ')' )?
modifiers 'struct' identifier '{' sep* ( modifiers variable_decl sep* )* '}'
'extern' ( extern_function | extern_variable )
'function' identifier '(' param_list? ')' ( ':' type )?
'let' identifier ':' type
⚙️

Functions

3 rules
modifiers 'function' identifier '(' param_list? ')' ( ':' type )? block?
param ( ',' param )*
param ::=
type? identifier
📜

Statements

22 rules
statement ::=
use_stmt | print_stmt | printnl_stmt | printerr_stmt | printerrnl_stmt | 'nl' | if_stmt | for_stmt | repeat_stmt | while_stmt | switch_stmt | foreach_stmt | call_stmt | super_call | 'stop' | 'continue' | return_stmt | throw_stmt | try_stmt | thread_stmt | sleep_stmt | join_stmt | collection_decl | java_block | array_assign | map_assign | variable_decl | expression_stmt
if_stmt ::=
'if' expr 'then' block ( 'otherwise' ( if_stmt | block ) )?
for_stmt ::=
'for' identifier 'be' expr 'to' expr block
'repeat' number_lit 'times' block
'while' expr block
'foreach' identifier ( ',' identifier )? ':' expr block
'switch' '(' expr ')' '{' switch_case* switch_default? '}'
'case' expr '=>' statement*
'default' '=>' statement*
call_stmt ::=
'call' identifier ( '(' expr_list? ')' )?
'super' '(' expr_list? ')'
'return' expr?
'throw' expr
try_stmt ::=
'try' block 'catch' identifier block
'Thread' identifier '{' sep* ( statement sep* )* '}'
'sleep' '=>' expr
join_stmt ::=
'join' identifier
'@java' '{' raw_java_source '}'
'print' expr+
'printnl' expr+
'printerr' expr+
'printerrnl' expr+
📦

Collections

7 rules
array_decl | map_decl | set_decl | queue_decl | list_decl
'Array' ( '<' type '>' )? identifier 'be' ( 'new' 'Array' '<' type '>' '[' expr ']' | '[' expr_list? ']' )
map_decl ::=
'Map' ( '<' type ',' type '>' | '[' identifier ',' identifier ']' ) identifier 'be' '{' ( map_entry ( ',' map_entry )* )? '}'
map_entry ::=
expr ':' expr
set_decl ::=
'Set' ( '<' type '>' )? identifier 'be' '{' expr_list? '}'
'Queue' ( '<' type '>' )? identifier 'be' '{' expr_list? '}'
list_decl ::=
'List' ( '<' type '>' )? identifier 'be' '[' expr_list? ']'
✏️

Assignment

7 rules
identifier ( '[' expr ']' )+ assign_op expr
identifier '[' expr ']' 'be' expr
'final'? ( ( ( 'float' | type ) identifier | 'let' identifier ( ':' type )? ) assign_tail | member_ref assign_op expr )
( assign_op expr )?
assign_op ::=
'be' | 'pels' | 'mels' | 'dels' | 'sels' | 'mls'
( 'this' | identifier ) '.' identifier
expr
📐

Blocks

1 rule
block ::=
'{' sep* ( statement sep* )* '}'
🎯

Expressions

21 rules
expr::=
ternary_expr
or_expr ( '?' expr ':' expr )?
and_expr ( 'or' and_expr )*
equality_expr ( 'and' equality_expr )*
relational_expr ( ( 'is equal to' | 'not equal to' ) relational_expr )*
additive_expr ( ( 'is greater than' | 'is less than' | 'is greater than or equal to' | 'is less than or equal to' ) additive_expr )*
multiplicative_expr ( ( 'add' | 'subtract' | '+' | '-' ) multiplicative_expr )*
unary_expr ( ( 'multiply' | 'divide' | 'mod' | '*' | '/' | '%' ) unary_expr )*
( 'not' | '-' )* postfix_expr
primary postfix_op*
'.' ( identifier | 'add' ) ( '(' expr_list? ')' )? | '[' expr ']'
'true' | 'false' | 'null' | number_lit | string_lit | ( 'scan' '(' string_lit? | '(' expr ')' ) | 'new' new_expr | 'call' identifier ( '(' expr_list? ')' )? | array_literal | ( 'this' | 'super' ) member_chain | identifier class_literal? array_access? member_chain? function_call? | cast_expr | lambda_expr
'Array' '<' type '>' '[' expr ']' | qualified_name '(' expr_list? ')'
( '.' ( identifier | 'add' ) ( '(' expr_list? ')' )? )*
( '[' expr ']' )*
'(' expr_list? ')'
'.' 'class'
'[' ( expr ( ',' expr )* )? ']'
'(' type ')' unary_expr
'(' param_list? ')' '=>' ( expr | block )
expr ( ',' expr )*
🏷️

Types

5 rules
type::=
primitive_type | collection_type | qualified_name type_args?
'Int' | 'Double' | 'Float' | 'Boolean' | 'String' | 'Long' | 'Char' | 'Short' | 'Byte' | 'Object' | 'Void'
( 'List' | 'Array' | 'Map' | 'Set' | 'Queue' ) type_args?
identifier ( '.' identifier )*
'<' type ( ',' type )* '>'
🔤

Lexical

6 rules
sep::=
NEWLINE | ';'
[a-zA-Z_] [a-zA-Z0-9_$]*
[0-9]+ ( '.' [0-9]+ )? ( 'f' | 'F' )?
'"' [^"]* '"'
[^{}]*
#xA