Skip to content
Snippets Groups Projects

BNF grammar v0.2

Merged Jackson requested to merge Lukas into main
1 file
+ 54
54
Compare changes
  • Side-by-side
  • Inline
+ 54
54
BNF GRAMMAR
Exp ::= for '(' Exp1 ')' '{' Exp '}' { For $3 $ 6 }
| if '(' Exp1 ')' then '{' Exp '}' If1 { If $3 $7 }
| tile '[' Row ']' {Tile $3}
| empty '(' int ',' int ')' {Empty $3 $5}
| blank '(' int ',' int ')' {Blank $3 $5}
| numCol '(' var ')' {NumCol $3}
| numRow '(' var ')' {NumRow $3}
| '[' List ']' {Group $2}
| Type var'[' int ']' {TileGroup $4}
| print '(' var ')' {Print $3}
| shape '(' var ')' {Shape $3}
| for Exp3 '{' Exp '}' {For $2 $4}
| join '[' List ']' {Join $3 }
| stack '[' List ']' {Stack $3}
| rotate '(' var ')' {Rotate $3}
| supersize '(' var ',' int ')' {Super $3 $5}
| Exp1
Func ::= for '(' Math ')' '{' Func '}' {For $3 $6}
| if '(' Operations ')' then '{' Func '}' IfStatement {If $3 $7}
| var '=' tile '[' Row ']' {Tile $1 $5}
| empty '(' int ',' int ')' {Empty $3 $5}
| blank '(' int ',' int ')' {Blank $3 $5}
| numCol '(' var ')' {NumCol $3}
| numRow '(' var ')' {NumRow $3}
| var '=' '[' List ']' {TGroup $1 $4}
| var '[' int ']' {Accessor $1 $3}
| print '(' var ')' {Print $3}
| shape '(' var ')' {Shape $3}
| join '[' List ']' {Join $3}
| stack '[' List ']' {Stack $3}
| rotate '(' var ')' {Rotate $3}
| supersize '(' var ',' int ')' {Super $3 $5}
| BoolTiles
BoolTiles ::= conj '(' var ',' var ')' {Conjunction $3 $5}
| neg '(' var ')' {Negation $3}
| Math {$1}
IfStatement ::= else if '(' Boolean ')' then '{' Func '}' IfStatement {ElseIf $4 $8 $10}
| else '{' Func '}' {Else $3}
List ::= var {Var $1}
| var ',' List {List $1 $3}
| var ',' List {List $1 $3}
Row ::= '[' Block ']' {Block $2}
| '[' Block ']' ',' Row {Blocks $2 $5}
Block ::= '0' {Z}
| '1' {O}
| '0'',' Block {Z $3}
| '1'',' Block {O $3}
Exp1::= Exp2 '<' Exp2 {Less $1 $3}
| true {BTrue}
| false {BFalse}
If1 ::= else if '(' Exp1 ')' then '{' Exp '}' If1 { ElseIf $4 $8 $10 }
| else '{' Exp '}' { Else $3 }
| Exp2 { $1 }
Exp2::=
Exp3::= Exp3 '+' Exp3
| Exp3 '-' Exp3
| Exp3 '*' Exp3
| Exp3 '/' Exp3
| '(' Exp ')' {$2}
| Exp4
Exp4 : int { Int $1 }
| Type var { Var $1 $ 2 }
| '[' Block ']' ',' Row {Blocks $2 $5}
Block ::= '0' {Z}
| '1' {O}
| '0' ',' Block {Z $3}
| '1' ',' Block {O $3}
Operations ::= Boolean '&' '&' Boolean {And $1 $4}
| Boolean '|' '|' Boolean {Or $1 $4}
| not Operations {Not $2}
| Boolean {$1}
Boolean ::= Math '<' Math {Less $1 $3}
| Math '=' '=' Math {Equality $1 $4}
| true {BTrue}
| false {BFalse}
Math ::= Math '+' Math
| Math '-' Math
| Math '*' Math
| Math '/' Math
| '(' Math ')' {$2}
| Prim
Prim ::= int {Int $1}
| Type var {Var $1 $2}
Type::= Tile {TileType}
| TileGroup {TGType}
| Int {IntType}
| Bool {BoolType}
\ No newline at end of file
Type ::= Tile {TileType}
| TileGroup {TGType}
| Int {IntType}
| Bool {BoolType}
\ No newline at end of file
Loading