On Sat, 3 Aug 2002, Damian Conway wrote:
> > don't know exactly what the syntax for adding /* */ will be
>
> Something like this:
>
> grammar Perl::With::Ugly::C::Comments is Perl {
>
> rule ws { <Perl::ws> | <ugly_c_comment> }
>
> rule ugly_c_comment {
> /\* [ .*? <ugly_c_comment>? ]*? \*/
> { let $0 := " " }
> }
> }
>
> caller{MY}.parser(Perl::With::Ugly::C::Comments);
I'm still having trouble getting my head around the new
grammar-construction rules. Three questions:
1) Am I right that anything inside a "rule" block is considered to be
inside a regex? If not, why didn't you have to write:
rule ugly_c_comment {
/
\/ \* [ .*? <ugly_c_comment>? ]*? \* \/
{ let $0 := " " }
/
}
2) As written, I believe that the ugly_c_comment rule would permit nested
comments (that is, /* /**/ */), but would break if the comments were
improperly nested (e.g., /* /* */). Is that correct?
3) The rule will replace the comment with a single, literal space. Why is
this replacement necessary...isn't it sufficient to simply define it as
whitespace, as was done above?
Dave Storrs