| 80 | } |
| 81 | |
| 82 | void Scanner::ScanNextToken() { |
| 83 | if (m_endedStream) { |
| 84 | return; |
| 85 | } |
| 86 | |
| 87 | if (!m_startedStream) { |
| 88 | return StartStream(); |
| 89 | } |
| 90 | |
| 91 | // get rid of whitespace, etc. (in between tokens it should be irrelevant) |
| 92 | ScanToNextToken(); |
| 93 | |
| 94 | // maybe need to end some blocks |
| 95 | PopIndentToHere(); |
| 96 | |
| 97 | // ***** |
| 98 | // And now branch based on the next few characters! |
| 99 | // ***** |
| 100 | |
| 101 | // end of stream |
| 102 | if (!INPUT) { |
| 103 | return EndStream(); |
| 104 | } |
| 105 | |
| 106 | if (INPUT.column() == 0 && INPUT.peek() == Keys::Directive) { |
| 107 | return ScanDirective(); |
| 108 | } |
| 109 | |
| 110 | // document token |
| 111 | if (INPUT.column() == 0 && Exp::DocStart().Matches(INPUT)) { |
| 112 | return ScanDocStart(); |
| 113 | } |
| 114 | |
| 115 | if (INPUT.column() == 0 && Exp::DocEnd().Matches(INPUT)) { |
| 116 | return ScanDocEnd(); |
| 117 | } |
| 118 | |
| 119 | // flow start/end/entry |
| 120 | if (INPUT.peek() == Keys::FlowSeqStart || |
| 121 | INPUT.peek() == Keys::FlowMapStart) { |
| 122 | return ScanFlowStart(); |
| 123 | } |
| 124 | |
| 125 | if (INPUT.peek() == Keys::FlowSeqEnd || INPUT.peek() == Keys::FlowMapEnd) { |
| 126 | return ScanFlowEnd(); |
| 127 | } |
| 128 | |
| 129 | if (INPUT.peek() == Keys::FlowEntry) { |
| 130 | return ScanFlowEntry(); |
| 131 | } |
| 132 | |
| 133 | // block/map stuff |
| 134 | if (Exp::BlockEntry().Matches(INPUT)) { |
| 135 | return ScanBlockEntry(); |
| 136 | } |
| 137 | |
| 138 | if ((InBlockContext() ? Exp::Key() : Exp::KeyInFlow()).Matches(INPUT)) { |
| 139 | return ScanKey(); |