From: Pietro Abate <Pietro.Abate@anu.edu.au>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] camlp4 help
Date: Tue, 19 Jul 2005 15:23:21 +1000 [thread overview]
Message-ID: <20050719052321.GA23096@pulp.anu.edu.au> (raw)
In-Reply-To: <rl4qasa0dw.fsf@ithif59.inf.tu-dresden.de>
On Mon, Jul 18, 2005 at 12:12:27PM +0200, Hendrik Tews wrote:
> See "More Power for Camlp4 recursive descent parsing" in
> http://wwwtcs.inf.tu-dresden.de/~tews/ocamlp4/camlp4-undoc.html
Inspired from your page I'm trying to mix regular expression
and streams... below there's a bit of code to parsa entry of the form
TEST ------ END
where you can have an arbitray ( > 1) number of dashes.
However, for some reasons, it doesn't work as expected. The function test
correctly recognizes the string "-----" but then I get a Stream.Error from
nowhere ( guess from Grammar.Entry.of_parser ) and the parsin fails...
what am I doing wrong ?
:)
p
------------
(*pp camlp4o -I . pa_extend.cmo q_MLast.cmo *)
let (=~) s re = Str.string_match (Str.regexp re) s 0;;
let test rex strm =
match Stream.peek strm with
| Some(_,s) when s =~ rex -> print_endline "!!!!" ; ()
| _ -> raise Stream.Failure
;;
let test_sep_dash =
Grammar.Entry.of_parser Pcaml.gram "test_sep_dash" ( test "-+" )
;;
EXTEND
GLOBAL: Pcaml.str_item ;
Pcaml.str_item: [[
"TEST"; test_sep_dash; "END" -> <:str_item< value ii = "!!!!" >>
]];
END
-------------
#ocamlfind ocamlc -package str -c -pp "camlp4o -I . pa_extend.cmo q_MLast.cmo " -I /usr/lib/ocaml/3.08.3/camlp4 te.ml
#camlp4o /usr/lib/ocaml/3.08.3/str.cma ./te.cmo pr_o.cmo oo.ml
!!!!
File "oo.ml", line 2, characters 5-13:
Parse error: [test_sep_dash] expected after 'TEST' (in [str_item])
Uncaught exception: Stream.Error("[test_sep_dash] expected after 'TEST' (in [str_item])")
--
++ Blog: http://blog.rsise.anu.edu.au/?q=pietro
++
++ "All great truths begin as blasphemies." -George Bernard Shaw
++ Please avoid sending me Word or PowerPoint attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html
next prev parent reply other threads:[~2005-07-19 8:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-15 8:39 Pietro Abate
2005-07-15 20:24 ` [Caml-list] " Martin Jambon
2005-07-18 10:12 ` Hendrik Tews
2005-07-19 5:23 ` Pietro Abate [this message]
2005-07-20 7:37 ` Hendrik Tews
2005-07-20 9:57 ` Gerd Stolpmann
2009-03-21 3:41 Camlp4 help Andre Nathan
2009-03-21 15:26 ` [Caml-list] " blue storm
2009-03-21 16:14 ` Andre Nathan
2009-03-21 17:24 ` blue storm
2009-03-21 17:26 ` blue storm
2009-04-13 0:05 Andre Nathan
2009-04-13 19:08 ` [Caml-list] " Andre Nathan
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=20050719052321.GA23096@pulp.anu.edu.au \
--to=pietro.abate@anu.edu.au \
--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