1.8 KiB
1.8 KiB
Grammar of the ShulkerScript language
Table of contents
Program
Program: Declaration*;
Declaration
Declaration: FunctionDeclaration;
FunctionDeclaration
Function:
Annotation* 'fn' Identifier '(' ParameterList? ')' Block
;
ParameterList:
Identifier (',' Identifier)* ','?
;
Annotation
Annotation: '#[' Identifier ('=' StringLiteral)? ']';
Statement
Statement:
Block
| LiteralCommand
| Conditional
| Grouping
| DocComment
| Semicolon
| Run
;
Block
Block: '{' Statement* '}';
Run
Run:
'run' Expression ';'
;
Conditional
Conditional:
'if' ParenthizedCondition Block ('else' Block)?
;
Condition
Condition:
PrimaryCondition
BinaryCondition
;
PrimaryCondition
PrimaryCondition:
ConditionalPrefix
| ParenthesizedCondition
| StringLiteral
;
ConditionalPrefix
ConditionalPrefix:
ConditionalPrefixOperator PrimaryCondition
;
ConditionalPrefixOperator
ConditionalPrefixOperator: '!';
BinaryCondition
BinaryCondition:
Condition ConditionalBinaryOperator Condition
;
ConditionalBinaryOperator
ConditionalBinaryOperator:
'&&'
| '||'
;
ParenthizedCondition
ParenthizedCondition:
'(' Condition ')'
;
Grouping
Grouping:
'group' Block
;
Expression
Expression:
Primary
;
Primary
Primary:
FunctionCall
;
FunctionCall
FunctionCall:
Identifier '(' (Expression (',' Expression)*)? ')'
;
LuaCode
LuaCode:
'lua' '(' (Expression (',' Expression)*)? ')' '{' (.*?)* '}'
;