Re: recursive comments and Re: Techniques for writing an interpreter

sestoft@ellemose.dina.kvl.dk (Peter Sestoft)
20 Mar 1998 11:40:54 -0500

          From comp.compilers

Related articles
Techniques for writing an interpreter simon@magnorth.nildram.co.uk (Simon Chapman) (1998-03-06)
Re: Techniques for writing an interpreter adrian@dcs.rhbnc.ac.uk (1998-03-12)
Re: Techniques for writing an interpreter ct7@mitre.org (W. Craig Trader) (1998-03-15)
Re: Techniques for writing an interpreter fjh@cs.mu.OZ.AU (1998-03-15)
Re: Techniques for writing an interpreter hgg9140@heckle.ca.boeing.com (1998-03-18)
recursive comments and Re: Techniques for writing an interpreter monnier+comp/compilers/news/@tequila.cs.yale.edu (Stefan Monnier) (1998-03-20)
Re: recursive comments and Re: Techniques for writing an interpreter sestoft@ellemose.dina.kvl.dk (1998-03-20)
Re: recursive comments and Re: Techniques for writing an interpreter monnier+comp/compilers/news/@tequila.cs.yale.edu (Stefan Monnier) (1998-03-20)
Re: recursive comments and Re: Techniques for writing an interpreter bjartem@idi.ntnu.no (Bjarte MayanjaØstvold) (1998-03-24)
Re: recursive comments and Re: Techniques for writing an interpreter pilz@ifi.unizh.ch (1998-03-24)
Re: recursive comments and Re: Techniques for writing an interpreter sethml@ugcs.caltech.edu (1998-03-24)
| List of all articles for this month |

From: sestoft@ellemose.dina.kvl.dk (Peter Sestoft)
Newsgroups: comp.compilers
Date: 20 Mar 1998 11:40:54 -0500
Organization: RVAU
References: 98-03-032 98-03-098 98-03-141 98-03-147 98-03-159 98-03-183
Keywords: syntax, comment

Stefan Monnier <monnier@tequila.cs.yale.edu> writes:


      (1) What languages allow recursive comments ?


Standard ML does:


[1, (* 2 (* 3 *) 4 *) 5]


evaluates to the list [1, 5].


And ["(*", "1", "*)"]


evaluates to the list ["(*", "1", "*)"].


      (2) What languages enforce a "lexing" of the content of comments
      (so that an end-comment inside a string inside a comment is ignored) ?


Standard ML doesn't. Would it be useful? It would prevent you from
writing comments containing otherwise innocent TeX code such as


(* Chalmers, G\"oteborg, Sverige *)


      [C does if you count #if 0 as a comment. -John]


Right on (1) but not on (2) --- as far as I can see.


Peter Sestoft
--
Department of Mathematics and Physics * http://www.dina.kvl.dk/~sestoft/
Royal Veterinary and Agricultural University * Tel +45 3528 2334
Thorvaldsensvej 40, DK-1871 Frederiksberg C, Denmark * Fax +45 3528 2350
[Sure it does. Consider this C source:


#if 0
int first;
/*
#endif
int second;
#if 0
*/
int third;
#endif


C considers this to be completely blank and does not see the
definition of second, since the first endif is inside a
comment. Strings and #if don't interact because #if has to be the
first thing on a line and C doesn't permit multi-line strings. -John]
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.