示例#1
0
	// DocEnd
	void Scanner::ScanDocEnd()
	{
		PopAllIndents();
		VerifyAllSimpleKeys();
		m_simpleKeyAllowed = false;

		// eat
		Mark mark = INPUT.mark();
		INPUT.eat(3);
		m_tokens.push(Token(TT_DOC_END, mark));
	}
示例#2
0
// 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;
}
示例#3
0
文件: scantoken.cpp 项目: alisw/rivet
// DocStart
void Scanner::ScanDocStart() {
  PopAllIndents();
  PopAllSimpleKeys();
  m_simpleKeyAllowed = false;
  m_canBeJSONFlow = false;

  // eat
  Mark mark = INPUT.mark();
  INPUT.eat(3);
  m_tokens.push(Token(Token::DOC_START, mark));
}
示例#4
0
	// 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();
		VerifyAllSimpleKeys();

		m_simpleKeyAllowed = false;

		// store pos and eat indicator
		Mark mark = INPUT.mark();
		INPUT.eat(1);

		// read name
		while(INPUT && !Exp::BlankOrBreak.Matches(INPUT))
			name += 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();

			params.push_back(param);
		}
		
		Token token(TT_DIRECTIVE, mark);
		token.value = name;
		token.params = params;
		m_tokens.push(token);
	}