Author: pmichaud
Date: Fri Nov 4 06:19:26 2005
New Revision: 9774
Modified:
trunk/compilers/pge/PGE/P6Rule.pir
trunk/t/p6rules/builtins.t
trunk/t/p6rules/text_brk.t
Log:
* Added text-argument parameterized subrules.
* Removed 'todo' designation of <null> test.
* Added parameterized tests for <PGE::Text::bracketed>.
Modified: trunk/compilers/pge/PGE/P6Rule.pir
==============================================================================
--- trunk/compilers/pge/PGE/P6Rule.pir (original)
+++ trunk/compilers/pge/PGE/P6Rule.pir Fri Nov 4 06:19:26 2005
@@ -356,6 +356,8 @@
subrule_name_2:
$I1 = pos - $I0
subname = substr target, $I0, $I1
+ $S0 = substr target, pos, 2
+ if $S0 == ": " goto subrule_text
$S0 = substr target, pos, 1
if $S0 != " " goto subrule_end
inc pos
@@ -368,6 +370,16 @@
pos = $P1.to()
mpos = -1
$S0 = substr target, pos, 1
+ goto subrule_end
+ subrule_text:
+ pos += 2
+ $I0 = index target, ">", pos
+ if $I0 < 0 goto end
+ $I0 -= pos
+ $S0 = substr target, pos, $I0
+ mob["arg"] = $S0
+ pos += $I0
+ $S0 = substr target, pos, 1
subrule_end:
if $S0 != ">" goto end
inc pos
Modified: trunk/t/p6rules/builtins.t
==============================================================================
--- trunk/t/p6rules/builtins.t (original)
+++ trunk/t/p6rules/builtins.t Fri Nov 4 06:19:26 2005
@@ -142,8 +142,7 @@ p6rule_like($str, '<null> $',
p6rule_is ($str, 'abc <null> def', 'null pattern (<null>)');
p6rule_like($str, "abc <null> def",
qr/mob<null>: < @ 58>/, 'null pattern (<null>)');
-p6rule_is ($str, 'x | y | <null>', 'null pattern (<null>)',
- todo => 'specification unclear');
+p6rule_is ($str, 'x | y | <null>', 'null pattern (<null>)');
p6rule_is ($str, 'x | y | <?null>', 'null pattern (<null>)');
Modified: trunk/t/p6rules/text_brk.t
==============================================================================
--- trunk/t/p6rules/text_brk.t (original)
+++ trunk/t/p6rules/text_brk.t Fri Nov 4 06:19:26 2005
@@ -1,4 +1,4 @@
-use Parrot::Test tests => 5;
+use Parrot::Test tests => 12;
use Parrot::Test::PGE;
## First, test direct calls to PGE::Text::bracketed
@@ -62,10 +62,23 @@ OUT
## Now, test calls as subrules
##
-$PTB = "^<PGE::Text::bracketed>\$";
+$PTB = "^<PGE::Text::bracketed>\$";
p6rule_is ("{ nested { and } okay, () and <> pairs okay }", $PTB);
-p6rule_is ("{ nested { and } okay, escaped \\}'s okay }", $PTB);
+p6rule_is ("{ nested { and } okay, () <>, escaped \\}'s okay }", $PTB);
p6rule_isnt("{ unmatched nested { not okay }", $PTB);
p6rule_isnt("{ unmatched nested ( not okay }", $PTB);
+## parameterized with {}
+$PTB = "^<PGE::Text::bracketed: {}>";
+p6rule_is ("{ nested { } okay, unbalanced (, <, escaped \\} okay}", $PTB);
+p6rule_isnt("{ unmatched nested { not okay }", $PTB);
+p6rule_isnt("{ unmatched nested { not okay, nor ( and < }", $PTB);
+
+## parameterized with {}[]" (nested and quoted)
+$PTB = '^<PGE::Text::bracketed: {}[]"`>';
+p6rule_isnt('{ unbalanced nested [ with } and ] not okay', $PTB);
+p6rule_is ('{ balanced nested [ with ] and ( is } okay', $PTB);
+p6rule_is ('{ a quoted "}" unbalanced right bracket} okay', $PTB);
+p6rule_is ('{ quoted "}" unbalanced quotes (`}}}"""}}}}`)} okay', $PTB);
+
# Don't forget to change the number of tests!