Added Anchor() regex (so that we're not just using Alphanumeric to match anchors), but it's still not 100% right (it shouldn't allow non-printable characters, e.g.). Also fixed a test that was broken along these lines (if a colon immediately follows an anchor, it's part of the anchor)

This commit is contained in:
jbeder
2011-01-31 17:47:20 +00:00
parent 7fd040c311
commit 9e345650e1
3 changed files with 6 additions and 2 deletions

View File

@@ -112,6 +112,10 @@ namespace YAML
static const RegEx e = RegEx('#');
return e;
}
inline const RegEx& Anchor() {
static const RegEx e = !(RegEx("[]{},", REGEX_OR) || BlankOrBreak());
return e;
}
inline const RegEx& AnchorEnd() {
static const RegEx e = RegEx("?:,]}%@`", REGEX_OR) || BlankOrBreak();
return e;

View File

@@ -238,7 +238,7 @@ namespace YAML
alias = (indicator == Keys::Alias);
// now eat the content
while(Exp::AlphaNumeric().Matches(INPUT))
while(INPUT && Exp::Anchor().Matches(INPUT))
name += INPUT.get();
// we need to have read SOMETHING!

View File

@@ -472,7 +472,7 @@ namespace Test
bool AliasAsSimpleKey()
{
std::string input = "- &a b\n- *a: c";
std::string input = "- &a b\n- *a : c";
std::stringstream stream(input);
YAML::Parser parser(stream);