mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Switched from moving the cursor forward (in Regex) to ignoring (this handles newlines properly).
Updated some of the character-in-scalar rules.
This commit is contained in:
9
exp.h
9
exp.h
@@ -29,7 +29,7 @@ namespace YAML
|
|||||||
const RegEx BlockEntry = RegEx('-') + (BlankOrBreak || RegEx(EOF));
|
const RegEx BlockEntry = RegEx('-') + (BlankOrBreak || RegEx(EOF));
|
||||||
const RegEx Key = RegEx('?'),
|
const RegEx Key = RegEx('?'),
|
||||||
KeyInFlow = RegEx('?') + BlankOrBreak;
|
KeyInFlow = RegEx('?') + BlankOrBreak;
|
||||||
const RegEx Value = RegEx(':'),
|
const RegEx Value = RegEx(':') + BlankOrBreak,
|
||||||
ValueInFlow = RegEx(':') + BlankOrBreak;
|
ValueInFlow = RegEx(':') + BlankOrBreak;
|
||||||
const RegEx Comment = RegEx('#');
|
const RegEx Comment = RegEx('#');
|
||||||
const RegEx AnchorEnd = RegEx("?:,]}%@`", REGEX_OR) || BlankOrBreak;
|
const RegEx AnchorEnd = RegEx("?:,]}%@`", REGEX_OR) || BlankOrBreak;
|
||||||
@@ -38,12 +38,11 @@ namespace YAML
|
|||||||
// . Cannot start with a blank.
|
// . Cannot start with a blank.
|
||||||
// . Can never start with any of , [ ] { } # & * ! | > \' \" % @ `
|
// . Can never start with any of , [ ] { } # & * ! | > \' \" % @ `
|
||||||
// . In the block context - ? : must be not be followed with a space.
|
// . In the block context - ? : must be not be followed with a space.
|
||||||
// . In the flow context ? : are illegal and - must not be followed with a space.
|
// . In the flow context ? is illegal and : and - must not be followed with a space.
|
||||||
const RegEx PlainScalar = !(BlankOrBreak || RegEx(",[]{}#&*!|>\'\"%@`", REGEX_OR) || (RegEx("-?:", REGEX_OR) + Blank)),
|
const RegEx PlainScalar = !(BlankOrBreak || RegEx(",[]{}#&*!|>\'\"%@`", REGEX_OR) || (RegEx("-?:", REGEX_OR) + Blank)),
|
||||||
PlainScalarInFlow = !(BlankOrBreak || RegEx("?:,[]{}#&*!|>\'\"%@`", REGEX_OR) || (RegEx('-') + Blank));
|
PlainScalarInFlow = !(BlankOrBreak || RegEx("?,[]{}#&*!|>\'\"%@`", REGEX_OR) || (RegEx("-:", REGEX_OR) + Blank));
|
||||||
const RegEx IllegalColonInScalar = RegEx(':') + !BlankOrBreak;
|
|
||||||
const RegEx EndScalar = RegEx(':') + BlankOrBreak,
|
const RegEx EndScalar = RegEx(':') + BlankOrBreak,
|
||||||
EndScalarInFlow = (RegEx(':') + BlankOrBreak) || RegEx(",:?[]{}", REGEX_OR);
|
EndScalarInFlow = (RegEx(':') + BlankOrBreak) || RegEx(",?[]{}", REGEX_OR);
|
||||||
|
|
||||||
const RegEx EscSingleQuote = RegEx("\'\'");
|
const RegEx EscSingleQuote = RegEx("\'\'");
|
||||||
const RegEx EscBreak = RegEx('\\') + Break;
|
const RegEx EscBreak = RegEx('\\') + Break;
|
||||||
|
@@ -283,7 +283,7 @@ namespace YAML
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
offset += n;
|
offset += n;
|
||||||
in.seekg(n, std::ios_base::cur);
|
in.ignore(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
return offset;
|
return offset;
|
||||||
|
@@ -274,7 +274,7 @@ namespace YAML
|
|||||||
|
|
||||||
// set up the scanning parameters
|
// set up the scanning parameters
|
||||||
ScanScalarParams params;
|
ScanScalarParams params;
|
||||||
params.end = (m_flowLevel > 0 ? Exp::EndScalarInFlow : Exp::EndScalar) || (RegEx(' ') + Exp::Comment);
|
params.end = (m_flowLevel > 0 ? Exp::EndScalarInFlow : Exp::EndScalar) || (Exp::BlankOrBreak + Exp::Comment);
|
||||||
params.eatEnd = false;
|
params.eatEnd = false;
|
||||||
params.indent = (m_flowLevel > 0 ? 0 : m_indents.top() + 1);
|
params.indent = (m_flowLevel > 0 ? 0 : m_indents.top() + 1);
|
||||||
params.fold = true;
|
params.fold = true;
|
||||||
@@ -294,10 +294,9 @@ namespace YAML
|
|||||||
// can have a simple key only if we ended the scalar by starting a new line
|
// can have a simple key only if we ended the scalar by starting a new line
|
||||||
m_simpleKeyAllowed = params.leadingSpaces;
|
m_simpleKeyAllowed = params.leadingSpaces;
|
||||||
|
|
||||||
// finally, we can't have any colons in a scalar, so if we ended on a colon, there
|
// finally, check and see if we ended on an illegal character
|
||||||
// had better be a break after it
|
//if(Exp::IllegalCharInScalar.Matches(INPUT))
|
||||||
if(Exp::IllegalColonInScalar.Matches(INPUT))
|
// throw ParserException(INPUT.line, INPUT.column, ErrorMsg::CHAR_IN_SCALAR);
|
||||||
throw ParserException(INPUT.line, INPUT.column, ErrorMsg::CHAR_IN_SCALAR);
|
|
||||||
|
|
||||||
Token *pToken = new Token(TT_SCALAR, line, column);
|
Token *pToken = new Token(TT_SCALAR, line, column);
|
||||||
pToken->value = scalar;
|
pToken->value = scalar;
|
||||||
|
@@ -21,4 +21,15 @@
|
|||||||
that gets chomped.
|
that gets chomped.
|
||||||
- >2
|
- >2
|
||||||
Here's a folded scalar
|
Here's a folded scalar
|
||||||
that starts with some indentation.
|
that starts with some indentation.
|
||||||
|
- ::vector
|
||||||
|
- ": - ()"
|
||||||
|
- Up, up, and away!
|
||||||
|
- -123
|
||||||
|
- http://example.com/foo#bar
|
||||||
|
# Inside flow collection:
|
||||||
|
- [ ::vector,
|
||||||
|
": - ()",
|
||||||
|
"Up, up and away!",
|
||||||
|
-123,
|
||||||
|
http://example.com/foo#bar ]
|
Reference in New Issue
Block a user