Skip to content

Commit

Permalink
Final: minor corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
volgar1x committed May 11, 2017
1 parent 778677b commit c1faaac
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion TP05/essais.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ let c5 = lambda s : (Nat -> Nat). lambda z : Nat. s (s (s (s (s z)))) ;;
realnat c5 ;;

# encore un terme mal typé
(lambda x : bool. x) succ 0 ;;
(lambda x : bool. x) (succ 0) ;;

# et un autre
realnat 0 ;;
Expand Down
8 changes: 6 additions & 2 deletions final/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ else
(* describe where in the code we are *)
let code_loc buf =
let loc = buf.Lexing.lex_curr_p in
Ansi.wrap [Underline] ("line " ^ (string_of_int loc.Lexing.pos_lnum))
Ansi.wrap [Underline] (loc.Lexing.pos_fname ^ ":" ^ (string_of_int loc.Lexing.pos_lnum))
;;

(* main evaluation loop *)
Expand All @@ -42,7 +42,11 @@ let rec loop gamma delta buf =

(* open file and evaluate it *)
let ch = open_in Sys.argv.(1) in
try loop [] [] (Lexing.from_channel ch)
let buf = Lexing.from_channel ch in
buf.Lexing.lex_curr_p <- { buf.Lexing.lex_curr_p with
Lexing.pos_fname = Sys.argv.(1);
};
try loop [] [] buf
with err -> print_endline ("unexpected error: " ^ (Printexc.to_string err));
close_in ch
;;
12 changes: 9 additions & 3 deletions final/parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,18 @@ variant :
;

variantlist :
| variant variantlist2 { $1 :: $2 }
| { [] }
| { [] }
| Lbar variantlist1 { $2 }
| variantlist1 { $1 }
;

variantlist1 :
| variant variantlist2 { $1 :: $2 }
| { [] }
;

variantlist2 :
| Lbar variantlist { $2 }
| Lbar variantlist1 { $2 }
| { [] }
;

Expand Down

0 comments on commit c1faaac

Please sign in to comment.