Added directives and tags.

This commit is contained in:
Jesse Beder 2008-06-30 04:22:41 +00:00
parent 2b8628922f
commit 07d4cac48f
6 changed files with 120 additions and 159 deletions

View file

@ -35,6 +35,44 @@ namespace YAML
return pToken;
}
// DirectiveToken
// . Note: no semantic checking is done here (that's for the parser to do)
template <> DirectiveToken *Scanner::ScanToken(DirectiveToken *pToken)
{
// pop indents and simple keys
PopIndentTo(-1);
VerifyAllSimpleKeys();
m_simpleKeyAllowed = false;
// eat indicator
INPUT.Eat(1);
// read name
while(INPUT.peek() != EOF && !Exp::BlankOrBreak.Matches(INPUT))
pToken->name += INPUT.GetChar();
// read parameters
while(1) {
// first get rid of whitespace
while(Exp::Blank.Matches(INPUT))
INPUT.Eat(1);
// break on newline or comment
if(INPUT.peek() == EOF || Exp::Break.Matches(INPUT) || Exp::Comment.Matches(INPUT))
break;
// now read parameter
std::string param;
while(INPUT.peek() != EOF && !Exp::BlankOrBreak.Matches(INPUT))
param += INPUT.GetChar();
pToken->params.push_back(param);
}
return pToken;
}
// DocumentStartToken
template <> DocumentStartToken *Scanner::ScanToken(DocumentStartToken *pToken)
{
@ -222,6 +260,34 @@ namespace YAML
return pToken;
}
// TagToken
template <> TagToken *Scanner::ScanToken(TagToken *pToken)
{
// insert a potential simple key
if(m_simpleKeyAllowed)
InsertSimpleKey();
m_simpleKeyAllowed = false;
// eat the indicator
INPUT.Eat(1);
// read the handle
while(INPUT.peek() != EOF && INPUT.peek() != Keys::Tag && !Exp::BlankOrBreak.Matches(INPUT))
pToken->handle += INPUT.GetChar();
// is there a suffix?
if(INPUT.peek() == Keys::Tag) {
// eat the indicator
INPUT.Eat(1);
// then read it
while(INPUT.peek() != EOF && !Exp::BlankOrBreak.Matches(INPUT))
pToken->suffix += INPUT.GetChar();
}
return pToken;
}
// PlainScalarToken
template <> PlainScalarToken *Scanner::ScanToken(PlainScalarToken *pToken)
{