In the directory of the OCaml sources (from SVN or a relase tarball), the source of the module Foo
of the standard library will be in stdlib/foo.{ml,mli}
(.mli
is the interface file, .ml
the implementation file). Looking at stdlib/lexing.ml
gives you:
let new_line lexbuf =
let lcp = lexbuf.lex_curr_p in
lexbuf.lex_curr_p <- { lcp with
pos_lnum = lcp.pos_lnum + 1;
pos_bol = lcp.pos_cnum;
}
You can implement this in your code as well, using open Lexing
to have the field names in scope, or using lexbuf.Lexing.lex_curr_p
, and { lcp with Lexing.pos_lnum = lcp.Lexing.pos_lnum ...
instead.
Edit: as you probably don't plan to hack the OCaml code yourself, let's give you the full thing:
let new_line lexbuf =
let lcp = lexbuf.Lexing.lex_curr_p in
lexbuf.Lexing.lex_curr_p <- { lcp with
Lexing.pos_lnum = lcp.Lexing.pos_lnum + 1;
Lexing.pos_bol = lcp.Lexing.pos_cnum;
}
add this at the top of the file that uses new_line
(if it says Lexing.new_line
, turn it into new_line
), and you should be fine.