Commit 2b4ade16 authored by Kim Nguyễn's avatar Kim Nguyễn
Browse files

WIP Parser : restore the behaviour of toplevel phrases.

parent 9dcd5820
......@@ -202,7 +202,8 @@ e = expr EOI { e }
top_phrases:
| p = prog {p}
| e = multi_expr ";;" { [ mk $sloc (EvalStatement e) ] }
| p = list(prog_item) ";;" { p }
;
prog:
......
exception Error of string
(* Taken from Menhir/Lib/Convert.ml*)
let for_sedlex parser =
fun lexer ->
let lexbuf : Lexing.lexbuf =
Lexing.from_string ""
in
let lexer (lexbuf : Lexing.lexbuf) =
let token, startp, endp = lexer() in
lexbuf.Lexing.lex_start_p <- startp;
lexbuf.Lexing.lex_curr_p <- endp;
token
in
parser lexer lexbuf
(**)
let protect_exn f g =
try let x = f () in g (); x
with e -> g (); raise e
......
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