feat: enter and exit handlers

This commit is contained in:
James Houlahan
2020-07-29 13:59:52 +02:00
parent 8bd74c5edc
commit a7da66ccbc
6 changed files with 269 additions and 90 deletions

View File

@ -63,7 +63,7 @@ func (p *Parser) parse(r io.Reader) (err error) {
}
func (p *Parser) enter() {
p.stack = append(p.stack, &Part{})
p.stack = append(p.stack, &Part{parent: p.top()})
}
func (p *Parser) exit() {
@ -79,6 +79,10 @@ func (p *Parser) exit() {
}
func (p *Parser) top() *Part {
if len(p.stack) == 0 {
return nil
}
return p.stack[len(p.stack)-1]
}