[svn] r6228: nemerle/trunk: macros/text.n
ncc/testsuite/positive/matching.n
malekith
svnadmin at nemerle.org
Fri May 5 13:35:40 CEST 2006
Log:
Apply patch from Tobias to fix optional value typing in regexps. Resolves #617.
Author: malekith
Date: Fri May 5 13:35:39 2006
New Revision: 6228
Modified:
nemerle/trunk/macros/text.n
nemerle/trunk/ncc/testsuite/positive/matching.n
Modified: nemerle/trunk/macros/text.n
==============================================================================
--- nemerle/trunk/macros/text.n (original)
+++ nemerle/trunk/macros/text.n Fri May 5 13:35:39 2006
@@ -106,13 +106,13 @@
// check if this group is optional (it's context information)
// so we must count [(] and [)]
- for (mutable i = m.Index; !end && i < str.Length; ++i)
+ def stack = Stack();
+ for (mutable i = 0; !end && i < str.Length; ++i)
{
match (str[i]) {
- | '(' => paren = paren + 1
+ | '(' => stack.Push(i <= m.Index)
| ')' =>
- paren = paren - 1;
- when (paren == 0 && i + 1 < str.Length && str[i + 1] == '?') {
+ when(stack.Pop() && i > m.Index && i + 1 < str.Length && str[i + 1] == '?') {
end = true;
optional = true;
}
Modified: nemerle/trunk/ncc/testsuite/positive/matching.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/matching.n (original)
+++ nemerle/trunk/ncc/testsuite/positive/matching.n Fri May 5 13:35:39 2006
@@ -1,6 +1,6 @@
-
using Nemerle.Collections;
using Nemerle.IO;
+using Nemerle.Text;
module M1
{
@@ -1475,6 +1475,15 @@
| _ => 17
}
+
+ // bug 617
+ def res =
+ regexp match("10va") {
+ | @"(?<a : int>\d+)(va)?" => a : int
+ | _ => -1
+ }
+ assert (res == 10);
+
}
}
More information about the svn
mailing list