shulkerscript-lang/grammar.md

817 B

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
    ;

Block

Block: '{' Statement* '}';

Conditional

Conditional:
    'if' ParenthizedCondition Block ('else' Block)?
    ;

ParenthizedCondition

ParenthizedCondition:
    '(' Condition ')'
    ;

Condition

Condition:
    StringLiteral