2024-04-06 21:49:25 +02:00
|
|
|
# Grammar of the ShulkerScript language
|
2024-03-29 18:26:43 +01:00
|
|
|
|
|
|
|
## Table of contents
|
|
|
|
|
|
|
|
### Program
|
|
|
|
```ebnf
|
2024-06-09 17:59:56 +02:00
|
|
|
Program: Namespace Declaration*;
|
|
|
|
```
|
|
|
|
|
|
|
|
### Namespace
|
|
|
|
```ebnf
|
|
|
|
Namespace: 'namespace' StringLiteral;
|
2024-03-29 18:26:43 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
### Declaration
|
|
|
|
```ebnf
|
2024-06-24 21:37:02 +02:00
|
|
|
Declaration: FunctionDeclaration | Import;
|
|
|
|
```
|
|
|
|
|
|
|
|
### Import
|
|
|
|
```ebnf
|
|
|
|
Import: 'from' StringLiteral 'import' Identifier;
|
2024-03-29 18:26:43 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
### FunctionDeclaration
|
|
|
|
```ebnf
|
|
|
|
Function:
|
2024-06-09 17:59:56 +02:00
|
|
|
Annotation* 'pub'? 'fn' Identifier '(' ParameterList? ')' Block
|
2024-03-29 18:26:43 +01:00
|
|
|
;
|
|
|
|
ParameterList:
|
|
|
|
Identifier (',' Identifier)* ','?
|
|
|
|
;
|
|
|
|
```
|
|
|
|
|
2024-04-01 20:42:38 +02:00
|
|
|
### Annotation
|
|
|
|
```ebnf
|
|
|
|
Annotation: '#[' Identifier ('=' StringLiteral)? ']';
|
|
|
|
```
|
|
|
|
|
2024-03-29 18:26:43 +01:00
|
|
|
### Statement
|
|
|
|
```ebnf
|
|
|
|
Statement:
|
|
|
|
Block
|
|
|
|
| LiteralCommand
|
|
|
|
| Conditional
|
2024-04-05 16:16:12 +02:00
|
|
|
| Grouping
|
|
|
|
| DocComment
|
2024-04-06 15:12:20 +02:00
|
|
|
| Semicolon
|
|
|
|
| Run
|
2024-03-29 18:26:43 +01:00
|
|
|
;
|
|
|
|
```
|
|
|
|
|
|
|
|
### Block
|
|
|
|
```ebnf
|
|
|
|
Block: '{' Statement* '}';
|
|
|
|
```
|
|
|
|
|
2024-04-06 15:12:20 +02:00
|
|
|
### Run
|
|
|
|
```ebnf
|
|
|
|
Run:
|
|
|
|
'run' Expression ';'
|
|
|
|
;
|
|
|
|
```
|
|
|
|
|
2024-03-29 18:26:43 +01:00
|
|
|
### Conditional
|
|
|
|
```ebnf
|
|
|
|
Conditional:
|
|
|
|
'if' ParenthizedCondition Block ('else' Block)?
|
|
|
|
;
|
|
|
|
```
|
|
|
|
|
2024-04-06 17:23:20 +02:00
|
|
|
### Condition
|
2024-03-29 18:26:43 +01:00
|
|
|
```ebnf
|
2024-04-06 17:23:20 +02:00
|
|
|
Condition:
|
|
|
|
PrimaryCondition
|
|
|
|
BinaryCondition
|
2024-03-29 18:26:43 +01:00
|
|
|
;
|
|
|
|
```
|
|
|
|
|
2024-04-06 17:23:20 +02:00
|
|
|
#### PrimaryCondition
|
2024-03-29 18:26:43 +01:00
|
|
|
```ebnf
|
2024-04-06 17:23:20 +02:00
|
|
|
PrimaryCondition:
|
|
|
|
ConditionalPrefix
|
|
|
|
| ParenthesizedCondition
|
|
|
|
| StringLiteral
|
|
|
|
;
|
|
|
|
```
|
|
|
|
|
|
|
|
#### ConditionalPrefix
|
|
|
|
```ebnf
|
|
|
|
ConditionalPrefix:
|
|
|
|
ConditionalPrefixOperator PrimaryCondition
|
|
|
|
;
|
|
|
|
```
|
|
|
|
|
|
|
|
#### ConditionalPrefixOperator
|
|
|
|
``` ebnf
|
|
|
|
ConditionalPrefixOperator: '!';
|
|
|
|
```
|
|
|
|
|
|
|
|
#### BinaryCondition
|
|
|
|
``` ebnf
|
|
|
|
BinaryCondition:
|
|
|
|
Condition ConditionalBinaryOperator Condition
|
|
|
|
;
|
2024-04-05 16:16:12 +02:00
|
|
|
```
|
|
|
|
|
2024-04-06 17:23:20 +02:00
|
|
|
#### ConditionalBinaryOperator
|
|
|
|
``` ebnf
|
|
|
|
ConditionalBinaryOperator:
|
|
|
|
'&&'
|
|
|
|
| '||'
|
|
|
|
;
|
|
|
|
```
|
|
|
|
|
|
|
|
#### ParenthizedCondition
|
|
|
|
```ebnf
|
|
|
|
ParenthizedCondition:
|
|
|
|
'(' Condition ')'
|
|
|
|
;
|
|
|
|
```
|
|
|
|
|
|
|
|
|
2024-04-05 16:16:12 +02:00
|
|
|
### Grouping
|
|
|
|
``` ebnf
|
|
|
|
Grouping:
|
|
|
|
'group' Block
|
2024-04-06 17:23:20 +02:00
|
|
|
;
|
2024-04-05 16:16:12 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
### Expression
|
|
|
|
```ebnf
|
|
|
|
Expression:
|
|
|
|
Primary
|
2024-04-06 17:23:20 +02:00
|
|
|
;
|
2024-04-05 16:16:12 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
### Primary
|
2024-04-06 21:49:25 +02:00
|
|
|
```ebnf
|
2024-04-05 16:16:12 +02:00
|
|
|
Primary:
|
|
|
|
FunctionCall
|
2024-04-06 17:23:20 +02:00
|
|
|
;
|
2024-04-05 16:16:12 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
### FunctionCall
|
2024-04-06 21:49:25 +02:00
|
|
|
```ebnf
|
2024-04-05 16:16:12 +02:00
|
|
|
FunctionCall:
|
|
|
|
Identifier '(' (Expression (',' Expression)*)? ')'
|
|
|
|
;
|
2024-04-06 17:23:20 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
### LuaCode
|
|
|
|
```ebnf
|
|
|
|
LuaCode:
|
|
|
|
'lua' '(' (Expression (',' Expression)*)? ')' '{' (.*?)* '}'
|
|
|
|
;
|
2024-03-29 18:26:43 +01:00
|
|
|
```
|