From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA13105; Tue, 4 Nov 2003 14:07:24 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA12915 for ; Tue, 4 Nov 2003 14:07:23 +0100 (MET) Received: from is.intellij.net (host98.intellij.net [213.182.181.98]) by concorde.inria.fr (8.11.1/8.11.1) with SMTP id hA4D7K123719 for ; Tue, 4 Nov 2003 14:07:21 +0100 (MET) Received: (qmail 24718 invoked by uid 89); 4 Nov 2003 13:07:19 -0000 Received: from unknown (HELO dsl-ps.labs.intellij.net) (192.168.1.43) by host98.intellij.net with SMTP; 4 Nov 2003 13:07:18 -0000 From: Dmitry Lomov Reply-To: dsl@intellij.com Organization: IntelliJ Labs To: "caml-list@inria.fr" Subject: Re: [Caml-list] Right way to determine used syntax ( camlp4 ) Date: Tue, 4 Nov 2003 15:59:53 +0300 User-Agent: KMail/1.5 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200311041559.54268.Dmitry.Lomov@intellij.com> X-Loop: caml-list@inria.fr X-Spam: no; 0.00; lomov:01 lomov:01 intellij:01 caml-list:01 camlp:01 artem:01 expr:01 expr:01 pcaml:01 intellij:01 jetbrains:01 cmo:01 cmo:01 ocaml:01 dmitry:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, I believe the best way is to have two separate syntax extension files, and then just supply the right one (either for normal or "revised" syntax) at compile time. What you propose has a strong hackish smell :) Friendly, Dmitry On Tuesday 04 November 2003 13:46, Artem Prisyznuk wrote: > Hello, > > I write small extension for ocaml. But I have next question. > > Grammar entry differ for pa_o.cmo and pa_r.cmo. So in my pa_ module > I want auto determinate which syntax used and apply differ EXTEND > branches for normal syntax and revised syntax. Now I determine which > syntax > used with next code: > > let normal_extend () = > EXTEND > GLOBAL: expr; > expr: LEVEL "expr1" > [[ ..... ]] > ...... > END;; > > let revised_extend () = > EXTEND > GLOBAL: expr; > expr: LEVEL "top" > [[ ..... ]] > ...... > END;; > > > let _ = > try ignore(Grammar.Entry.find Pcaml.expr "expr1"); normal_extend () > with Not_found -> revised_extend ();; > > > It work, but I don't assurance what it's right way. > > Any suggestions? -- Dmitry Lomov IntelliJ Labs / JetBrains Inc. http://www.intellij.com "Develop with pleasure!" ------------------- 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