On Sunday 30 June 2002 12:46 pm, Dan Sugalski wrote:
> So, it's been a week or so and, while I'm mostly offline until
> wednesday, I'll ask the question...
>
> How's the work on the perl 6 grammar going? We any further along than
> we were before YAPC?

I don't know how the grammars are going, and I'm not fit to write one myself, 
but I wrote a list of variables I'll try to parse using any grammars which go 
by. Are all of these legal? I suppose that's more of a -language question.

Ashley Winters

# Variable access you will want to parse

# standard variables
$foo;
@foo;
%foo;
&foo;

# need more tests for ${}, I'm not evil enough for it
${foo};

# Apocalypse 3 specifies context characters
*@foo;
$@foo;
&@foo;
*%foo;
*@{foo};    # sanity check

# Also, there are globals to consider
$*foo;
@*foo;
%*foo;
&*foo;
$*{foo};
*@*foo;
$@*foo;
&@*foo;
*%*foo;

# not to mention members
$.foo;
@.foo;
%.foo;
&.foo;
$.{foo};
*@.foo;
$@.foo;
&@.foo;
*%.foo;


# lets test packages at least once
$foo::bar;
@foo::bar::baz;
%foo::bar::baz::blurfl;
&foo::bar::baz::blurfl::aybabtu;

# Now, the hard part. Element access
$foo{1};
$foo[1];
$foo(1);
$foo();
$foo.{1};
$foo.[1];
$foo.(1);
$foo.();

# off the subject, but lets make sure $foo.. is parsed correctly
$foo..1;
$foo..[1];
$.foo..{1};
$foo..(1);
$foo..<$*STDIN>;    # perfectly legal
$foo...bar;         # $foo .. .bar, since there's no binary ...

@foo{1};      # I ass_u_me {} [] and () can be overloaded?
@foo[1];
@foo(1);
@foo();
@.foo{1};
@.foo[1];
@.foo(1);
@.foo();
@foo.{1};
@foo.[1];
@foo.(1);
@foo.();
@.foo.{1};
@.foo.[1];
@.foo.(1);
@.foo.();

# I will just assume if the parser made it this far, <[%$&]> also work

foo{1};         # foo is unary here
foo[1];
foo();
foo.{1};
foo.[1];
foo.();         # Is this &{ foo() }() or foo()? I would vote former
.foo{1};
.foo[1];
.foo();
.foo.{1};
.foo.[1];
.foo.();

# As a final sanity check, lets chain these things

@.proc[$*PID].ps.{RSS};
@proc.[$*PID].ps().{RSS};

# And, just to make sure your parser doesn't pass this suite...

$foo{"Do you want to try $interpolated{"string"}?"};

# Okay, I've had my fun

Reply via email to