[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Pietro Abate <Pietro.Abate@a...> |
| Subject: | Re: [Caml-list] camlp4 help |
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