Home | History | Annotate | Download | only in Chapter2
      1 (*===----------------------------------------------------------------------===
      2  * Main driver code.
      3  *===----------------------------------------------------------------------===*)
      4 
      5 let main () =
      6   (* Install standard binary operators.
      7    * 1 is the lowest precedence. *)
      8   Hashtbl.add Parser.binop_precedence '<' 10;
      9   Hashtbl.add Parser.binop_precedence '+' 20;
     10   Hashtbl.add Parser.binop_precedence '-' 20;
     11   Hashtbl.add Parser.binop_precedence '*' 40;    (* highest. *)
     12 
     13   (* Prime the first token. *)
     14   print_string "ready> "; flush stdout;
     15   let stream = Lexer.lex (Stream.of_channel stdin) in
     16 
     17   (* Run the main "interpreter loop" now. *)
     18   Toplevel.main_loop stream;
     19 ;;
     20 
     21 main ()
     22