caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Ocamllex newline counting...
@ 2008-03-07  9:57 Till Varoquaux
  2008-03-07 15:39 ` [Caml-list] " Berke Durak
  2008-03-12  1:00 ` Nathaniel Gray
  0 siblings, 2 replies; 3+ messages in thread
From: Till Varoquaux @ 2008-03-07  9:57 UTC (permalink / raw)
  To: OCaml

The title is pretty self explanetory: Ocamllex is able to keep track
of positions automatically but it needs help with new lines ( you need
to register new lines with a function like:

 let newline lexbuf =
    let pos = lexbuf.lex_curr_p in
    lexbuf.lex_curr_p <-
      { pos with pos_lnum = pos.pos_lnum + 1; pos_bol = pos.pos_cnum }
).
This tends to pollute the code and require you to add additional rules
and underlying machinery. I can see one easy workaround: pipe the
function you build your lexer from trough an additional function that
registers newlines. This seems a bit costly at run time but should be
just fine in most cases.

Is there any fundamental reason I am missing why newlines are not
handled natively in the generated automaton?

Cheers,

Till


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-03-12  1:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-07  9:57 Ocamllex newline counting Till Varoquaux
2008-03-07 15:39 ` [Caml-list] " Berke Durak
2008-03-12  1:00 ` Nathaniel Gray

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).