Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
make the NFA work with () captures
  • Loading branch information
diakopter committed Nov 18, 2011
1 parent ec2f2a8 commit 9dd7eab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/QRegex/NFA.nqp
Expand Up @@ -44,7 +44,6 @@ class QRegex::NFA {

method regex_nfa($node, $from, $to) {
my $method := ($node.rxtype // 'concat');
nqp::say("got method $method");
self.HOW.can(self, $method)
?? self."$method"($node, $from, $to)
!! self.fate($node, $from, $to);
Expand Down Expand Up @@ -124,7 +123,9 @@ class QRegex::NFA {
?? ($node.negate
?? self.fate($node, $from, $to)
!! self.addedge($from, 0, $EDGE_SUBRULE, $node.name))
!! self.addedge($from, $to, $EDGE_SUBRULE, $node[0][0]);
!! $subtype eq 'capture' && $node[1]
?? self.regex_nfa($node[1], $from, $to)
!! self.addedge($from, $to, $EDGE_SUBRULE, $node[0][0]);
}

method quant($node, $from, $to) {
Expand Down
2 changes: 1 addition & 1 deletion src/QRegex/P6Regex/Actions.nqp
Expand Up @@ -121,7 +121,7 @@ class QRegex::P6Regex::Actions is HLL::Actions {

method metachar:sym<( )>($/) {
my $subpast := PAST::Node.new(buildsub($<nibbler>.ast));
my $qast := QAST::Regex.new( $subpast, :rxtype('subrule'),
my $qast := QAST::Regex.new( $subpast, $<nibbler>.ast, :rxtype('subrule'),
:subtype('capture'), :node($/) );
make $qast;
}
Expand Down

0 comments on commit 9dd7eab

Please sign in to comment.