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

Commit

Permalink
Add special handling of <sym>.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Oct 23, 2009
1 parent d6f5066 commit fbaf420
Show file tree
Hide file tree
Showing 4 changed files with 2,859 additions and 2,766 deletions.
6 changes: 5 additions & 1 deletion src/Regex/P6Grammar/Actions.pm
Expand Up @@ -31,14 +31,18 @@ method regex_stmt($/, $key?) {
my @MODIFIERS := Q:PIR {
%r = get_hll_global ['Regex';'P6Regex';'Actions'], '@MODIFIERS'
};
my $name := ~$<longname>;
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);
Q:PIR {
$P0 = find_lex '$name'
set_hll_global ['Regex';'P6Regex';'Actions'], '$REGEXNAME', $P0
};
return 0;
}
my $name := ~$<longname>;
my $past;
if $<proto> {
$past :=
Expand Down
15 changes: 15 additions & 0 deletions src/Regex/P6Regex/Actions.pm
Expand Up @@ -322,6 +322,21 @@ method assertion:sym<name>($/) {
$past := $<assertion>[0].ast;
subrule_alias($past, $name);
}
elsif $name eq 'sym' {
my $regexsym := Q:PIR {
$P0 = get_global '$REGEXNAME'
$S0 = $P0
$I0 = index $S0, ':sym<'
add $I0, 5
$S0 = substr $S0, $I0
chopn $S0, 1
%r = box $S0
};
$past := PAST::Regex.new(
PAST::Regex.new( $regexsym, :pasttype('literal') ),
:name($name), :pasttype('subcapture'), :node($/)
);
}
else {
$past := PAST::Regex.new( $name, :name($name),
:pasttype('subrule'), :subtype('capture'), :node($/) );
Expand Down

0 comments on commit fbaf420

Please sign in to comment.