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 RAA20700; Wed, 9 Apr 2003 17:16:00 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA20604 for ; Wed, 9 Apr 2003 17:15:59 +0200 (MET DST) Received: from titan.enpc.fr (titan.enpc.fr [195.221.193.114]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h39FFw904997 for ; Wed, 9 Apr 2003 17:15:58 +0200 (MET DST) Received: from cassis.enpc.fr (cassis [195.221.193.109]) by titan.enpc.fr (8.12.3/8.12.3/Debian-6.3) with ESMTP id h39FFvBo002290; Wed, 9 Apr 2003 17:15:57 +0200 Received: from localhost (localhost.localdomain [127.0.0.1]) by cassis.enpc.fr (8.11.6/8.11.6) with ESMTP id h39FFvK03275; Wed, 9 Apr 2003 17:15:57 +0200 Date: Wed, 09 Apr 2003 17:15:57 +0200 (CEST) Message-Id: <20030409.171557.95501305.ts@cassis.enpc.fr> To: Samuel.Lacas@trusted-logic.fr Cc: caml-list@inria.fr Subject: Re: [Caml-list] single-line comment request From: Thierry SALSET In-Reply-To: <20030408171708.A3382@ouessant.trusted-logic.fr> References: <200304081756.05304.snob@snob.spb.ru> <20030408171708.A3382@ouessant.trusted-logic.fr> X-Mailer: Mew version 2.2 on Emacs 20.7 / Mule 4.0 (HANANOEN) Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Wed_Apr__9_17:15:57_2003_656)--" Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-milter (http://amavis.org/) X-Spam: no; 0.00; cermics:01 enpc:01 caml-list:01 samuel:01 lacas:01 nickolay:01 weis:01 camlp:01 personnally:01 plexer:01 3.06:01 patched:01 linenum:01 ecrit:01 ocaml:01 X-Attachments: name="plexer.diff" Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk ----Next_Part(Wed_Apr__9_17:15:57_2003_656)-- Content-Type: Text/Plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable >>>>> "Samuel" =3D=3D Samuel Lacas writ= es: Samuel> Nickolay Semyonov-Kolchin a =E9crit 0.5K le Tue, Apr 08, 20= 03 Samuel> at 05:56:05PM +0500: Hi, I really want single-line comment Samuel> in Ocaml. Peter Weis (sorry, if I typed name wrong) several= Samuel> time ago said that "there is no suitable character for Samuel> single line comment". Why don't use double '#'? I.e. '##'. Samuel> Single line comment let _ =3D ## Another single line commen= t Samuel> ... Samuel> Hmm, may be a "simple" camlp4 extension can cater for your Samuel> need, though I personnally never explored camlp4 in depth..= .= Comments are processed by the lexer, so a simple extension to the camlp= 4 lexer should allow that. A patch to camlp4/lib/plexer.ml (O'Caml 3.06) follows. Thierry Salset CERMICS / ENPC ----Next_Part(Wed_Apr__9_17:15:57_2003_656)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="plexer.diff" *** camlp4/lib/plexer.ml Fri Jul 19 16:53:48 2002 --- camlp4/lib/patched/plexer.ml Wed Apr 9 17:10:26 2003 *************** *** 127,133 **** [ [: `' ' | '\010' | '\013' | '\t' | '\026' | '\012'; s :] -> next_token s | [: `'('; s :] -> left_paren bp s ! | [: `'#'; s :] -> do { spaces_tabs s; linenum bp s } | [: `('A'..'Z' | '\192'..'\214' | '\216'..'\222' as c); s :] -> let id = get_buff (ident (store 0 c) s) in let loc = (bp, Stream.count s) in --- 127,133 ---- [ [: `' ' | '\010' | '\013' | '\t' | '\026' | '\012'; s :] -> next_token s | [: `'('; s :] -> left_paren bp s ! | [: `'#'; s :] -> sharp bp s | [: `('A'..'Z' | '\192'..'\214' | '\216'..'\222' as c); s :] -> let id = get_buff (ident (store 0 c) s) in let loc = (bp, Stream.count s) in *************** *** 327,332 **** --- 327,340 ---- parser [ [: `'>' :] -> len | [: a = quotation bp (store len '>') :] -> a ] + and sharp bp = + parser + [ [: `'#'; _ = one_line_comment bp ; a = next_token :] -> a + | [: s :] -> do { spaces_tabs s; linenum bp s } ] + and one_line_comment bp = + parser + [ [: `'\n' :] -> () + | [: `_; s :] -> one_line_comment bp s ] and left_paren bp = parser [ [: `'*'; _ = comment bp; a = next_token :] -> a ----Next_Part(Wed_Apr__9_17:15:57_2003_656)---- ------------------- 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