Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Switch :$*endsym to a trait
  • Loading branch information
sorear committed May 13, 2011
1 parent 6e81878 commit a71faea
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
24 changes: 12 additions & 12 deletions STD.pm6
Expand Up @@ -167,7 +167,7 @@ token category:sigil { <sym> }
proto token sigil {*}

token category:twigil { <sym> }
proto token twigil (:$*endsym = 'begid') {*}
proto token twigil is endsym<begid> {*}

token category:special_variable { <sym> }
proto token special_variable {*}
Expand Down Expand Up @@ -203,7 +203,7 @@ token category:postfix { <sym> }
proto token postfix is unary is defequiv(%autoincrement) {*}

token category:dotty { <sym> }
proto token dotty (:$*endsym = 'unspacey') {*}
proto token dotty is endsym<unspacey> {*}

token category:circumfix { <sym> }
proto token circumfix {*}
Expand All @@ -215,37 +215,37 @@ token category:quote_mod { <sym> }
proto token quote_mod {*}

token category:trait_mod { <sym> }
proto token trait_mod (:$*endsym = 'keyspace') {*}
proto token trait_mod is endsym<keyspace> {*}

token category:type_declarator { <sym> }
proto token type_declarator (:$*endsym = 'keyspace') {*}
proto token type_declarator is endsym<keyspace> {*}

token category:scope_declarator { <sym> }
proto token scope_declarator (:$*endsym = 'nofun') {*}
proto token scope_declarator is endsym<nofun> {*}

token category:package_declarator { <sym> }
proto token package_declarator (:$*endsym = 'keyspace') {*}
proto token package_declarator is endsym<keyspace> {*}

token category:multi_declarator { <sym> }
proto token multi_declarator (:$*endsym = 'keyspace') {*}
proto token multi_declarator is endsym<keyspace> {*}

token category:routine_declarator { <sym> }
proto token routine_declarator (:$*endsym = 'nofun') {*}
proto token routine_declarator is endsym<nofun> {*}

token category:regex_declarator { <sym> }
proto token regex_declarator (:$*endsym = 'keyspace') {*}
proto token regex_declarator is endsym<keyspace> {*}

token category:statement_prefix { <sym> }
proto rule statement_prefix () {*}

token category:statement_control { <sym> }
proto rule statement_control (:$*endsym = 'keyspace') {*}
proto rule statement_control is endsym<keyspace> {*}

token category:statement_mod_cond { <sym> }
proto rule statement_mod_cond (:$*endsym = 'nofun') {*}
proto rule statement_mod_cond is endsym<nofun> {*}

token category:statement_mod_loop { <sym> }
proto rule statement_mod_loop (:$*endsym = 'nofun') {*}
proto rule statement_mod_loop is endsym<nofun> {*}

token category:infix_prefix_meta_operator { <sym> }
proto token infix_prefix_meta_operator is binary {*}
Expand Down
15 changes: 10 additions & 5 deletions viv
Expand Up @@ -64,7 +64,7 @@ my @did_ws;
my @context;
$::MULTINESS = '';
# XXX STD Global trait tables simulate inheritance
local $::PROTO = {};
local $::PROTOENDSYM = {};
local $::PROTOSIG = {};

BEGIN {
Expand Down Expand Up @@ -2077,8 +2077,14 @@ TEXT
re => $self->{regex_block}{nibble}{"."}->re_ast);
}
sub protoregex { my $self = shift; my $name = shift;
$::PROTO->{$name} = 1;
$::RETREE->{$name . ":*"} = { dic => $::PKG };
for my $t ($self->kids("trait")) {
if ($t->{trait_mod}{longname} &&
$t->{trait_mod}{longname}->Str eq 'endsym') {
$::PROTOENDSYM->{$name} =
$t->{trait_mod}{circumfix}[0]{nibble}->Str;
}
}
$::PROTOSIG->{$name} = ($self->kids("signature"))[0];
<<EOT;
sub ${name}__PEEK { \$_[0]->_AUTOLEXpeek('$name:*',\$retree); }
Expand Down Expand Up @@ -2146,7 +2152,7 @@ EOT
my $p5name = $name;
my %adv = $self->{deflongname}[0]->adverbs;
local $::SYM = $adv{sym};
local $::ENDSYM;
local $::ENDSYM = $::PROTOENDSYM->{$name};
local $::REV = '';
local $::PLURALITY = 1;
local @::DECL;
Expand All @@ -2158,8 +2164,7 @@ EOT

my $spcsig = $self->kids('signature') ?
(($self->kids('signature'))[0])->p5 : '';
my $defsig = $::PROTO && $::PROTOSIG->{$name}
? $::PROTOSIG->{$name}->p5 : '';
my $defsig = $::PROTOSIG->{$name} ? $::PROTOSIG->{$name}->p5 : '';
if (defined $adv{sym}) {
$p5name = sprintf "%s__S_%03d%s", $name, $::MULTIRX_SEQUENCE++,
::mangle(split " ", $adv{sym});
Expand Down

0 comments on commit a71faea

Please sign in to comment.