mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
refactor: reuse a bit of code
This commit is contained in:
parent
404e35f850
commit
853c9f27bd
1 changed files with 5 additions and 6 deletions
|
|
@ -170,16 +170,15 @@ module Make(Sexp : SEXP) = struct
|
||||||
exception E_end
|
exception E_end
|
||||||
exception E_error of int * int * string
|
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 pair_of_pos_ p =
|
||||||
let open Lexing in
|
let open Lexing in
|
||||||
p.pos_lnum, p.pos_cnum - p.pos_bol
|
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 next (t:t) =
|
||||||
let open Lexing in
|
let open Lexing in
|
||||||
let rec expr () = match cur t with
|
let rec expr () = match cur t with
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue