User Tools

Site Tools


elderscript_syntax

Formal Syntax

This is the formal definition for ELDARScript syntax in EBNF. Note that this also describes some semantically incorrect programs, even though they are syntactically correct, as well as some ambiguous conditions that are also resolved based on semantics. Not all of this grammar is available in all places (for example, a function definition can not currently specify rolling dice).

RollExpr ::= ConditionExpr ( (',' ConditionExpr) | ('.' ConditionExpr))*

ConditionExpr ::= Assignment | 'if' AndOrExpr 'then' RollExpr ('elif' AndOrExpr 'then' RollExpr)* 'else' RollExpr 'end' | 'for' Variable 'in' RollExpr 'do' RollExpr 'end' | AndOrExpr

Assignment ::= (Variable | Parameter) '' ConditionExpr

AndOrExpr ::= Comparison ( ('∧' | '∨' | '') Comparison)*

Comparison ::= RollRange ( ('<' | '≤' | '=' | '≠' | '>' | '≥' | 'in' ) parseRollRange)*

RollRange ::= RollTerm ( '…' RollTerm ) *

RollTerm ::= RollMult (('+' | '-') RollMult ) *

RollMult ::= RollSubscript (('×' | '%' | '/+' | '/-' | '/=' | '÷' | '/' ) RollSubscript)*

RollSubscript ::= FunctionCallExpr ( '[' RollExpr ']' ('' ConditionExpr)? | ':' Identifier ('' ConditionExpr)? )*

FunctionCallExpr ::= FunctionName ( Number )? List | ('×' SimpleValue ':')? SimpleValue

SimpleValue ::= String | Dice

Dice ::= Frame | '(' ')' | '(' RollExpr ')' | 'true' | 'false' | Variable ( List )? | Identifier | Parameter | Number | (RollReference | DieCount? DieAppearance Macro? | '$(' DieCount? DieAppearance Macro? (',' DieCount? DieAppearance Macro?)* ')' ) Reducer? | DieCount? TextDieAppearance

DieCount ::= Parameter | Number ('½')?

DieColor ::= [rgbcmykwaon]

DieAppearance ::= DieColor? [dz] Open? (Identifier (Number) | Number | Parameter | '%' | '‰' | '‱' | '6a' )?

TextDieAppearance ::= DieColor? [t] Identifier (Number)

Open ::= '+' | '-' | '*' | '±' | '.+' |'.-' |'.±'

Macro ::= Identifier (Number | Parameter)?

RollReference ::= [$][1-9][0-9]?

Variable::= [@] [A-Z][A-Za-z0-9]?

Parameter ::= [#] [1-9][0-9]?

Frame ::= '{' ( List )? ( Slot ('|' Slot )* )? '}'

Slot ::= SlotName ':' ConditionExpr

SlotName ::= ( String | Identifier | Number ('…' Number )? ) (',' SlotName )*

List ::= '(' ( ConditionExpr ( ',' ConditionExpr )* )? ')'

elderscript_syntax.txt · Last modified: 2019/07/12 11:40 by dicenomiwiki