From: Joel Reymont <joelr1@gmail.com>
To: O'Caml Mailing List <caml-list@yquem.inria.fr>
Subject: Re: camlp4 stream parser syntax
Date: Sat, 7 Mar 2009 22:52:52 +0000 [thread overview]
Message-ID: <24D11586-4F15-4B6E-8FB7-58651317164D@gmail.com> (raw)
In-Reply-To: <A60C1C9E-9990-40E8-B6B3-6B4FBBB50F24@gmail.com>
> Where can I read up on the syntax of the following in a camlp4
> stream parser?
>
> | [<' INT n >] -> Int n
>
> For example, where are [< ... >] described and why is the ' needed
> in between?
To be more precise, I'm using camlp4 to parse a language into a non-
OCaml AST.
I'm trying to figure out the meaning of [<, >], [[ and ]]
My ocamllex lexer is wrapped to make it look like a stream lexer
(below) and I'm returning a tuple of (tok, loc) because I don't see
another way of making token location available to the parser.
Still, I'm how to integrate the reporting of error location into ?? in
something like this
| [< 'Token.Kwd '('; e=parse_expr; 'Token.Kwd ')' ?? "expected ')'"
>] -> e
Would someone kindly shed light on this?
Thanks in advance, Joel
P.S. ocamllex wrapper to return a' Stream.t
{
let from_lexbuf tab lb =
let next _ =
let tok = token tab lb in
let loc = Loc.of_lexbuf lb in
Some (tok, loc)
in Stream.from next
let setup_loc lb loc =
let start_pos = Loc.start_pos loc in
lb.lex_abs_pos <- start_pos.pos_cnum;
lb.lex_curr_p <- start_pos
let from_string loc tab str =
let lb = Lexing.from_string str in
setup_loc lb loc;
from_lexbuf tab lb
}
---
http://tinyco.de
Mac, C++, OCaml
next prev parent reply other threads:[~2009-03-07 22:54 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-07 22:38 Joel Reymont
2009-03-07 22:52 ` Joel Reymont [this message]
2009-03-07 23:21 ` Re : [Caml-list] " Matthieu Wipliez
2009-03-07 23:42 ` Joel Reymont
2009-03-08 0:40 ` Joel Reymont
2009-03-08 1:08 ` Re : " Matthieu Wipliez
2009-03-08 8:25 ` Joel Reymont
2009-03-08 9:37 ` Daniel de Rauglaudre
2009-03-08 9:51 ` Joel Reymont
2009-03-08 10:27 ` Daniel de Rauglaudre
2009-03-08 10:35 ` Joel Reymont
2009-03-08 11:07 ` Joel Reymont
2009-03-08 11:28 ` Daniel de Rauglaudre
2009-03-08 11:45 ` Re : Re : " Matthieu Wipliez
2009-03-08 11:52 ` Joel Reymont
2009-03-08 13:33 ` Re : " Matthieu Wipliez
2009-03-08 13:59 ` Joel Reymont
2009-03-08 14:09 ` Re : " Matthieu Wipliez
2009-03-08 14:30 ` Joel Reymont
2009-03-08 15:07 ` Re : " Matthieu Wipliez
2009-03-08 15:24 ` Joel Reymont
2009-03-08 15:32 ` Re : " Matthieu Wipliez
2009-03-08 15:39 ` Joel Reymont
2009-03-08 15:46 ` Joel Reymont
2009-03-08 15:55 ` Re : " Matthieu Wipliez
2009-03-08 16:58 ` Joel Reymont
2009-03-08 17:04 ` Re : " Matthieu Wipliez
2009-03-08 17:15 ` Joel Reymont
2009-03-08 9:34 ` Joel Reymont
2009-03-07 23:52 ` [Caml-list] " Jon Harrop
2009-03-07 23:53 ` Joel Reymont
2009-03-08 0:12 ` Jon Harrop
2009-03-08 0:20 ` Re : " Matthieu Wipliez
2009-03-08 0:29 ` Jon Harrop
2009-03-08 0:30 ` Re : " Joel Reymont
2009-03-08 0:37 ` Re : " Matthieu Wipliez
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=24D11586-4F15-4B6E-8FB7-58651317164D@gmail.com \
--to=joelr1@gmail.com \
--cc=caml-list@yquem.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