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 TAA25809; Mon, 6 Sep 2004 19:34:44 +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 TAA23185 for ; Mon, 6 Sep 2004 19:34:43 +0200 (MET DST) Received: from yquem.inria.fr (yquem.inria.fr [128.93.8.37]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id i86HYecA024660; Mon, 6 Sep 2004 19:34:40 +0200 Received: by yquem.inria.fr (Postfix, from userid 18041) id AAF41BC42; Mon, 6 Sep 2004 19:34:40 +0200 (CEST) Date: Mon, 6 Sep 2004 19:34:40 +0200 To: "lehalle@miriad" Cc: caml-list@inria.fr Subject: Re: [Caml-list] ocamllex parametrized parse regexp Message-ID: <20040906173440.GB17368@yquem.inria.fr> References: <20040906155041.GG7964@alan-schm1p> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.28i From: luc.maranget@inria.fr (Luc Maranget) X-Miltered: at concorde with ID 413C9FB0.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 printf:01 printf:01 unk:99 fprintf:01 compiles:01 'let:01 regexp:01 regexp:01 compiler:01 implements:01 maranget:02 maranget:02 eof:02 external:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > Hi, > > I try to use ocamllex like this (I want to have one of the parsing regexp > to be read from an external file) : > > > { > open Printf;; > > } > let digit = ['0'-'9'] > > let mark = ...read in a file... > > rule oaddress outcan = parse > | mark as bemark > { > printf "MARK(%s)" bemark; > oaddress outcan lexbuf > } > | _ as d > { printf "Unk[%c]\n" d; > oaddress outcan lexbuf > } > | eof > { > fprintf outcan "END"; > } > > Is it possible or useless to try somethink like that ? ocamllex is a standard compiler, it compiles its input base.mll file into a base.ml file that implements the lexer. The language understood by ocamllex remains quite basic. As a consequence there is no built-in support for what you want. (Basically the 'let name = regexp' feature can be seen as simple macros). However, nothing prevents you from generating the appropriate source (.mll) files before you feed them into ocamllex. -- Luc ------------------- 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