| 168 | } |
| 169 | |
| 170 | func (p *parser) node(kind Kind, defaultTag, tag, value string) *Node { |
| 171 | var style Style |
| 172 | if tag != "" && tag != "!" { |
| 173 | tag = shortTag(tag) |
| 174 | style = TaggedStyle |
| 175 | } else if defaultTag != "" { |
| 176 | tag = defaultTag |
| 177 | } else if kind == ScalarNode { |
| 178 | tag, _ = resolve("", value) |
| 179 | } |
| 180 | n := &Node{ |
| 181 | Kind: kind, |
| 182 | Tag: tag, |
| 183 | Value: value, |
| 184 | Style: style, |
| 185 | } |
| 186 | if !p.textless { |
| 187 | n.Line = p.event.start_mark.line + 1 |
| 188 | n.Column = p.event.start_mark.column + 1 |
| 189 | n.HeadComment = string(p.event.head_comment) |
| 190 | n.LineComment = string(p.event.line_comment) |
| 191 | n.FootComment = string(p.event.foot_comment) |
| 192 | } |
| 193 | return n |
| 194 | } |
| 195 | |
| 196 | func (p *parser) parseChild(parent *Node) *Node { |
| 197 | child := p.parse() |