From: Thierry SALSET <ts@cermics.enpc.fr>
To: Samuel.Lacas@trusted-logic.fr
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] single-line comment request
Date: Wed, 09 Apr 2003 17:15:57 +0200 (CEST) [thread overview]
Message-ID: <20030409.171557.95501305.ts@cassis.enpc.fr> (raw)
In-Reply-To: <20030408171708.A3382@ouessant.trusted-logic.fr>
[-- Attachment #1: Type: Text/Plain, Size: 875 bytes --]
>>>>> "Samuel" == Samuel Lacas <Samuel.Lacas@trusted-logic.fr> writes:
Samuel> Nickolay Semyonov-Kolchin a écrit 0.5K le Tue, Apr 08, 2003
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 _ = ## Another single line comment
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 camlp4
lexer should allow that. A patch to camlp4/lib/plexer.ml (O'Caml 3.06)
follows.
Thierry Salset
CERMICS / ENPC
[-- Attachment #2: plexer.diff --]
[-- Type: Text/Plain, Size: 1363 bytes --]
*** 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 prev parent reply other threads:[~2003-04-09 15:16 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-08 12:56 Nickolay Semyonov-Kolchin
2003-04-08 15:17 ` Samuel Lacas
2003-04-08 14:27 ` Nickolay Semyonov-Kolchin
2003-04-08 16:21 ` Samuel Lacas
2003-04-09 15:15 ` Thierry SALSET [this message]
2003-04-08 15:19 ` Brian Hurt
2003-04-08 14:25 ` Nickolay Semyonov-Kolchin
2003-04-08 16:08 ` Brian Hurt
2003-04-08 15:38 ` Nickolay Semyonov-Kolchin
2003-04-08 17:42 ` Brian Hurt
2003-04-08 17:31 ` Chris Hecker
2003-04-08 16:29 ` Nickolay Semyonov-Kolchin
2003-04-08 19:26 ` Basile STARYNKEVITCH
2003-04-08 20:22 ` Brian Hurt
2003-04-08 21:37 ` Michal Moskal
2003-04-08 17:13 ` Brian Hurt
2003-04-08 19:23 ` Chris Hecker
2003-04-08 18:49 ` Karl Zilles
2003-04-08 19:04 ` Brian Hurt
2003-04-08 21:57 ` Daniel Andor
2003-04-08 22:07 ` Michal Moskal
2003-04-08 22:09 ` Brian Hurt
2003-04-10 2:59 ` cashin
2003-04-10 7:58 ` [Caml-list] { ... } vs ( ... ) vs begin ... end Frederic van der Plancke
2003-04-08 19:42 ` [Caml-list] single-line comment request Daniel M. Albro
2003-04-08 18:53 ` Alexander V. Voinov
2003-04-08 18:19 ` Nickolay Semyonov-Kolchin
2003-04-08 22:40 ` Joshua Scholar
2003-04-13 19:46 ` Andreas Rossberg
2003-04-13 22:57 ` Daniel M. Albro
2003-04-08 19:53 ` Jeff Henrikson
2003-04-08 20:31 ` Brian Hurt
2003-04-13 14:07 ` John Max Skaller
2003-04-08 15:28 ` Damien
2003-04-08 14:49 ` Nickolay Semyonov-Kolchin
2003-04-08 15:39 ` Brian Hurt
2003-04-08 15:45 ` malc
2003-04-08 15:45 ` Samuel Lacas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030409.171557.95501305.ts@cassis.enpc.fr \
--to=ts@cermics.enpc.fr \
--cc=Samuel.Lacas@trusted-logic.fr \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).