Record that after the current element is finished (that element is already pushed on the stack) Token should return EOF until popEOF is called.
()
| 413 | // (that element is already pushed on the stack) |
| 414 | // Token should return EOF until popEOF is called. |
| 415 | func (d *Decoder) pushEOF() { |
| 416 | // Walk down stack to find Start. |
| 417 | // It might not be the top, because there might be stkNs |
| 418 | // entries above it. |
| 419 | start := d.stk |
| 420 | for start.kind != stkStart { |
| 421 | start = start.next |
| 422 | } |
| 423 | // The stkNs entries below a start are associated with that |
| 424 | // element too; skip over them. |
| 425 | for start.next != nil && start.next.kind == stkNs { |
| 426 | start = start.next |
| 427 | } |
| 428 | s := d.free |
| 429 | if s != nil { |
| 430 | d.free = s.next |
| 431 | } else { |
| 432 | s = new(stack) |
| 433 | } |
| 434 | s.kind = stkEOF |
| 435 | s.next = start.next |
| 436 | start.next = s |
| 437 | } |
| 438 | |
| 439 | // Undo a pushEOF. |
| 440 | // The element must have been finished, so the EOF should be at the top of the stack. |