refactor: reuse a bit of code

This commit is contained in:
Simon Cruanes 2019-11-05 19:43:37 -06:00
parent 404e35f850
commit 853c9f27bd

View file

@ -170,16 +170,15 @@ module Make(Sexp : SEXP) = struct
exception E_end
exception E_error of int * int * string
let error_ lexbuf msg =
let start = Lexing.lexeme_start_p lexbuf in
let line = start.Lexing.pos_lnum in
let col = start.Lexing.pos_cnum - start.Lexing.pos_bol in
raise (E_error (line,col,msg))
let pair_of_pos_ p =
let open Lexing in
p.pos_lnum, p.pos_cnum - p.pos_bol
let error_ lexbuf msg =
let start = Lexing.lexeme_start_p lexbuf in
let line, col = pair_of_pos_ start in
raise (E_error (line,col,msg))
let next (t:t) =
let open Lexing in
let rec expr () = match cur t with