caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: Nicolas Ojeda Bar <nojb@math.harvard.edu>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] stream parsers with location information?
Date: Sun, 8 Jul 2012 12:18:30 +0200	[thread overview]
Message-ID: <CAPFanBEwHQ6znL=3atL0JO36aDXtOtKMj5T7a7JV-sQw0o+Kww@mail.gmail.com> (raw)
In-Reply-To: <73F2C118-89C0-4EFB-849D-1F70B4B58AA4@math.harvard.edu>

Indeed: you need your lexer to produce location information. Instead
of manipulating a (token Stream.t), you will produce (and then parse
at the lexer level) a ((token * location) Stream.t).

This is the way Camlp4 parsers are implemented (recursive descent over
a stream of tokens and positions). See also "Planck", an experiment at
combinator parser libraries by Jun Furuse, using a similar (but
different) architecture.
  http://bluestorm.info/camlp4/camlp4-doc/Sig.Lexer.html
  https://bitbucket.org/camlspotter/planck/
  http://camlspotter.blogspot.fr/2011/05/planck-small-parser-combinator-library.html


On Sun, Jul 8, 2012 at 12:01 PM, Nicolas Ojeda Bar
<nojb@math.harvard.edu> wrote:
> Hi,
>
> Is there a clean way to use stream parsers/lexers if I want to have
> location (line number, character position) information attached to
> each token?
>
> Thanks!
> Nicolas
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>

      reply	other threads:[~2012-07-08 10:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-08 10:01 Nicolas Ojeda Bar
2012-07-08 10:18 ` Gabriel Scherer [this message]

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='CAPFanBEwHQ6znL=3atL0JO36aDXtOtKMj5T7a7JV-sQw0o+Kww@mail.gmail.com' \
    --to=gabriel.scherer@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=nojb@math.harvard.edu \
    /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;
as well as URLs for NNTP newsgroup(s).