* [Caml-list] stream parsers with location information?
@ 2012-07-08 10:01 Nicolas Ojeda Bar
2012-07-08 10:18 ` Gabriel Scherer
0 siblings, 1 reply; 2+ messages in thread
From: Nicolas Ojeda Bar @ 2012-07-08 10:01 UTC (permalink / raw)
To: caml-list
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] stream parsers with location information?
2012-07-08 10:01 [Caml-list] stream parsers with location information? Nicolas Ojeda Bar
@ 2012-07-08 10:18 ` Gabriel Scherer
0 siblings, 0 replies; 2+ messages in thread
From: Gabriel Scherer @ 2012-07-08 10:18 UTC (permalink / raw)
To: Nicolas Ojeda Bar; +Cc: caml-list
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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-07-08 10:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-08 10:01 [Caml-list] stream parsers with location information? Nicolas Ojeda Bar
2012-07-08 10:18 ` Gabriel Scherer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox