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

Commit

Permalink
Add parsing for &&.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Aug 20, 2010
1 parent a56f707 commit 8788740
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/Regex/P6Regex/Actions.pm
Expand Up @@ -37,8 +37,22 @@ method nibbler($/, $key?) {

@MODIFIERS.shift;
my $past;
if +$<termish> > 1 {
if +$<termconj> > 1 {
$past := PAST::Regex.new( :pasttype('alt'), :node($/) );
for $<termconj> {
$past.push($_.ast);
}
}
else {
$past := $<termconj>[0].ast;
}
make $past;
}

method termconj($/) {
my $past;
if +$<termish> > 1 {
$past := PAST::Regex.new( :pasttype('conj'), :node($/) );
for $<termish> {
$past.push($_.ast);
}
Expand Down
9 changes: 8 additions & 1 deletion src/Regex/P6Regex/Grammar.pm
Expand Up @@ -29,8 +29,15 @@ grammar Regex::P6Regex::Grammar is HLL::Grammar;
token nibbler {
{*} #= open
[ <.ws> ['||'|'|'|'&&'|'&'] ]?
<termish>
<termconj>
[ ['||'|'|']
[ <termconj> || <.panic: 'Null pattern not allowed'> ]
]*
}

token termconj {
<termish>
[ ['&&'|'&']
[ <termish> || <.panic: 'Null pattern not allowed'> ]
]*
}
Expand Down

0 comments on commit 8788740

Please sign in to comment.