From: Joel Reymont <joelr1@gmail.com>
To: Matthieu Wipliez <mwipliez@yahoo.fr>
Cc: O'Caml Mailing List <caml-list@yquem.inria.fr>
Subject: Re: Re : [Caml-list] Re: camlp4 stream parser syntax
Date: Sat, 7 Mar 2009 23:42:55 +0000 [thread overview]
Message-ID: <D4AC88DD-F817-4924-83C7-931ACD1CA110@gmail.com> (raw)
In-Reply-To: <46331.52510.qm@web27007.mail.ukl.yahoo.com>
On Mar 7, 2009, at 11:21 PM, Matthieu Wipliez wrote:
> why are you using stream parsers instead of Camlp4 grammars ?
Because I don't know any better? I'm just starting out, really.
I have a parser that I wrote using ocamlyacc and menhir. I finally
when with dypgen and didn't touch the code for a few months. I then
tried to simplify the grammar on account of a later type checking pass
and realized that I cannot troubleshoot it.
I think I can make do with a camlp4 parser and it will vastly simplify
debugging.
> This:
> ...
> could be written as:
> expression: [
> [ (i, _) = INT -> Int i
> | (s, _) = STRING -> Str s
> ... ]
> ];
Doesn't your example assume that I'm using the camlp4 lexer?
> expression: [
> [ e1 = SELF; "/"; e2 = SELF ->
> if e2 = Int 0 then
> Loc.raise _loc (Failure "division by zero")
> else
> BinaryOp (e1, Div, e2) ]
> ];
Where does SELF above come from?
Can I use a token instead of "/" since I return SLASH whenever "/" is
found by the lexer.
> By the way, do you need you own tailor-made lexer? Camlp4 provides
> one that might satisfy your needs.
It has been said that it's not extensible so I wrote my own lexer
using ocamllex and wrapped it to return (tok, loc) Stream.t.
> Otherwise, you can always define your own lexer (I had to do that
> for the project I'm working on, see file attached).
Thanks, I'll study it.
> Your parser would then look like
>
> (* functor application *)
> module Camlp4Loc = Camlp4.Struct.Loc
> module Lexer = Cal_lexer.Make(Camlp4Loc)
> module Gram = Camlp4.Struct.Grammar.Static.Make(Lexer)
Is this extending the OCaml grammar or starting with an "empty" one?
> (* rule definition *)
> let rule = Gram.Entry.mk "rule"
Is this the "start" rule of the parser?
Thanks, Joel
---
http://tinyco.de
Mac, C++, OCaml
next prev parent reply other threads:[~2009-03-07 23:43 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
2009-03-07 23:21 ` Re : [Caml-list] " Matthieu Wipliez
2009-03-07 23:42 ` Joel Reymont [this message]
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=D4AC88DD-F817-4924-83C7-931ACD1CA110@gmail.com \
--to=joelr1@gmail.com \
--cc=caml-list@yquem.inria.fr \
--cc=mwipliez@yahoo.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