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 LAA04652; Sat, 30 Aug 2003 11:24:10 +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 LAA00053 for ; Sat, 30 Aug 2003 11:24:08 +0200 (MET DST) Received: from ep09.kernel.pl (ep09.kernel.pl [212.87.11.162]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h7U9O7f03146 for ; Sat, 30 Aug 2003 11:24:07 +0200 (MET DST) Received: (qmail 30815 invoked by uid 566); 30 Aug 2003 09:24:06 -0000 Date: Sat, 30 Aug 2003 11:22:47 +0200 From: Michal Moskal To: David Van Horn Cc: caml-list@inria.fr Subject: Re: [Caml-list] Notion of lexer state in ocamllex? Message-ID: <20030830092247.GA6055@roke.freak> Mail-Followup-To: David Van Horn , caml-list@inria.fr References: <3F4FBB16.5000006@cs.uvm.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3F4FBB16.5000006@cs.uvm.edu> User-Agent: Mutt/1.4.1i X-PGP-Fingerprint: CF89 1B14 11BE 1CC9 2CA3 7497 5E32 69B4 BC71 B4C2 X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; michal:01 moskal:01 malekith:01 pld-linux:01 caml-list:01 horn:99 michal:01 moskal:01 malekith:01 kernel:01 token:01 token:01 parser:02 gcs:03 wrote:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, Aug 29, 2003 at 03:44:06PM -0500, David Van Horn wrote: > I'm new to ocamllex and I am trying to translate a lexer written using CUP > (for Java), but I don't understand how parser state is accomplished in > ocamllex. For example, I have: > > "/*" { yybegin(INCOMMENT); } > "*/" { yybegin(YYINITIAL); } > [^\*]+ { } > > Any ideas how to do this in ocamllex? Thanks. rule token = parse ... | "/*" { comment lexbuf; token lexbuf } ... and comment = parse "*/" { () } _ { comment lexbuf } Or something like this. -- : Michal Moskal :: http://www.kernel.pl/~malekith : GCS {C,UL}++++$ a? !tv : When in doubt, use brute force. -- Ken Thompson : {E-,w}-- {b++,e}>+++ h ------------------- 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