Skip to content

Commit

Permalink
Fix issue 12367 - std.regex: Recognize (?# ... ) comment syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryOlshansky committed Apr 10, 2016
1 parent 401158d commit 12c7d68
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
14 changes: 14 additions & 0 deletions std/regex/internal/parser.d
Expand Up @@ -432,6 +432,20 @@ struct Parser(R)
next();
switch(current)
{
case '#':
nesting--;
fixupStack.pop();
for(;;)
{
if(!next())
error("Unexpected end of pattern");
if(current == ')')
{
next();
break;
}
}
break;
case ':':
put(Bytecode(IR.Nop, 0));
next();
Expand Down
7 changes: 7 additions & 0 deletions std/regex/internal/tests.d
Expand Up @@ -1003,3 +1003,10 @@ unittest
auto rx = regex("[c d]", "x");
assert("a b".matchFirst(rx));
}

unittest
{
auto r = regex("(?# comment)abc(?# comment2)");
assert("abc".matchFirst(r));
assertThrown(regex("(?#..."));
}

0 comments on commit 12c7d68

Please sign in to comment.