Skip to content

Commit

Permalink
Various fixes so we can use native types on QAST::Regex attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Jun 25, 2012
1 parent 4c86f84 commit 20a37a9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/QAST/Compiler.nqp
Expand Up @@ -572,7 +572,7 @@ class QAST::Compiler is HLL::Compiler {

method regex_post($node) {
return $*PASTCOMPILER.as_post($node) if $node ~~ PAST::Node;
my $rxtype := $node.rxtype() // 'concat';
my $rxtype := $node.rxtype() || 'concat';
self."$rxtype"($node);
}

Expand Down Expand Up @@ -827,8 +827,8 @@ class QAST::Compiler is HLL::Compiler {
my $prefix := self.unique('rxquant' ~ $backtrack);
my $looplabel := self.post_new('Label', :result($prefix ~ '_loop'));
my $donelabel := self.post_new('Label', :result($prefix ~ '_done'));
my $min := $node.min || 0;
my $max := $node.max // -1;
my $min := $node.min;
my $max := $node.max;
my $needrep := $min > 1 || $max > 1;
my $needmark := $needrep || $backtrack eq 'r';

Expand Down
6 changes: 3 additions & 3 deletions src/QAST/Regex.nqp
Expand Up @@ -6,9 +6,9 @@ class QAST::Regex is QAST::Node {
has int $!min;
has int $!max;

method rxtype(*@value) { $!rxtype := @value[0] if @value; $!rxtype }
method subtype(*@value) { $!subtype := @value[0] if @value; $!subtype }
method backtrack(*@value) { $!backtrack := @value[0] if @value; $!backtrack }
method rxtype(*@value) { $!rxtype := @value[0] if @value; $!rxtype || "" }
method subtype(*@value) { $!subtype := @value[0] if @value; $!subtype || "" }
method backtrack(*@value) { $!backtrack := @value[0] if @value; $!backtrack || "" }
method negate(*@value) { $!negate := @value[0] if @value; $!negate }
method min(*@value) { $!min := @value[0] if @value; $!min }
method max(*@value) { $!max := @value[0] if @value; $!max }
Expand Down
6 changes: 3 additions & 3 deletions src/QRegex/P6Regex/Actions.nqp
Expand Up @@ -101,12 +101,12 @@ class QRegex::P6Regex::Actions is HLL::Actions {
}

method quantifier:sym<*>($/) {
my $qast := QAST::Regex.new( :rxtype<quant>, :node($/) );
my $qast := QAST::Regex.new( :rxtype<quant>, :min(0), :max(-1), :node($/) );
make backmod($qast, $<backmod>);
}

method quantifier:sym<+>($/) {
my $qast := QAST::Regex.new( :rxtype<quant>, :min(1), :node($/) );
my $qast := QAST::Regex.new( :rxtype<quant>, :min(1), :max(-1), :node($/) );
make backmod($qast, $<backmod>);
}

Expand All @@ -117,7 +117,7 @@ class QRegex::P6Regex::Actions is HLL::Actions {

method quantifier:sym<**>($/) {
my $qast;
$qast := QAST::Regex.new( :rxtype<quant>, :min(+$<min>), :node($/) );
$qast := QAST::Regex.new( :rxtype<quant>, :min(+$<min>), :max(-1), :node($/) );
if ! $<max> { $qast.max(+$<min>) }
elsif $<max>[0] ne '*' { $qast.max(+$<max>[0]); }
make backmod($qast, $<backmod>);
Expand Down

0 comments on commit 20a37a9

Please sign in to comment.