Miko O'Sullivan wrote:

> OK, would that notation ( @arr[] = $var ) be something that could be added
> by a module, in the same way that operators and /* */ will be addable?  I
> 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);


> but if you can
> say to the preprocessor something like s#/*#=comment#g then perhaps you can
> also say something like s#\[\s*\]\s*=#binpush#g and then also define binpush
> as an operator.

You could rebuild the lexical parser grammar as above (to allow the lamentable 
C<@arr[] = $scalar> syntax), or you could just create a new operator with
something like:

        module BinaryPush;

        my sub operator:<-- is exported (@array is rw, $scalar) {
                push @array, $scalar;
        }

        # and elsewhere...

        use BinaryPush;

        @arr <-- $val;

Damian

Reply via email to