Skip to content

Instantly share code, notes, and snippets.

@wweic
Created August 23, 2016 15:47
Show Gist options
  • Save wweic/5e56c3fc47dcf3d3828b5144b6326033 to your computer and use it in GitHub Desktop.
Save wweic/5e56c3fc47dcf3d3828b5144b6326033 to your computer and use it in GitHub Desktop.
while.ml
type token = Bool of bool
| Number of int
| Identifier of string
| SemiColon
| LeftBracket
| RightBracket
| LeftParen
| RightParen
| KeywordIf
| KeywordThen
| KeywordElse
| KeywordWhile
| KeywordDo
| KeywordAnd
| KeywordOr
| OpAssign
| OpPlus
| OpSub
| OpMul
| OpDiv
| OpLT
| OpGT
type exp = PlusExp of exp * exp
| SubExp of exp * exp
| MulExp of exp * exp
| DivExp of exp * exp
| Variable of string
| NumLiteral of int
| LTExp of exp * exp
| GTExp of exp * exp
| AndExp of exp * exp
| OrExp of exp * exp
| BoolLiteral of bool
type prog = Stmts of prog list
| Assign of string * exp
| IfElse of exp * prog * prog
| While of exp * prog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment