Mercurial > hg > CbC > CbC_llvm
view examples/OCaml-Kaleidoscope/Chapter7/ast.ml @ 26:d84031a0fa3c
bug fix : removed the error that TCE doesn't work if the function isn't a code segment. (It's due to incorrect if statement)
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 12 Nov 2013 18:45:31 +0900 |
parents | 9ad51c7bc036 |
children |
line wrap: on
line source
(*===----------------------------------------------------------------------=== * Abstract Syntax Tree (aka Parse Tree) *===----------------------------------------------------------------------===*) (* expr - Base type for all expression nodes. *) type expr = (* variant for numeric literals like "1.0". *) | Number of float (* variant for referencing a variable, like "a". *) | Variable of string (* variant for a unary operator. *) | Unary of char * expr (* variant for a binary operator. *) | Binary of char * expr * expr (* variant for function calls. *) | Call of string * expr array (* variant for if/then/else. *) | If of expr * expr * expr (* variant for for/in. *) | For of string * expr * expr * expr option * expr (* variant for var/in. *) | Var of (string * expr option) array * expr (* proto - This type represents the "prototype" for a function, which captures * its name, and its argument names (thus implicitly the number of arguments the * function takes). *) type proto = | Prototype of string * string array | BinOpPrototype of string * string array * int (* func - This type represents a function definition itself. *) type func = Function of proto * expr