shulkerscript-lang/grammar.md

90 lines
1.1 KiB
Markdown
Raw Normal View History

# Grammar of the shulkerscript language
## Table of contents
### Program
```ebnf
Program: Declaration*;
```
### Declaration
```ebnf
Declaration: FunctionDeclaration;
```
### FunctionDeclaration
```ebnf
Function:
2024-04-01 20:42:38 +02:00
Annotation* 'fn' Identifier '(' ParameterList? ')' Block
;
ParameterList:
Identifier (',' Identifier)* ','?
;
```
2024-04-01 20:42:38 +02:00
### Annotation
```ebnf
Annotation: '#[' Identifier ('=' StringLiteral)? ']';
```
### Statement
```ebnf
Statement:
Block
| LiteralCommand
| Conditional
2024-04-05 16:16:12 +02:00
| Grouping
| DocComment
;
```
### Block
```ebnf
Block: '{' Statement* '}';
```
### Conditional
```ebnf
Conditional:
'if' ParenthizedCondition Block ('else' Block)?
;
```
### ParenthizedCondition
```ebnf
ParenthizedCondition:
'(' Condition ')'
;
```
### Condition
```ebnf
Condition:
StringLiteral
2024-04-05 16:16:12 +02:00
```
### Grouping
``` ebnf
Grouping:
'group' Block
;
```
### Expression
```ebnf
Expression:
Primary
```
### Primary
``` ebnf
Primary:
FunctionCall
```
### FunctionCall
``` ebnf
FunctionCall:
Identifier '(' (Expression (',' Expression)*)? ')'
;
```