From: Serge Leblanc <serge.leblanc@orange.fr>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] DELETE_RULE arguments?
Date: Wed, 22 Jul 2009 00:35:43 +0200 [thread overview]
Message-ID: <1248215743.6357.39.camel@serge2> (raw)
In-Reply-To: <1248006890.4590.166.camel@serge2>
[-- Attachment #1.1.1: Type: text/plain, Size: 954 bytes --]
In the attached exemple, the DELETE_RULE raise an exception Not_found.
The statement DELETE_RULE Gram foo: "foo"; LIDENT; END bar is exploded
as follows :
$ camlp4of -str "DELETE_RULE Gram foo: "foo"; LIDENT; bar END"
Gram.delete_rule foo
[ Gram.Snterm (Gram.Entry.obj (foo : 'foo Gram.Entry.t));
Gram.Stoken
(((function | LIDENT ((_)) -> true | _ -> false), "LIDENT ((_))"));
Gram.Snterm (Gram.Entry.obj (bar : 'bar Gram.Entry.t)) ]
while the running example is the following :
Gram.delete_rule foo
[ Gram.Skeyword "foo";
Gram.Stoken
(((function | LIDENT ((_)) -> true | _ -> false), "LIDENT _"));
Gram.Snterm (Gram.Entry.obj (bar : 'bar Gram.Entry.t)) ]
How do I write the rule DELETE_RULE to work in this case?
--
Serge Leblanc
gpg --keyserver hkp://keyserver.ubuntu.com:11371 --recv-keys 0x33243C1B
Fingerprint = 066C 005F 5595 D85C 7673 D969 1DD4 90C4 3324 3C1B
[-- Attachment #1.1.2: Type: text/html, Size: 1737 bytes --]
[-- Attachment #1.2: pr_ulex.ml --]
[-- Type: text/x-ocaml, Size: 1057 bytes --]
type t1 = A | B
type t2 = Foo of string * t1
let print_t2 = function
Foo (s,t) -> let print_t1 = function A -> "A" | B -> "B"
in Printf.printf "Foo (\"%s\",%s)\n" s (print_t1 t)
open Camlp4.PreCast
let foo = Gram.Entry.mk "foo"
let bar = Gram.Entry.mk "bar"
EXTEND Gram
GLOBAL: foo bar;
foo: [ [ "foo"; i = LIDENT; b = bar -> Foo(i,b) ] ];
bar: [ [ "?" -> A | "." -> B ] ];
END
let r = Gram.parse_string foo (Loc.mk "<string>") "foo x?"
in print_t2 r
let _ = Gram.Entry.print Format.std_formatter foo
try
DELETE_RULE Gram foo: "foo"; LIDENT; bar END
with Not_found -> Format.printf "@[no rule matched!@]@\n"
(* the correct sentence
let _ =
try
Gram.delete_rule foo
[ Gram.Skeyword "foo";
Gram.Stoken
(((function | LIDENT ((_)) -> true | _ -> false), "LIDENT _"));
Gram.Snterm (Gram.Entry.obj (bar : 'bar Gram.Entry.t)) ]
with | Not_found -> Format.printf "@[no rule matched!@]@\n"
*)
let _ = Gram.Entry.print Format.std_formatter foo
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
next prev parent reply other threads:[~2009-07-21 22:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-19 12:34 Serge Leblanc
2009-07-21 22:35 ` Serge Leblanc [this message]
2009-07-22 7:26 ` [Caml-list] " blue storm
2009-07-22 12:54 ` Serge Leblanc
2009-07-22 10:03 ` blue storm
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=1248215743.6357.39.camel@serge2 \
--to=serge.leblanc@orange.fr \
--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