From: "Till Varoquaux" <till.varoquaux@gmail.com>
To: OCaml <caml-list@inria.fr>
Subject: Ocamllex newline counting...
Date: Fri, 7 Mar 2008 09:57:28 +0000 [thread overview]
Message-ID: <9d3ec8300803070157y6bb173eew865e2f232cb4c789@mail.gmail.com> (raw)
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
next reply other threads:[~2008-03-07 9:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-07 9:57 Till Varoquaux [this message]
2008-03-07 15:39 ` [Caml-list] " Berke Durak
2008-03-12 1:00 ` Nathaniel Gray
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9d3ec8300803070157y6bb173eew865e2f232cb4c789@mail.gmail.com \
--to=till.varoquaux@gmail.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox