You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The fields pos_lnum, pos_bol and pos_fname are not computed (this is
acknowledges
in the manual).
They would be really useful. Every time I write a parser, I have to write a
location module to store the byte offsets of line positions... Last time I was
pleased to see that this had finally been implemented only to find out that the
fields weren't computed.
type position = {
pos_fname : string;
pos_lnum : int;
pos_bol : int;
pos_cnum : int;
}
The text was updated successfully, but these errors were encountered:
The fields pos_lnum, pos_bol and pos_fname are not computed (this is
acknowledges in the manual).
They would be really useful. Every time I write a parser, I have to write a
location module to store the byte offsets of line positions... Last time I
was
pleased to see that this had finally been implemented only to find out that
the
fields weren't computed.
But the fields have to be computed by the lexer, since it is the only part of
the
code that has a notion of lines. So it has to be done by user-written code.
On Tue, Jan 18, 2005 at 03:43:46PM +0100, Damien Doligez wrote:
Full_Name: Berke Durak
Version: 3.08.2
The fields pos_lnum, pos_bol and pos_fname are not computed (this is
acknowledges in the manual).
They would be really useful. Every time I write a parser, I have to write a
location module to store the byte offsets of line positions... Last time I
was
pleased to see that this had finally been implemented only to find out that
the
fields weren't computed.
But the fields have to be computed by the lexer, since it is the only part of
the
code that has a notion of lines.
Yes.
So it has to be done by user-written code.
Why ? A Lexing.of_channel_with_lines, implemented as follows,
would be nice in the standard library.
let lexbuf_from_channel_with_lines p ic =
let x = ref 0 (* Byte count )
in
Lexing.from_function
(fun s n ->
let n = input ic s 0 n in
for i = 0 to n - 1 do
if s.[i] = '\n' then
( put offset etc. *)
done;
x := !x + n;
n)
;;
Original bug ID: 3431
Reporter: administrator
Status: closed
Resolution: won't fix
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Berke Durak
Version: 3.08.2
OS: Debian
Submission from: vol75-1-81-57-79-249.fbx.proxad.net (81.57.79.249)
Hello,
The fields pos_lnum, pos_bol and pos_fname are not computed (this is
acknowledges
in the manual).
They would be really useful. Every time I write a parser, I have to write a
location module to store the byte offsets of line positions... Last time I was
pleased to see that this had finally been implemented only to find out that the
fields weren't computed.
type position = {
pos_fname : string;
pos_lnum : int;
pos_bol : int;
pos_cnum : int;
}
The text was updated successfully, but these errors were encountered: