diff --git a/bin/main.ml b/bin/main.ml index 632ebf6..69a8387 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -1,6 +1,11 @@ open Format open Lambda_dti +(* Altenative to Lexing.flush_input so that pos_bol is also reset to 0 *) +let flush_input lexbuf = + Lexing.flush_input lexbuf; + lexbuf.lex_curr_p <- {lexbuf.lex_curr_p with pos_bol = 0} + let debug = ref false let rec read_eval_print lexbuf env tyenv = @@ -47,11 +52,11 @@ let rec read_eval_print lexbuf env tyenv = with | Failure message -> print "Failure: %s\n" message; - Lexing.flush_input lexbuf + flush_input lexbuf | Parser.Error -> (* Menhir *) let token = Lexing.lexeme lexbuf in print "Parser.Error: unexpected token %s\n" token; - Lexing.flush_input lexbuf + flush_input lexbuf | Typing.Type_error message -> print "Type_error: %s\n" message | Eval.Blame (r, p) -> begin diff --git a/lib/lexer.mll b/lib/lexer.mll index bf47347..2164509 100644 --- a/lib/lexer.mll +++ b/lib/lexer.mll @@ -26,7 +26,7 @@ let range_of lexbuf = rule main = parse [' ' '\t']+ { main lexbuf } -| [' ' '\t']* '\n'+ { Lexing.new_line lexbuf; main lexbuf } +| [' ' '\t']* '\n' { Lexing.new_line lexbuf; main lexbuf } | "(*" { comment lexbuf; main lexbuf } | ['0'-'9']+ {