Re: Grammars are not Regexps

Steven Pemberton writes:

> So my solution was:
>
> 	comments: (comment, s?)+.
> 	-s: -[" "; #a; #9].
>
>
> 	comment: "(*", content, ")".
> 	-content: (c*, "*"+)+~["*)"].
> 	-c: ~["*"].
>
>
> I consider the interesting bit to be the last "*" in the rule for
> content, which is only there to force the earlier "*"+ to match the
> maximal number of asterisks.

Nice use of a separator!  I had to study the compiled version of this
for several minutes before I saw how it worked: I was unconsciously
misreading the rule for 'content' as if there were a comma after the
first right-parenthesis.

Michael


-- 
C. M. Sperberg-McQueen
Black Mesa Technologies LLC
http://blackmesatech.com

Received on Monday, 7 February 2022 14:40:44 UTC