# Grammar Defining the grammar of our D-language. ### Program: \{ Statement } ### Statement : Assignment | Declaration | Print | Return | If | Loop | Expression ### Assignment : Primary := Expression ### Declaration : var VariableDefinition { ',' VariableDefinition } ### VariableDefinition : IDENTIFIER [ ':=' Expression ] ### Print : print Expression { , Expression } ### Return : return [ Expression ] ### If : if Expression then Body [ else Body ] end ### Loop : while Expression LoopBody | for Identifier in Expression .\. Expression LoopBody ### LoopBody : loop Body end ### Body : \{ Statement } ### Primary : Identifier { Tail } | readInt | readReal | readString ### Tail : .IntegerLiteral | .Identifier | [Expression] | (Expression {, Expression} ) ### Expression : Conjunction \{ ( or | xor ) Conjunction } ### Conjunction : Relation { and Relation } ### Relation : Factor [ ( < | <= | > | >= | = | /= ) Factor ] ### Factor : Term \{ ( + | - ) Term } ### Term : Unary \{ ( * | / ) Unary } ### Unary : [ + | - | not ] Primary [ is TypeIndicator ] | Literal | ( Expression ) ### Literal : INTEGER | REAL | BOOL | STRING | ArrayLiteral | TupleLiteral | FunctionLiteral ### ArrayLiteral : '[' [ Expression { , Expression } ] ']' ### FunctionLiteral : func [ Parameters ] FunBody ### TupleLiteral : '{' [ TupleElement { ',' TupleElement } ] '}' ### TupleElement : [ Identifier := ] Expression ### Parameters : ( Identifier { , Identifier } ) ### FunBody : is Body end | => Expression ### TypeIndicator: int | real | bool | string | empty | [ ] | { } | func