Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
A :my declaration in a regex prevents the current protoregex implemen…
…tation spotting constant prefixes that immediately follow it. By a little re-ordering, we can shave about 5% off the time to compile the setting by allowing those constant prefixes to be spotted and computed, since we don't have to chase down a bunch of false branches.
  • Loading branch information
jnthn committed Apr 4, 2010
1 parent 1094cf3 commit 32fda13
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/Perl6/Grammar.pm
Expand Up @@ -558,24 +558,24 @@ token twigil:sym<?> { <sym> }

proto token package_declarator { <...> }
token package_declarator:sym<package> {
:my $*PKGDECL := 'package';
<sym> <package_def>
<sym> :my $*PKGDECL := 'package';
<package_def>
}
token package_declarator:sym<module> {
:my $*PKGDECL := 'module';
<sym> <package_def>
<sym> :my $*PKGDECL := 'module';
<package_def>
}
token package_declarator:sym<class> {
:my $*PKGDECL := 'class';
<sym> <package_def>
<sym> :my $*PKGDECL := 'class';
<package_def>
}
token package_declarator:sym<grammar> {
:my $*PKGDECL := 'grammar';
<sym> <package_def>
<sym> :my $*PKGDECL := 'grammar';
<package_def>
}
token package_declarator:sym<role> {
:my $*PKGDECL := 'role';
<sym> <package_def>
<sym> :my $*PKGDECL := 'role';
<package_def>
}

token package_declarator:sym<does> {
Expand Down Expand Up @@ -611,16 +611,16 @@ token declarator {

proto token multi_declarator { <...> }
token multi_declarator:sym<multi> {
:my $*MULTINESS := 'multi';
<sym> <.ws> [ <declarator> || <routine_def> || <.panic: 'Malformed multi'> ]
<sym> :my $*MULTINESS := 'multi';
<.ws> [ <declarator> || <routine_def> || <.panic: 'Malformed multi'> ]
}
token multi_declarator:sym<proto> {
:my $*MULTINESS := 'proto';
<sym> <.ws> [ <declarator> || <routine_def> || <.panic: 'Malformed proto'> ]
<sym> :my $*MULTINESS := 'proto';
<.ws> [ <declarator> || <routine_def> || <.panic: 'Malformed proto'> ]
}
token multi_declarator:sym<only> {
:my $*MULTINESS := 'only';
<sym> <.ws> [ <declarator> || <routine_def> || <.panic: 'Malformed only'> ]
<sym> :my $*MULTINESS := 'only';
<.ws> [ <declarator> || <routine_def> || <.panic: 'Malformed only'> ]
}
token multi_declarator:sym<null> {
:my $*MULTINESS := '';
Expand Down Expand Up @@ -885,8 +885,8 @@ token type_declarator:sym<enum> {
}

token type_declarator:sym<subset> {
:my $*IN_DECL := 'subset';
<sym> :s
<sym> :my $*IN_DECL := 'subset';
:s
[
[
[ <longname> { $/.CURSOR.add_name($<longname>[0].Str); } ]?
Expand Down

0 comments on commit 32fda13

Please sign in to comment.