Permalink
Browse files

Catch lexer warnings

  • Loading branch information...
1 parent 58a69dd commit 9a7783d23617d2988d080197bde12079b524fb28 @let-def let-def committed Mar 30, 2013
Showing with 11 additions and 5 deletions.
  1. +11 −5 command.ml
View
@@ -101,16 +101,22 @@ let command_tell = {
in
let rec loop state =
let bufpos = ref state.pos in
- let outlines, chunks, types =
+ let tokens, outlines, chunks, types =
+ state.tokens,
(History.cutoff state.outlines),
(History.cutoff state.chunks),
(History.cutoff state.types)
in
- let tokens, outlines =
- try Outline.parse ~bufpos state.tokens outlines lexbuf
- with Lexer.Error _ as exn ->
- state.tokens, Outline.append_exns [exn] outlines
+ let exns, tokens, outlines =
+ match Location.catch_warnings
+ (fun () -> Outline.parse ~bufpos tokens outlines lexbuf)
+ with
+ | warnings, Misc.Inr (tokens, outlines) ->
+ warnings, tokens, outlines
+ | warnings, Misc.Inl exn ->
+ exn :: warnings, tokens, outlines
in
+ let outlines = Outline.append_exns exns outlines in
let chunks = Chunk.sync outlines chunks in
let types = Typer.sync chunks types in
let pos = !bufpos in

0 comments on commit 9a7783d

Please sign in to comment.