Commits

Anonymous committed 9155937

Removing unused file; added a small comment.

Comments (0)

Files changed (2)

blub_lex.mll

-{
-  open Printf
-  open Blub_types
-
-  type token =
-      Lval of sval
-    | Ltoken of char
-
-
-  let unexpected_token c =
-    eprintf "Unexpected token %c\n%!" c;
-    assert false
-
-
-  let read_quoted read_fn sym =
-    match read_fn () with
-	Lval x -> Lval (Slist [ sym; x ] )
-      | Ltoken c -> unexpected_token c
-
-  let get_symbol sym =
-    Ssymbol sym
-
-  let sym_quote = get_symbol "quote"
-  let sym_quasiquote = get_symbol "quasiquote"
-  let sym_unquote = get_symbol "unquote"
-  let sym_unquote_splicing = get_symbol "unquote-splicing"
-
-}
-
-let id_char = [ '!' '$' '%' '*' '+' '-' '.' '/' ':' '<' '=' '>' '?' '@' '^' '_' '~' 'a'-'z' 'A'-'Z' ]
-let peculiar_id = "+" | "-" | "..."
-let sign = ['+' '-']
-let digit = ['0'-'9']
-let other = id_char | digit
-
-let char_prefix = "#\\"
-
-let r10_int = sign? digit+
-
-
-rule read_string sbuf = parse
-  | '"' { }
-  | "\\\"" { Buffer.add_char sbuf '"'; read_string sbuf lexbuf }
-  | _ as c { Buffer.add_char sbuf c; read_string sbuf lexbuf }
-    
-
-
-and read_expr = parse
-
-  | r10_int as numstr
-      {
-	let v = Sint (int_of_string numstr) in
-	Lval v
-      }
-
-
-  | r10_int '.' r10_int* as numstr
-      {
-	let v = Sfloat (float_of_string numstr) in
-	Lval v
-      }
-
-  | '.' { Ltoken '.' }
-  | id_char other* ':' as sym 
-      { 
-	Lval (Slist [sym_quote; get_symbol sym ])
-     }
-
-  | id_char other* | peculiar_id as id 
-      {
-	Lval (get_symbol id)
-      }
-
-
-  | '\'' { read_quoted (fun () -> read_expr lexbuf) sym_quote }
-  | '`' { read_quoted (fun () -> read_expr lexbuf) sym_quasiquote }
-  | ',' { read_quoted (fun () -> read_expr lexbuf) sym_unquote }
-  | ",@" { read_quoted (fun () -> read_expr lexbuf) sym_unquote_splicing }
-
-  | '"' 
-      { 
-	let buf = Buffer.create 1000 in
-	read_string buf lexbuf;
-	let s = Buffer.contents buf in
-	Lval (Sstring s)
-      }
-
-  | '('
-      {
-	let rec build_list () =
-	  match read_expr lexbuf with
-	      Ltoken ')' -> []
-	    | Lval s -> s :: (build_list ())
-	    | Ltoken c -> unexpected_token c
-	in
-	let l = build_list () in
-	Lval (Slist l)
-      }
-
-  | "#t" { Lval Strue }
-  | "#f" { Lval Sfalse }
-
-  | ';' [^ '\n']* '\n' { read_expr lexbuf }
-
-  | "#("
-      {
-	let rec build_vector () =
-	  match read_expr lexbuf with
-	      Ltoken ')' -> []
-	    | Lval s -> s :: (build_vector ())
-	    | Ltoken c -> 
-		eprintf "Unexpected token %c\n%!" c;
-		assert false
-	in
-	let l = build_vector () in
-	let vec = Array.of_list l in
-	Lval (Svector vec)
-      }
-
-  | ')' { Ltoken ')' }
-
-  | [' ' '\t' '\n' '\r' '\012'] { read_expr lexbuf }   (* eat up whitespace *)
-
-  | _ as c
-      {
-	printf "Couldn't parse character %c (%d)\n%!" c (Char.code c);
-	assert false
-      }
-
-  | eof { raise End_of_file }
-
-
-
-{
-
-  let read_expr () =
-    let lexbuf = Lexing.from_channel stdin in
-    match read_expr lexbuf with
-	Lval v -> v
-      | _ -> assert false
-
-}
 		 Blub_closure.VarSet.add var acc)
 	      params Blub_closure.VarSet.empty 
 	    in
-	    let _ = try
-	      Blub_closure.find_free bound_vars body
-	    with _ -> Blub_closure.VarSet.empty
+	    let () = try
+	      let free_vars = Blub_closure.find_free bound_vars body in
+	      printf "Function has %d free variables\n%!" (Blub_closure.VarSet.cardinal free_vars);
+	      (* 
+		 Conditions for invoking LLVM right now:
+		 [1] no free variables
+		 [2] all type variables are bound to concrete types 
+	      *)
+	      
+	    with _ -> ()
 	    in
 
 	    (* We will definitely compile the bytecode version of the function