Directive . Note: no semantic checking is done here (that's for the parser to do)
| 18 | // Directive |
| 19 | // . Note: no semantic checking is done here (that's for the parser to do) |
| 20 | void Scanner::ScanDirective() { |
| 21 | std::string name; |
| 22 | std::vector<std::string> params; |
| 23 | |
| 24 | // pop indents and simple keys |
| 25 | PopAllIndents(); |
| 26 | PopAllSimpleKeys(); |
| 27 | |
| 28 | m_simpleKeyAllowed = false; |
| 29 | m_canBeJSONFlow = false; |
| 30 | |
| 31 | // store pos and eat indicator |
| 32 | Token token(Token::DIRECTIVE, INPUT.mark()); |
| 33 | INPUT.eat(1); |
| 34 | |
| 35 | // read name |
| 36 | while (INPUT && !Exp::BlankOrBreak().Matches(INPUT)) |
| 37 | token.value += INPUT.get(); |
| 38 | |
| 39 | // read parameters |
| 40 | while (true) { |
| 41 | // first get rid of whitespace |
| 42 | while (Exp::Blank().Matches(INPUT)) |
| 43 | INPUT.eat(1); |
| 44 | |
| 45 | // break on newline or comment |
| 46 | if (!INPUT || Exp::Break().Matches(INPUT) || Exp::Comment().Matches(INPUT)) |
| 47 | break; |
| 48 | |
| 49 | // now read parameter |
| 50 | std::string param; |
| 51 | while (INPUT && !Exp::BlankOrBreak().Matches(INPUT)) |
| 52 | param += INPUT.get(); |
| 53 | |
| 54 | token.params.push_back(param); |
| 55 | } |
| 56 | |
| 57 | m_tokens.push(token); |
| 58 | } |
| 59 | |
| 60 | // DocStart |
| 61 | void Scanner::ScanDocStart() { |