[antlr-interest] Lexing nested comments

Jim Idle jimi at temporal-wave.com
Wed Feb 10 12:27:52 PST 2010



> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Michael Siff
> Sent: Wednesday, February 10, 2010 12:25 PM
> To: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Lexing nested comments
> 
> Jim, first of all, thank you very much for the prompt reply. What you
> sent seems to do the trick quite nicely. I had tried listing BOOL
> first,
> but, for whatever reason, NESTED still seems to take precedence.
> 
> You are right, the source language in question is not something I would
> recommend programming in. What I sent was a simplification of a
> pedagogical language I have designed call php-- that is essentially a
> subset (and much less powerful subset at that) of PHP. The idea is to
> add explicit types to an implicitly typed language and still let the
> explicitly typed version sneak through the original language's parser
> (so to have the new language remain essentially a subset). This way
> students can try out simple php-- programs using command-line php. (The
> same idea can be applied to most any language that has multiline
> comments.) Of course, the nested comment ability is not strictly
> necessary - but as a pedagogical language it demonstrates to
> introductory compilers students some of the lexical-analysis challenges
> that compiler writers have historically faced.

Ah OK - I see the point of it now :-)

Jim





More information about the antlr-interest mailing list