Skip to content

Commit 20a37a9

Browse files
committed
Various fixes so we can use native types on QAST::Regex attributes.
1 parent 4c86f84 commit 20a37a9

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/QAST/Compiler.nqp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ class QAST::Compiler is HLL::Compiler {
572572

573573
method regex_post($node) {
574574
return $*PASTCOMPILER.as_post($node) if $node ~~ PAST::Node;
575-
my $rxtype := $node.rxtype() // 'concat';
575+
my $rxtype := $node.rxtype() || 'concat';
576576
self."$rxtype"($node);
577577
}
578578

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

src/QAST/Regex.nqp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ class QAST::Regex is QAST::Node {
66
has int $!min;
77
has int $!max;
88

9-
method rxtype(*@value) { $!rxtype := @value[0] if @value; $!rxtype }
10-
method subtype(*@value) { $!subtype := @value[0] if @value; $!subtype }
11-
method backtrack(*@value) { $!backtrack := @value[0] if @value; $!backtrack }
9+
method rxtype(*@value) { $!rxtype := @value[0] if @value; $!rxtype || "" }
10+
method subtype(*@value) { $!subtype := @value[0] if @value; $!subtype || "" }
11+
method backtrack(*@value) { $!backtrack := @value[0] if @value; $!backtrack || "" }
1212
method negate(*@value) { $!negate := @value[0] if @value; $!negate }
1313
method min(*@value) { $!min := @value[0] if @value; $!min }
1414
method max(*@value) { $!max := @value[0] if @value; $!max }

src/QRegex/P6Regex/Actions.nqp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ class QRegex::P6Regex::Actions is HLL::Actions {
101101
}
102102

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

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

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

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

0 commit comments

Comments
 (0)