~ubuntu-branches/ubuntu/quantal/llvm-3.1/quantal

« back to all changes in this revision

Viewing changes to examples/OCaml-Kaleidoscope/Chapter4/ast.ml

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2012-03-29 19:09:51 UTC
  • Revision ID: package-import@ubuntu.com-20120329190951-aq83ivog4cg8bxun
Tags: upstream-3.1~svn153643
ImportĀ upstreamĀ versionĀ 3.1~svn153643

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(*===----------------------------------------------------------------------===
 
2
 * Abstract Syntax Tree (aka Parse Tree)
 
3
 *===----------------------------------------------------------------------===*)
 
4
 
 
5
(* expr - Base type for all expression nodes. *)
 
6
type expr =
 
7
  (* variant for numeric literals like "1.0". *)
 
8
  | Number of float
 
9
 
 
10
  (* variant for referencing a variable, like "a". *)
 
11
  | Variable of string
 
12
 
 
13
  (* variant for a binary operator. *)
 
14
  | Binary of char * expr * expr
 
15
 
 
16
  (* variant for function calls. *)
 
17
  | Call of string * expr array
 
18
 
 
19
(* proto - This type represents the "prototype" for a function, which captures
 
20
 * its name, and its argument names (thus implicitly the number of arguments the
 
21
 * function takes). *)
 
22
type proto = Prototype of string * string array
 
23
 
 
24
(* func - This type represents a function definition itself. *)
 
25
type func = Function of proto * expr