summaryrefslogtreecommitdiff
path: root/examples/OCaml-Kaleidoscope/Chapter3/ast.ml
diff options
context:
space:
mode:
authorErick Tryzelaar <idadesub@users.sourceforge.net>2010-03-08 19:32:27 +0000
committerErick Tryzelaar <idadesub@users.sourceforge.net>2010-03-08 19:32:27 +0000
commit49457b81589c6a3ef384caa8fdf1463ad2ada7c7 (patch)
tree8500bcc1ba0067ff7816b083d8b5a535be6ee50d /examples/OCaml-Kaleidoscope/Chapter3/ast.ml
parent9ef76b9985a0c408e126affa049698c413ad8664 (diff)
downloadllvm-49457b81589c6a3ef384caa8fdf1463ad2ada7c7.tar.gz
llvm-49457b81589c6a3ef384caa8fdf1463ad2ada7c7.tar.bz2
llvm-49457b81589c6a3ef384caa8fdf1463ad2ada7c7.tar.xz
Add OCaml tutorial to the examples.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97966 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'examples/OCaml-Kaleidoscope/Chapter3/ast.ml')
-rw-r--r--examples/OCaml-Kaleidoscope/Chapter3/ast.ml25
1 files changed, 25 insertions, 0 deletions
diff --git a/examples/OCaml-Kaleidoscope/Chapter3/ast.ml b/examples/OCaml-Kaleidoscope/Chapter3/ast.ml
new file mode 100644
index 0000000000..4cc2dea86b
--- /dev/null
+++ b/examples/OCaml-Kaleidoscope/Chapter3/ast.ml
@@ -0,0 +1,25 @@
+(*===----------------------------------------------------------------------===
+ * 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 binary operator. *)
+ | Binary of char * expr * expr
+
+ (* variant for function calls. *)
+ | Call of string * expr array
+
+(* 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
+
+(* func - This type represents a function definition itself. *)
+type func = Function of proto * expr