166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman(*===----------------------------------------------------------------------===
266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman * Main driver code.
366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman *===----------------------------------------------------------------------===*)
466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanopen Llvm
666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanlet main () =
866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman  (* Install standard binary operators.
966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman   * 1 is the lowest precedence. *)
1066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman  Hashtbl.add Parser.binop_precedence '<' 10;
1166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman  Hashtbl.add Parser.binop_precedence '+' 20;
1266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman  Hashtbl.add Parser.binop_precedence '-' 20;
1366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman  Hashtbl.add Parser.binop_precedence '*' 40;    (* highest. *)
1466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
1566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman  (* Prime the first token. *)
1666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman  print_string "ready> "; flush stdout;
1766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman  let stream = Lexer.lex (Stream.of_channel stdin) in
1866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
1966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman  (* Run the main "interpreter loop" now. *)
2066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman  Toplevel.main_loop stream;
2166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
2266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman  (* Print out all the generated code. *)
2366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman  dump_module Codegen.the_module
2466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman;;
2566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
2666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanmain ()
27