Skip to content

Instantly share code, notes, and snippets.

@rodrigogribeiro
Created April 6, 2020 17:28
Show Gist options
  • Save rodrigogribeiro/789c4c8e8be115c7d1f916fd64739ded to your computer and use it in GitHub Desktop.
Save rodrigogribeiro/789c4c8e8be115c7d1f916fd64739ded to your computer and use it in GitHub Desktop.
#lang brag
i-program : (i-statement)*
; statements syntax
@i-statement : i-assign | i-if | i-skip | i-while | i-print
i-assign : i-id /"=" i-exp /";"
@i-block : /"{" (i-statement)* /"}"
i-condition : /"(" i-exp /")"
i-if : /"if" i-condition i-block /"else" i-block
i-skip : /"skip" /";"
i-while : /"while" /"(" i-exp /")" i-block
i-print : /"print" i-exp /";"
; expression syntax
i-exp : @i-or-exp
i-or-exp : [i-or-exp "||"] @i-and-exp
i-and-exp : [i-and-exp "&&"] @i-not-exp
i-not-exp : ["!"] @i-comp-exp
i-comp-exp : [i-comp-exp ("=" | "<")] @i-sum
i-sum : [i-sum ("+" | "-")] @i-product
i-product : [i-product ("*" | "/" | "%")] @i-neg
i-neg : ["-"] @i-expt
i-expt : [i-expt ("^")] i-value
@i-value : i-number | i-id | /"(" i-exp /")"
@i-number : INTEGER
@i-id : ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment