Unnecessary code in "Parsing with OCamllex and Menhir" ?
benjub opened this issue · 0 comments
benjub commented
In https://dev.realworldocaml.org/parsing-with-ocamllex-and-menhir.html, the book defines a function
open Lexing
let next_line lexbuf =
let pos = lexbuf.lex_curr_p in
lexbuf.lex_curr_p <-
{ pos with pos_bol = pos.pos_cnum;
pos_lnum = pos.pos_lnum + 1
}
but the Lexing
module already contains a function new_line
which is nearly identical (except that it also handles the case when positions are not tracked). Is there a particular reason to define a new function ?