// EndStream // . Close out the stream, finish up, etc. void Scanner::EndStream() { // force newline if (INPUT.column() > 0) INPUT.ResetColumn(); PopAllIndents(); PopAllSimpleKeys(); m_simpleKeyAllowed = false; m_endedStream = true; }
// DocEnd void Scanner::ScanDocEnd() { PopAllIndents(); PopAllSimpleKeys(); m_simpleKeyAllowed = false; m_canBeJSONFlow = false; // eat Mark mark = INPUT.mark(); INPUT.eat(3); m_tokens.push(Token(Token::DOC_END, mark)); }
// Directive // . Note: no semantic checking is done here (that's for the parser to do) void Scanner::ScanDirective() { std::string name; std::vector <std::string> params; // pop indents and simple keys PopAllIndents(); PopAllSimpleKeys(); m_simpleKeyAllowed = false; m_canBeJSONFlow = false; // store pos and eat indicator Token token(Token::DIRECTIVE, INPUT.mark()); INPUT.eat(1); // read name while(INPUT && !Exp::BlankOrBreak().Matches(INPUT)) token.value += INPUT.get(); // read parameters while(1) { // first get rid of whitespace while(Exp::Blank().Matches(INPUT)) INPUT.eat(1); // break on newline or comment if(!INPUT || Exp::Break().Matches(INPUT) || Exp::Comment().Matches(INPUT)) break; // now read parameter std::string param; while(INPUT && !Exp::BlankOrBreak().Matches(INPUT)) param += INPUT.get(); token.params.push_back(param); } m_tokens.push(token); }