| 284 | } |
| 285 | |
| 286 | Scanner::IndentMarker* Scanner::PushIndentTo(int column, |
| 287 | IndentMarker::INDENT_TYPE type) { |
| 288 | // are we in flow? |
| 289 | if (InFlowContext()) { |
| 290 | return nullptr; |
| 291 | } |
| 292 | |
| 293 | std::unique_ptr<IndentMarker> pIndent(new IndentMarker(column, type)); |
| 294 | IndentMarker& indent = *pIndent; |
| 295 | const IndentMarker& lastIndent = *m_indents.top(); |
| 296 | |
| 297 | // is this actually an indentation? |
| 298 | if (indent.column < lastIndent.column) { |
| 299 | return nullptr; |
| 300 | } |
| 301 | if (indent.column == lastIndent.column && |
| 302 | !(indent.type == IndentMarker::SEQ && |
| 303 | lastIndent.type == IndentMarker::MAP)) { |
| 304 | return nullptr; |
| 305 | } |
| 306 | |
| 307 | // push a start token |
| 308 | indent.pStartToken = PushToken(GetStartTokenFor(type)); |
| 309 | |
| 310 | // and then the indent |
| 311 | m_indents.push(&indent); |
| 312 | m_indentRefs.push_back(std::move(pIndent)); |
| 313 | return &m_indentRefs.back(); |
| 314 | } |
| 315 | |
| 316 | void Scanner::PopIndentToHere() { |
| 317 | // are we in flow? |