Browse thread
[Caml-list] camlp4: pretty printing not to a file
[
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: | Daniel de Rauglaudre <daniel.de_rauglaudre@i...> |
| Subject: | Re: [Caml-list] camlp4: pretty printing not to a file |
Hi,
On Thu, Aug 29, 2002 at 02:51:41PM -0400, jehenrik wrote:
> Also it seems like there might be a way to take the parsing offsets
> and look back in the original pre-parsed string to get the real
> source snippet.
let getsource fname (bp, ep) =
let ic = open_in_bin fname in
let s = String.create (ep - bp) in
seek_in ic bp;
really_input ic s 0 (ep - bp);
close_in ic;
s
> EXTEND
> expr: LEVEL "expr1"
> [ LEFTA [ "REFLECTLIST"; hd = expr; "::"; tl = expr ->
> map_expr reflect_arg <:expr< [$hd$::$tl$] >>
> ] ];
> END;;
>
> let r = Grammar.Entry.parse expr (Stream.of_string "REFLECTLIST
> [1;3;5;11]");;
Input: REFLECTLIST [1;3;5;11]
The rule recognizes the keyword REFLECTLIST.
Then the rule symbol "hd = expr" recognizes the expr "[1;3;5;11]"
Then the rule expects a "::".
There is no "::".
Therefore: syntax error.
> let r = Grammar.Entry.parse expr (Stream.of_string "REFLECTLIST
> 1::3::5::11::[]\
> ");;
Idem. The symbol "hd = expr" recognizes the expr "1::3::5::11::[]".
There is no "::" following it.
Therefore syntax error again.
> Can anyone please enlighten me?
And why not just:
EXTEND
expr: LEVEL "expr1"
[ LEFTA [ "REFLECTLIST"; e = expr ->
map_expr reflect_arg e
] ];
END;;
--
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners