Commit 28c462e5 authored by Raphaël Cauderlier's avatar Raphaël Cauderlier
Browse files

Handle parsing errors

parent 9e80fb3c
open Parsetree
exception Unknown_type_variable of cid
exception Unknown_variable of id
type sty =
| Stcid of cid * sty
| Stlist of (label * sty) list
......
......@@ -24,7 +24,13 @@ let main () =
let lexbuf = Lexing.from_channel input in
let out_fmter = Format.std_formatter in
let prog = lex_prog lexbuf in
let scoped_prog = Scoper.scope prog in
let scoped_prog =
try Scoper.scope prog
with Scoper.Unknown_variable id ->
Format.eprintf "Scope error: unknown variable %s@."
(Scoper.string_of_id id);
exit 1
in
let typed_prog = Typer.type_check scoped_prog in
Format.fprintf out_fmter "#NAME %s.@\n" (Filename.chop_extension file);
Printer.declare_labels out_fmter !Base.labels;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment