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 KAA18505; Tue, 11 May 2004 10:33:04 +0200 (MET DST) 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 KAA19119 for ; Tue, 11 May 2004 10:33:03 +0200 (MET DST) Received: from interferon.mpi-sb.mpg.de (ag5.mpi-sb.mpg.de [139.19.1.1]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i4B8X2SH012986 for ; Tue, 11 May 2004 10:33:02 +0200 Received: from amavis by interferon.mpi-sb.mpg.de with scanned-ok (Exim 3.35 #1 (Debian)) id 1BNShB-0004G2-00 for ; Tue, 11 May 2004 10:33:01 +0200 Received: from data ([139.19.90.238] helo=mpi-sb.mpg.de) by interferon.mpi-sb.mpg.de with esmtp (Exim 3.35 #1 (Debian)) id 1BNSgn-0004Ah-00; Tue, 11 May 2004 10:32:37 +0200 Received: from mpiat2314 (mail@mpiat2314 [139.19.20.103]) by mpi-sb.mpg.de (8.12.9+Sun/8.12.9) with ESMTP id i4B8WaLT008008; Tue, 11 May 2004 10:32:37 +0200 (MEST) Received: from localhost ([127.0.0.1] helo=mpiat2314 ident=prevosto) by mpiat2314 with smtp (Exim 3.35 #1 (Debian)) id 1BNSgm-0007ie-00; Tue, 11 May 2004 10:32:36 +0200 Date: Tue, 11 May 2004 10:32:36 +0200 From: Virgile Prevosto To: John Goerzen Cc: caml-list@inria.fr Subject: Re: [Caml-list] camlp4 extensions and lexer replacements Message-Id: <20040511103236.2cb98d35@mpiat2314> In-Reply-To: <20040510191943.GB14068@excelhustler.com> References: <20040510191943.GB14068@excelhustler.com> X-Mailer: Sylpheed version 0.9.10claws (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by AMaViS perl-11 X-Miltered: at concorde with ID 40A08FBE.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; virgile:01 prevosto:01 prevosto:01 caml-list:01 camlp:01 replacements:01 plexer:01 gmake:01 overwrite:01 plexer:01 lident:01 lident:01 hashtable:01 wether:01 camlp:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Le lundi 10 mai, =E0 14h19 -0500, John Goerzen a =E9crit: >=20 > But #2 is trickier. pa_o.ml contains this: >=20 > Grammar.Unsafe.gram_reinit gram (Plexer.gmake ()); >=20 > So I can't define my lexer first -- pa_o.ml will just overwrite it. > Worse, I can't define my lexer second, either. Plexer relies on the > (strange, imho) notion of deciding whether something is a LIDENT or > keyword based on the list of keywords-as-tokens that were encountered > in a grammar. But the grammar reinit functions that I would have to > use to put in my lexer don't preserve that information, so my lexer > would have no way to differentiate a LIDENT from a keyword. Also, > Plexer provides no way to get a list of entries in its internal > hashtable. >=20 Hello, I'm not sure wether this will help you or not, but according to camlp4 documentation (http://caml.inria.fr/camlp4/manual/lib/Grammar.html#TYPEg), Grammar.tokens provides a way to get the list of the keywords used so far: "val tokens : g -> string -> (string * int) list Given a grammar and a token pattern constructor, returns the list of the corresponding values currently used in all entries of this grammar. The integer is the number of times this pattern value is used. Examples: * If the associated lexer uses ("", xxx) to represent a keyword (what is represented by then simple string xxx in an EXTEND statement rule), the call Grammar.token g "" returns the keywords list." Note that keywords are not always LIDENT: ~ [502]$ ocaml Objective Caml version 3.07+2 # #load "camlp4o.cma";; Camlp4 Parsing version 3.07+2 # let x =3D fst (List.split (Grammar.tokens Pcaml.gram ""));; val x : string list =3D ["in"; "<>"; "-."; "<=3D"; "struct"; "asr"; "if"; "{<"; "[<"; "<-"; ";;"; "lor"; "external"; "sig"; "virtual"; ":>"; ":=3D"; "type"; "::"; "method"; "then"; "**"; "true"; "match"; "parser"; "try"; "for"; "new"; "to"; "do"; "else"; "land"; "and"; "private"; "&&"; "initializer"; "as"; "lazy"; "open"; "false"; "rec"; "~"; "}"; "|"; "end"; "{"; "or"; "constraint"; "of"; "lxor"; ">}"; "`"; "_"; "^"; "]"; "["; "with"; "inherit"; "let"; "!=3D"; "object"; "||"; "include"; "while"; "module"; ">]"; "@"; "?"; ">"; "=3D"; "assert"; "<"; ";"; ":"; "??"; "when"; "exception"; "lsr"; "mutable" "/"; "[|"; "."; "-"; ","; "lsl"; "done"; "+"; "begin"; "downto"; "*"; ")" "|]"; "("; "function"; "'"; "&"; "functor"; "%"; "$"; ">=3D"; "#"; "~-."; "!"; "~-"; "fun"; "mod"; "class"; ".."; "=3D=3D"; "->"; "val"] --=20 E tutto per oggi, a la prossima volta Virgile ------------------- 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