Author: pmichaud
Date: Thu Nov 3 23:54:14 2005
New Revision: 9770
Modified:
trunk/compilers/pge/PGE/Exp.pir
trunk/compilers/pge/PGE/P6Rule.pir
trunk/t/p6rules/backtrack.t
Log:
* Added simple version of <commit>
Modified: trunk/compilers/pge/PGE/Exp.pir
==============================================================================
--- trunk/compilers/pge/PGE/Exp.pir (original)
+++ trunk/compilers/pge/PGE/Exp.pir Thu Nov 3 23:54:14 2005
@@ -28,6 +28,7 @@
$P1 = subclass $P0, "PGE::Exp::Quant"
$P1 = subclass $P0, "PGE::Exp::Modifier"
$P1 = subclass $P0, "PGE::Exp::Closure"
+ $P1 = subclass $P0, "PGE::Exp::Commit"
$P0 = new Integer
store_global "PGE::Exp", "$_serno", $P0
.end
@@ -1043,3 +1044,17 @@ register.
.return ()
.end
+.namespace [ "PGE::Exp::Commit" ]
+
+.sub "gen" :method
+ .param pmc code
+ .param string label
+ .param string next
+ .local pmc emit
+ emit = find_global "PGE::Exp", "emit"
+ emit(code, " %s: # commit ##", label)
+ emit(code, " bsr %s", next)
+ emit(code, " cutting = %s", PGE_CUT_MATCH)
+ emit(code, " goto fail")
+ .return ()
+.end
Modified: trunk/compilers/pge/PGE/P6Rule.pir
==============================================================================
--- trunk/compilers/pge/PGE/P6Rule.pir (original)
+++ trunk/compilers/pge/PGE/P6Rule.pir Thu Nov 3 23:54:14 2005
@@ -39,6 +39,8 @@
optable.addtok("circumfix:[ ]", "term:", "nows", "PGE::Exp::Group")
optable.addtok("circumfix:( )", "term:", "nows", "PGE::Exp::Group")
+ optable.addtok("<commit>", "term:", "nows", "PGE::Exp::Commit")
+
$P0 = find_global "PGE::P6Rule", "parse_subrule"
optable.addtok("term:<", "term:", "nows", $P0)
optable.addtok("term:<?", "term:", "nows", $P0)
Modified: trunk/t/p6rules/backtrack.t
==============================================================================
--- trunk/t/p6rules/backtrack.t (original)
+++ trunk/t/p6rules/backtrack.t Thu Nov 3 23:54:14 2005
@@ -36,9 +36,15 @@ p6rule_is ('xyabghij', '[ab::cd | gh::i
p6rule_isnt('xyabghij', '[ab:::cd | gh:::ij]', 'rule cut in group');
-## <commit> -- cut over entire rule
-p6rule_isnt('whence', '[ when <commit> ever ] | whence', 'full backtrack
failure', todo => 'not yet implemented');
-
+## <commit> -- cut over entire match
+p6rule_isnt('whence', '[ when <commit> ever ] | whence', 'full backtrack
failure');
+p6rule_isnt('whence',
+ [
+ [ subrule => 'when <commit> ever' ],
+ [ _MASTER => '<subrule> | whence' ],
+ ],
+ "<commit> in nested subrule");
+
# remember to change the number of tests :-)
-BEGIN { plan tests => 16; }
+BEGIN { plan tests => 17; }