Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Update P6Grammar to attach names to regexes, set modifiers for
token/rule.
  • Loading branch information
pmichaud committed Oct 15, 2009
1 parent 0c574ea commit 672674d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/Regex/P6Grammar/Actions.pm
Expand Up @@ -9,9 +9,27 @@ method TOP($/) {
}


method regex_stmt($/) {
method regex_stmt($/, $key?) {
my @MODIFIERS := Q:PIR {
%r = get_hll_global ['Regex';'P6Regex';'Actions'], '@MODIFIERS'
};
if $key eq 'open' {
my %h;
if $<sym> eq 'token' { %h<r> := 1; }
if $<sym> eq 'rule' { %h<r> := 1; %h<s> := 1; }
@MODIFIERS.unshift(%h);
return 0;
}
my $rpast := $<nibbler>.ast;
my $past := PAST::Block.new( $rpast, :name(~$<longname>),
:blocktype('method') );
my %capnames := Regex::P6Regex::Actions::capnames($rpast, 0);
%capnames{''} := 0;
$rpast := PAST::Regex.new(
$rpast,
PAST::Regex.new( :pasttype('pass') ),
:pasttype('concat'),
:capnames(%capnames)
);
my $past := PAST::Block.new( $rpast, :name(~$<longname>), :blocktype('method') );
@MODIFIERS.shift;
make $past;
}
1 change: 1 addition & 0 deletions src/Regex/P6Grammar/Grammar.pm
Expand Up @@ -21,6 +21,7 @@ grammar Regex::P6Grammar::Grammar is Regex::P6Regex::Grammar;
rule regex_stmt {
$<sym>=[regex|token|rule]
<longname>
{*} #= open
'{' <nibbler> '}'
{*}
}
Expand Down

0 comments on commit 672674d

Please sign in to comment.