Просмотр исходного кода

Header/Inline/Footer => {Head,Line,Foot}Comment

Gustavo Niemeyer 7 лет назад
Родитель
Сommit
f8f8118369
12 измененных файлов с 430 добавлено и 430 удалено
  1. 1 1
      apic.go
  2. 24 23
      decode.go
  3. 48 48
      emitterc.go
  4. 16 16
      encode.go
  5. 270 270
      node_test.go
  6. 31 31
      parserc.go
  7. 1 1
      readerc.go
  8. 11 11
      resolve.go
  9. 11 12
      scannerc.go
  10. 1 1
      sorter.go
  11. 3 3
      yaml.go
  12. 13 13
      yamlh.go

+ 1 - 1
apic.go

@@ -291,7 +291,7 @@ func yaml_document_end_event_initialize(event *yaml_event_t, implicit bool) {
 // Create ALIAS.
 func yaml_alias_event_initialize(event *yaml_event_t, anchor []byte) bool {
 	*event = yaml_event_t{
-		typ: yaml_ALIAS_EVENT,
+		typ:    yaml_ALIAS_EVENT,
 		anchor: anchor,
 	}
 	return true

+ 24 - 23
decode.go

@@ -43,9 +43,10 @@ type Node struct {
 	Anchor   string
 	Alias    *Node
 	Children []*Node
-	Header   string
-	Inline   string
-	Footer   string
+
+	HeadComment string
+	LineComment string
+	FootComment string
 }
 
 func (n *Node) LongTag() string {
@@ -233,15 +234,15 @@ func (p *parser) node(kind NodeKind, defaultTag, tag, value string) *Node {
 		tag, _ = resolve("", value)
 	}
 	return &Node{
-		Kind:   kind,
-		Tag:    tag,
-		Value:  value,
-		Style:  style,
-		Line:   p.event.start_mark.line + 1,
-		Column: p.event.start_mark.column + 1,
-		Header: string(p.event.header_comment),
-		Inline: string(p.event.inline_comment),
-		Footer: string(p.event.footer_comment),
+		Kind:        kind,
+		Tag:         tag,
+		Value:       value,
+		Style:       style,
+		Line:        p.event.start_mark.line + 1,
+		Column:      p.event.start_mark.column + 1,
+		HeadComment: string(p.event.head_comment),
+		LineComment: string(p.event.line_comment),
+		FootComment: string(p.event.foot_comment),
 	}
 }
 
@@ -257,7 +258,7 @@ func (p *parser) document() *Node {
 	p.expect(yaml_DOCUMENT_START_EVENT)
 	p.parseChild(n)
 	if p.peek() == yaml_DOCUMENT_END_EVENT {
-		n.Footer = string(p.event.footer_comment)
+		n.FootComment = string(p.event.foot_comment)
 	}
 	p.expect(yaml_DOCUMENT_END_EVENT)
 	return n
@@ -313,8 +314,8 @@ func (p *parser) sequence() *Node {
 	for p.peek() != yaml_SEQUENCE_END_EVENT {
 		p.parseChild(n)
 	}
-	n.Inline = string(p.event.inline_comment)
-	n.Footer = string(p.event.footer_comment)
+	n.LineComment = string(p.event.line_comment)
+	n.FootComment = string(p.event.foot_comment)
 	p.expect(yaml_SEQUENCE_END_EVENT)
 	return n
 }
@@ -329,13 +330,13 @@ func (p *parser) mapping() *Node {
 	for p.peek() != yaml_MAPPING_END_EVENT {
 		k := p.parseChild(n)
 		v := p.parseChild(n)
-		if v.Footer != "" {
-			k.Footer = v.Footer
-			v.Footer = ""
+		if v.FootComment != "" {
+			k.FootComment = v.FootComment
+			v.FootComment = ""
 		}
 	}
-	n.Inline = string(p.event.inline_comment)
-	n.Footer = string(p.event.footer_comment)
+	n.LineComment = string(p.event.line_comment)
+	n.FootComment = string(p.event.foot_comment)
 	p.expect(yaml_MAPPING_END_EVENT)
 	return n
 }
@@ -367,9 +368,9 @@ var (
 
 func newDecoder() *decoder {
 	d := &decoder{
-		stringMapType: stringMapType,
+		stringMapType:  stringMapType,
 		generalMapType: generalMapType,
-		uniqueKeys: true,
+		uniqueKeys:     true,
 	}
 	d.aliases = make(map[*Node]bool)
 	return d
@@ -756,7 +757,7 @@ func (d *decoder) mapping(n *Node, out reflect.Value) (good bool) {
 		nerrs := len(d.terrors)
 		for i := 0; i < l; i += 2 {
 			ni := n.Children[i]
-			for j := i+2; j < l; j += 2 {
+			for j := i + 2; j < l; j += 2 {
 				nj := n.Children[j]
 				if ni.Kind == nj.Kind && ni.Value == nj.Value {
 					d.terrors = append(d.terrors, fmt.Sprintf("line %d: mapping key %#v already defined at line %d", nj.Line, nj.Value, ni.Line))

+ 48 - 48
emitterc.go

@@ -416,8 +416,8 @@ func yaml_emitter_emit_document_start(emitter *yaml_emitter_t, event *yaml_event
 			}
 		}
 
-		if len(emitter.header_comment) > 0 {
-			if !yaml_emitter_process_header_comment(emitter) {
+		if len(emitter.head_comment) > 0 {
+			if !yaml_emitter_process_head_comment(emitter) {
 				return false
 			}
 			if !put_break(emitter) {
@@ -452,16 +452,16 @@ func yaml_emitter_emit_document_start(emitter *yaml_emitter_t, event *yaml_event
 func yaml_emitter_emit_document_content(emitter *yaml_emitter_t, event *yaml_event_t) bool {
 	emitter.states = append(emitter.states, yaml_EMIT_DOCUMENT_END_STATE)
 
-	if !yaml_emitter_process_header_comment(emitter) {
+	if !yaml_emitter_process_head_comment(emitter) {
 		return false
 	}
 	if !yaml_emitter_emit_node(emitter, event, true, false, false, false) {
 		return false
 	}
-	if !yaml_emitter_process_inline_comment(emitter) {
+	if !yaml_emitter_process_line_comment(emitter) {
 		return false
 	}
-	if !yaml_emitter_process_footer_comment(emitter) {
+	if !yaml_emitter_process_foot_comment(emitter) {
 		return false
 	}
 	return true
@@ -475,11 +475,11 @@ func yaml_emitter_emit_document_end(emitter *yaml_emitter_t, event *yaml_event_t
 	if !yaml_emitter_write_indent(emitter) {
 		return false
 	}
-	if len(emitter.footer_comment) > 0 {
+	if len(emitter.foot_comment) > 0 {
 		if !put_break(emitter) {
 			return false
 		}
-		if !yaml_emitter_process_footer_comment(emitter) {
+		if !yaml_emitter_process_foot_comment(emitter) {
 			return false
 		}
 	}
@@ -527,10 +527,10 @@ func yaml_emitter_emit_flow_sequence_item(emitter *yaml_emitter_t, event *yaml_e
 		if !yaml_emitter_write_indicator(emitter, []byte{']'}, false, false, false) {
 			return false
 		}
-		if !yaml_emitter_process_inline_comment(emitter) {
+		if !yaml_emitter_process_line_comment(emitter) {
 			return false
 		}
-		if !yaml_emitter_process_footer_comment(emitter) {
+		if !yaml_emitter_process_foot_comment(emitter) {
 			return false
 		}
 		emitter.state = emitter.states[len(emitter.states)-1]
@@ -545,7 +545,7 @@ func yaml_emitter_emit_flow_sequence_item(emitter *yaml_emitter_t, event *yaml_e
 		}
 	}
 
-	if !yaml_emitter_process_header_comment(emitter) {
+	if !yaml_emitter_process_head_comment(emitter) {
 		return false
 	}
 	if emitter.column == 0 {
@@ -559,7 +559,7 @@ func yaml_emitter_emit_flow_sequence_item(emitter *yaml_emitter_t, event *yaml_e
 			return false
 		}
 	}
-	if len(emitter.inline_comment) > 0 || len(emitter.footer_comment) > 0 {
+	if len(emitter.line_comment) > 0 || len(emitter.foot_comment) > 0 {
 		emitter.states = append(emitter.states, yaml_EMIT_FLOW_SEQUENCE_TRAIL_ITEM_STATE)
 	} else {
 		emitter.states = append(emitter.states, yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE)
@@ -567,15 +567,15 @@ func yaml_emitter_emit_flow_sequence_item(emitter *yaml_emitter_t, event *yaml_e
 	if !yaml_emitter_emit_node(emitter, event, false, true, false, false) {
 		return false
 	}
-	if len(emitter.inline_comment) > 0 || len(emitter.footer_comment) > 0 {
+	if len(emitter.line_comment) > 0 || len(emitter.foot_comment) > 0 {
 		if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) {
 			return false
 		}
 	}
-	if !yaml_emitter_process_inline_comment(emitter) {
+	if !yaml_emitter_process_line_comment(emitter) {
 		return false
 	}
-	if !yaml_emitter_process_footer_comment(emitter) {
+	if !yaml_emitter_process_foot_comment(emitter) {
 		return false
 	}
 	return true
@@ -608,10 +608,10 @@ func yaml_emitter_emit_flow_mapping_key(emitter *yaml_emitter_t, event *yaml_eve
 		if !yaml_emitter_write_indicator(emitter, []byte{'}'}, false, false, false) {
 			return false
 		}
-		if !yaml_emitter_process_inline_comment(emitter) {
+		if !yaml_emitter_process_line_comment(emitter) {
 			return false
 		}
-		if !yaml_emitter_process_footer_comment(emitter) {
+		if !yaml_emitter_process_foot_comment(emitter) {
 			return false
 		}
 		emitter.state = emitter.states[len(emitter.states)-1]
@@ -625,7 +625,7 @@ func yaml_emitter_emit_flow_mapping_key(emitter *yaml_emitter_t, event *yaml_eve
 		}
 	}
 
-	if !yaml_emitter_process_header_comment(emitter) {
+	if !yaml_emitter_process_head_comment(emitter) {
 		return false
 	}
 	if emitter.column == 0 {
@@ -667,7 +667,7 @@ func yaml_emitter_emit_flow_mapping_value(emitter *yaml_emitter_t, event *yaml_e
 			return false
 		}
 	}
-	if len(emitter.inline_comment) > 0 || len(emitter.footer_comment) > 0 {
+	if len(emitter.line_comment) > 0 || len(emitter.foot_comment) > 0 {
 		emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_TRAIL_KEY_STATE)
 	} else {
 		emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_KEY_STATE)
@@ -675,15 +675,15 @@ func yaml_emitter_emit_flow_mapping_value(emitter *yaml_emitter_t, event *yaml_e
 	if !yaml_emitter_emit_node(emitter, event, false, false, true, false) {
 		return false
 	}
-	if len(emitter.inline_comment) > 0 || len(emitter.footer_comment) > 0 {
+	if len(emitter.line_comment) > 0 || len(emitter.foot_comment) > 0 {
 		if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) {
 			return false
 		}
 	}
-	if !yaml_emitter_process_inline_comment(emitter) {
+	if !yaml_emitter_process_line_comment(emitter) {
 		return false
 	}
-	if !yaml_emitter_process_footer_comment(emitter) {
+	if !yaml_emitter_process_foot_comment(emitter) {
 		return false
 	}
 	return true
@@ -703,7 +703,7 @@ func yaml_emitter_emit_block_sequence_item(emitter *yaml_emitter_t, event *yaml_
 		emitter.states = emitter.states[:len(emitter.states)-1]
 		return true
 	}
-	if !yaml_emitter_process_header_comment(emitter) {
+	if !yaml_emitter_process_head_comment(emitter) {
 		return false
 	}
 	if !yaml_emitter_write_indent(emitter) {
@@ -716,10 +716,10 @@ func yaml_emitter_emit_block_sequence_item(emitter *yaml_emitter_t, event *yaml_
 	if !yaml_emitter_emit_node(emitter, event, false, true, false, false) {
 		return false
 	}
-	if !yaml_emitter_process_inline_comment(emitter) {
+	if !yaml_emitter_process_line_comment(emitter) {
 		return false
 	}
-	if !yaml_emitter_process_footer_comment(emitter) {
+	if !yaml_emitter_process_foot_comment(emitter) {
 		return false
 	}
 	return true
@@ -739,7 +739,7 @@ func yaml_emitter_emit_block_mapping_key(emitter *yaml_emitter_t, event *yaml_ev
 		emitter.states = emitter.states[:len(emitter.states)-1]
 		return true
 	}
-	if !yaml_emitter_process_header_comment(emitter) {
+	if !yaml_emitter_process_head_comment(emitter) {
 		return false
 	}
 	if emitter.states[len(emitter.states)-1] != yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE {
@@ -776,10 +776,10 @@ func yaml_emitter_emit_block_mapping_value(emitter *yaml_emitter_t, event *yaml_
 	if !yaml_emitter_emit_node(emitter, event, false, false, true, false) {
 		return false
 	}
-	if !yaml_emitter_process_inline_comment(emitter) {
+	if !yaml_emitter_process_line_comment(emitter) {
 		return false
 	}
-	if !yaml_emitter_process_footer_comment(emitter) {
+	if !yaml_emitter_process_foot_comment(emitter) {
 		return false
 	}
 	return true
@@ -1048,9 +1048,9 @@ func yaml_emitter_process_scalar(emitter *yaml_emitter_t) bool {
 	panic("unknown scalar style")
 }
 
-// Write a header comment.
-func yaml_emitter_process_header_comment(emitter *yaml_emitter_t) bool {
-	if len(emitter.header_comment) == 0 {
+// Write a head comment.
+func yaml_emitter_process_head_comment(emitter *yaml_emitter_t) bool {
+	if len(emitter.head_comment) == 0 {
 		return true
 	}
 	space_above := emitter.space_above
@@ -1071,16 +1071,16 @@ func yaml_emitter_process_header_comment(emitter *yaml_emitter_t) bool {
 	if !yaml_emitter_write_indent(emitter) {
 		return false
 	}
-	if !yaml_emitter_write_comment(emitter, emitter.header_comment) {
+	if !yaml_emitter_write_comment(emitter, emitter.head_comment) {
 		return false
 	}
-	emitter.header_comment = emitter.header_comment[:0]
+	emitter.head_comment = emitter.head_comment[:0]
 	return true
 }
 
-// Write an inline comment.
-func yaml_emitter_process_inline_comment(emitter *yaml_emitter_t) bool {
-	if len(emitter.inline_comment) == 0 {
+// Write an line comment.
+func yaml_emitter_process_line_comment(emitter *yaml_emitter_t) bool {
+	if len(emitter.line_comment) == 0 {
 		return true
 	}
 	if !emitter.whitespace {
@@ -1088,25 +1088,25 @@ func yaml_emitter_process_inline_comment(emitter *yaml_emitter_t) bool {
 			return false
 		}
 	}
-	if !yaml_emitter_write_comment(emitter, emitter.inline_comment) {
+	if !yaml_emitter_write_comment(emitter, emitter.line_comment) {
 		return false
 	}
-	emitter.inline_comment = emitter.inline_comment[:0]
+	emitter.line_comment = emitter.line_comment[:0]
 	return true
 }
 
-// Write a footer comment.
-func yaml_emitter_process_footer_comment(emitter *yaml_emitter_t) bool {
-	if len(emitter.footer_comment) == 0 {
+// Write a foot comment.
+func yaml_emitter_process_foot_comment(emitter *yaml_emitter_t) bool {
+	if len(emitter.foot_comment) == 0 {
 		return true
 	}
 	if !yaml_emitter_write_indent(emitter) {
 		return false
 	}
-	if !yaml_emitter_write_comment(emitter, emitter.footer_comment) {
+	if !yaml_emitter_write_comment(emitter, emitter.foot_comment) {
 		return false
 	}
-	emitter.footer_comment = emitter.footer_comment[:0]
+	emitter.foot_comment = emitter.foot_comment[:0]
 	return true
 }
 
@@ -1339,14 +1339,14 @@ func yaml_emitter_analyze_event(emitter *yaml_emitter_t, event *yaml_event_t) bo
 	emitter.tag_data.suffix = nil
 	emitter.scalar_data.value = nil
 
-	if len(event.header_comment) > 0 {
-		emitter.header_comment = event.header_comment
+	if len(event.head_comment) > 0 {
+		emitter.head_comment = event.head_comment
 	}
-	if len(event.inline_comment) > 0 {
-		emitter.inline_comment = event.inline_comment
+	if len(event.line_comment) > 0 {
+		emitter.line_comment = event.line_comment
 	}
-	if len(event.footer_comment) > 0 {
-		emitter.footer_comment = event.footer_comment
+	if len(event.foot_comment) > 0 {
+		emitter.foot_comment = event.foot_comment
 	}
 
 	switch event.typ {

+ 16 - 16
encode.go

@@ -368,16 +368,16 @@ func (e *encoder) nilv() {
 	e.emitScalar("null", "", "", yaml_PLAIN_SCALAR_STYLE, nil, nil, nil)
 }
 
-func (e *encoder) emitScalar(value, anchor, tag string, style yaml_scalar_style_t, header, inline, footer []byte) {
+func (e *encoder) emitScalar(value, anchor, tag string, style yaml_scalar_style_t, head, line, foot []byte) {
 	// TODO Kill this function. Replace all initialize calls by their underlining Go literals.
 	implicit := tag == ""
 	if !implicit {
 		tag = longTag(tag)
 	}
 	e.must(yaml_scalar_event_initialize(&e.event, []byte(anchor), []byte(tag), []byte(value), implicit, implicit, style))
-	e.event.header_comment = header
-	e.event.inline_comment = inline
-	e.event.footer_comment = footer
+	e.event.head_comment = head
+	e.event.line_comment = line
+	e.event.foot_comment = foot
 	e.emit()
 }
 
@@ -421,13 +421,13 @@ func (e *encoder) node(node *Node) {
 	switch node.Kind {
 	case DocumentNode:
 		yaml_document_start_event_initialize(&e.event, nil, nil, true)
-		e.event.header_comment = []byte(node.Header)
+		e.event.head_comment = []byte(node.HeadComment)
 		e.emit()
 		for _, node := range node.Children {
 			e.node(node)
 		}
 		yaml_document_end_event_initialize(&e.event, true)
-		e.event.footer_comment = []byte(node.Footer)
+		e.event.foot_comment = []byte(node.FootComment)
 		e.emit()
 
 	case SequenceNode:
@@ -436,14 +436,14 @@ func (e *encoder) node(node *Node) {
 			style = yaml_FLOW_SEQUENCE_STYLE
 		}
 		e.must(yaml_sequence_start_event_initialize(&e.event, []byte(node.Anchor), []byte(tag), tag == "", style))
-		e.event.header_comment = []byte(node.Header)
+		e.event.head_comment = []byte(node.HeadComment)
 		e.emit()
 		for _, node := range node.Children {
 			e.node(node)
 		}
 		e.must(yaml_sequence_end_event_initialize(&e.event))
-		e.event.inline_comment = []byte(node.Inline)
-		e.event.footer_comment = []byte(node.Footer)
+		e.event.line_comment = []byte(node.LineComment)
+		e.event.foot_comment = []byte(node.FootComment)
 		e.emit()
 
 	case MappingNode:
@@ -452,7 +452,7 @@ func (e *encoder) node(node *Node) {
 			style = yaml_FLOW_MAPPING_STYLE
 		}
 		yaml_mapping_start_event_initialize(&e.event, []byte(node.Anchor), []byte(tag), tag == "", style)
-		e.event.header_comment = []byte(node.Header)
+		e.event.head_comment = []byte(node.HeadComment)
 		e.emit()
 
 		for i := 0; i+1 < len(node.Children); i += 2 {
@@ -461,15 +461,15 @@ func (e *encoder) node(node *Node) {
 		}
 
 		yaml_mapping_end_event_initialize(&e.event)
-		e.event.inline_comment = []byte(node.Inline)
-		e.event.footer_comment = []byte(node.Footer)
+		e.event.line_comment = []byte(node.LineComment)
+		e.event.foot_comment = []byte(node.FootComment)
 		e.emit()
 
 	case AliasNode:
 		yaml_alias_event_initialize(&e.event, []byte(node.Value))
-		e.event.header_comment = []byte(node.Header)
-		e.event.inline_comment = []byte(node.Inline)
-		e.event.footer_comment = []byte(node.Footer)
+		e.event.head_comment = []byte(node.HeadComment)
+		e.event.line_comment = []byte(node.LineComment)
+		e.event.foot_comment = []byte(node.FootComment)
 		e.emit()
 
 	case ScalarNode:
@@ -489,7 +489,7 @@ func (e *encoder) node(node *Node) {
 			style = yaml_DOUBLE_QUOTED_SCALAR_STYLE
 		}
 
-		e.emitScalar(node.Value, node.Anchor, tag, style, []byte(node.Header), []byte(node.Inline), []byte(node.Footer))
+		e.emitScalar(node.Value, node.Anchor, tag, style, []byte(node.HeadComment), []byte(node.LineComment), []byte(node.FootComment))
 
 		// TODO Check if binaries are being decoded into node.Value or not.
 		//switch {

+ 270 - 270
node_test.go

@@ -616,200 +616,200 @@ var nodeTests = []struct {
 			Line:   3,
 			Column: 1,
 			Children: []*yaml.Node{{
-				Kind:   yaml.ScalarNode,
-				Value:  "true",
-				Tag:    "!!bool",
-				Line:   3,
-				Column: 1,
-				Header: "# One\n# Two",
-				Inline: "# Three",
-				Footer: "# Four\n# Five",
+				Kind:        yaml.ScalarNode,
+				Value:       "true",
+				Tag:         "!!bool",
+				Line:        3,
+				Column:      1,
+				HeadComment: "# One\n# Two",
+				LineComment: "# Three",
+				FootComment: "# Four\n# Five",
 			}},
 		},
 	}, {
 		"# DH1\n\n# DH2\n\n# H1\n# H2\ntrue # I\n# F1\n# F2\n\n# DF1\n\n# DF2\n",
 		yaml.Node{
-			Kind:   yaml.DocumentNode,
-			Line:   7,
-			Column: 1,
-			Header: "# DH1\n\n# DH2",
-			Footer: "# DF1\n\n# DF2",
+			Kind:        yaml.DocumentNode,
+			Line:        7,
+			Column:      1,
+			HeadComment: "# DH1\n\n# DH2",
+			FootComment: "# DF1\n\n# DF2",
 			Children: []*yaml.Node{{
-				Kind:   yaml.ScalarNode,
-				Value:  "true",
-				Tag:    "!!bool",
-				Line:   7,
-				Column: 1,
-				Header: "# H1\n# H2",
-				Inline: "# I",
-				Footer: "# F1\n# F2",
+				Kind:        yaml.ScalarNode,
+				Value:       "true",
+				Tag:         "!!bool",
+				Line:        7,
+				Column:      1,
+				HeadComment: "# H1\n# H2",
+				LineComment: "# I",
+				FootComment: "# F1\n# F2",
 			}},
 		},
 	}, {
 		"# DH1\n\n# DH2\n\n# HA1\n# HA2\nka: va # IA\n# FA1\n# FA2\n\n# HB1\n# HB2\nkb: vb # IB\n# FB1\n# FB2\n\n# DF1\n\n# DF2\n",
 		yaml.Node{
-			Kind:   yaml.DocumentNode,
-			Line:   7,
-			Column: 1,
-			Header: "# DH1\n\n# DH2",
-			Footer: "# DF1\n\n# DF2",
+			Kind:        yaml.DocumentNode,
+			Line:        7,
+			Column:      1,
+			HeadComment: "# DH1\n\n# DH2",
+			FootComment: "# DF1\n\n# DF2",
 			Children: []*yaml.Node{{
 				Kind:   yaml.MappingNode,
 				Tag:    "!!map",
 				Line:   7,
 				Column: 1,
 				Children: []*yaml.Node{{
-					Kind:   yaml.ScalarNode,
-					Line:   7,
-					Column: 1,
-					Tag:    "!!str",
-					Value:  "ka",
-					Header: "# HA1\n# HA2",
-					Footer: "# FA1\n# FA2",
+					Kind:        yaml.ScalarNode,
+					Line:        7,
+					Column:      1,
+					Tag:         "!!str",
+					Value:       "ka",
+					HeadComment: "# HA1\n# HA2",
+					FootComment: "# FA1\n# FA2",
 				}, {
-					Kind:   yaml.ScalarNode,
-					Line:   7,
-					Column: 5,
-					Tag:    "!!str",
-					Value:  "va",
-					Inline: "# IA",
+					Kind:        yaml.ScalarNode,
+					Line:        7,
+					Column:      5,
+					Tag:         "!!str",
+					Value:       "va",
+					LineComment: "# IA",
 				}, {
-					Kind:   yaml.ScalarNode,
-					Line:   13,
-					Column: 1,
-					Tag:    "!!str",
-					Value:  "kb",
-					Header: "# HB1\n# HB2",
-					Footer: "# FB1\n# FB2",
+					Kind:        yaml.ScalarNode,
+					Line:        13,
+					Column:      1,
+					Tag:         "!!str",
+					Value:       "kb",
+					HeadComment: "# HB1\n# HB2",
+					FootComment: "# FB1\n# FB2",
 				}, {
-					Kind:   yaml.ScalarNode,
-					Line:   13,
-					Column: 5,
-					Tag:    "!!str",
-					Value:  "vb",
-					Inline: "# IB",
+					Kind:        yaml.ScalarNode,
+					Line:        13,
+					Column:      5,
+					Tag:         "!!str",
+					Value:       "vb",
+					LineComment: "# IB",
 				}},
 			}},
 		},
 	}, {
 		"# DH1\n\n# DH2\n\n# HA1\n# HA2\n- la # IA\n# FA1\n# FA2\n\n# HB1\n# HB2\n- lb # IB\n# FB1\n# FB2\n\n# DF1\n\n# DF2\n",
 		yaml.Node{
-			Kind:   yaml.DocumentNode,
-			Line:   7,
-			Column: 1,
-			Header: "# DH1\n\n# DH2",
-			Footer: "# DF1\n\n# DF2",
+			Kind:        yaml.DocumentNode,
+			Line:        7,
+			Column:      1,
+			HeadComment: "# DH1\n\n# DH2",
+			FootComment: "# DF1\n\n# DF2",
 			Children: []*yaml.Node{{
 				Kind:   yaml.SequenceNode,
 				Tag:    "!!seq",
 				Line:   7,
 				Column: 1,
 				Children: []*yaml.Node{{
-					Kind:   yaml.ScalarNode,
-					Tag:    "!!str",
-					Line:   7,
-					Column: 3,
-					Value:  "la",
-					Header: "# HA1\n# HA2",
-					Inline: "# IA",
-					Footer: "# FA1\n# FA2",
+					Kind:        yaml.ScalarNode,
+					Tag:         "!!str",
+					Line:        7,
+					Column:      3,
+					Value:       "la",
+					HeadComment: "# HA1\n# HA2",
+					LineComment: "# IA",
+					FootComment: "# FA1\n# FA2",
 				}, {
-					Kind:   yaml.ScalarNode,
-					Tag:    "!!str",
-					Line:   13,
-					Column: 3,
-					Value:  "lb",
-					Header: "# HB1\n# HB2",
-					Inline: "# IB",
-					Footer: "# FB1\n# FB2",
+					Kind:        yaml.ScalarNode,
+					Tag:         "!!str",
+					Line:        13,
+					Column:      3,
+					Value:       "lb",
+					HeadComment: "# HB1\n# HB2",
+					LineComment: "# IB",
+					FootComment: "# FB1\n# FB2",
 				}},
 			}},
 		},
 	}, {
 		"# DH1\n\n- la # IA\n\n# HB1\n- lb\n",
 		yaml.Node{
-			Kind:   yaml.DocumentNode,
-			Line:   3,
-			Column: 1,
-			Header: "# DH1",
+			Kind:        yaml.DocumentNode,
+			Line:        3,
+			Column:      1,
+			HeadComment: "# DH1",
 			Children: []*yaml.Node{{
 				Kind:   yaml.SequenceNode,
 				Tag:    "!!seq",
 				Line:   3,
 				Column: 1,
 				Children: []*yaml.Node{{
-					Kind:   yaml.ScalarNode,
-					Tag:    "!!str",
-					Line:   3,
-					Column: 3,
-					Value:  "la",
-					Inline: "# IA",
+					Kind:        yaml.ScalarNode,
+					Tag:         "!!str",
+					Line:        3,
+					Column:      3,
+					Value:       "la",
+					LineComment: "# IA",
 				}, {
-					Kind:   yaml.ScalarNode,
-					Tag:    "!!str",
-					Line:   6,
-					Column: 3,
-					Value:  "lb",
-					Header: "# HB1",
+					Kind:        yaml.ScalarNode,
+					Tag:         "!!str",
+					Line:        6,
+					Column:      3,
+					Value:       "lb",
+					HeadComment: "# HB1",
 				}},
 			}},
 		},
 	}, {
 		"# DH1\n\n# HA1\nka:\n  # HB1\n  kb:\n  # HC1\n  # HC2\n  - lc # IC\n  # FC1\n  # FC2\n\n  # HD1\n  - ld # ID\n  # FD1\n\n# DF1\n",
 		yaml.Node{
-			Kind:   yaml.DocumentNode,
-			Line:   4,
-			Column: 1,
-			Header: "# DH1",
-			Footer: "# DF1",
+			Kind:        yaml.DocumentNode,
+			Line:        4,
+			Column:      1,
+			HeadComment: "# DH1",
+			FootComment: "# DF1",
 			Children: []*yaml.Node{{
 				Kind:   yaml.MappingNode,
 				Tag:    "!!map",
 				Line:   4,
 				Column: 1,
 				Children: []*yaml.Node{{
-					Kind:   yaml.ScalarNode,
-					Tag:    "!!str",
-					Line:   4,
-					Column: 1,
-					Value:  "ka",
-					Header: "# HA1",
+					Kind:        yaml.ScalarNode,
+					Tag:         "!!str",
+					Line:        4,
+					Column:      1,
+					Value:       "ka",
+					HeadComment: "# HA1",
 				}, {
 					Kind:   yaml.MappingNode,
 					Tag:    "!!map",
 					Line:   6,
 					Column: 3,
 					Children: []*yaml.Node{{
-						Kind:   yaml.ScalarNode,
-						Tag:    "!!str",
-						Line:   6,
-						Column: 3,
-						Value:  "kb",
-						Header: "# HB1",
+						Kind:        yaml.ScalarNode,
+						Tag:         "!!str",
+						Line:        6,
+						Column:      3,
+						Value:       "kb",
+						HeadComment: "# HB1",
 					}, {
 						Kind:   yaml.SequenceNode,
 						Line:   9,
 						Column: 3,
 						Tag:    "!!seq",
 						Children: []*yaml.Node{{
-							Kind:   yaml.ScalarNode,
-							Tag:    "!!str",
-							Line:   9,
-							Column: 5,
-							Value:  "lc",
-							Header: "# HC1\n# HC2",
-							Inline: "# IC",
-							Footer: "# FC1\n# FC2",
+							Kind:        yaml.ScalarNode,
+							Tag:         "!!str",
+							Line:        9,
+							Column:      5,
+							Value:       "lc",
+							HeadComment: "# HC1\n# HC2",
+							LineComment: "# IC",
+							FootComment: "# FC1\n# FC2",
 						}, {
-							Kind:   yaml.ScalarNode,
-							Tag:    "!!str",
-							Line:   14,
-							Column: 5,
-							Value:  "ld",
-							Header: "# HD1",
+							Kind:        yaml.ScalarNode,
+							Tag:         "!!str",
+							Line:        14,
+							Column:      5,
+							Value:       "ld",
+							HeadComment: "# HD1",
 
-							Inline: "# ID",
-							Footer: "# FD1",
+							LineComment: "# ID",
+							FootComment: "# FD1",
 						}},
 					}},
 				}},
@@ -822,14 +822,14 @@ var nodeTests = []struct {
 			Line:   2,
 			Column: 1,
 			Children: []*yaml.Node{{
-				Kind:   yaml.SequenceNode,
-				Tag:    "!!seq",
-				Style:  yaml.FlowStyle,
-				Line:   2,
-				Column: 1,
-				Header: "# H1",
-				Inline: "# I",
-				Footer: "# F1",
+				Kind:        yaml.SequenceNode,
+				Tag:         "!!seq",
+				Style:       yaml.FlowStyle,
+				Line:        2,
+				Column:      1,
+				HeadComment: "# H1",
+				LineComment: "# I",
+				FootComment: "# F1",
 				Children: []*yaml.Node{{
 					Kind:   yaml.ScalarNode,
 					Tag:    "!!str",
@@ -848,148 +848,148 @@ var nodeTests = []struct {
 	}, {
 		"# DH1\n\n# SH1\n[\n  # HA1\n  la, # IA\n  # FA1\n\n  # HB1\n  lb, # IB\n  # FB1\n]\n# SF1\n\n# DF1\n",
 		yaml.Node{
-			Kind:   yaml.DocumentNode,
-			Line:   4,
-			Column: 1,
-			Header: "# DH1",
-			Footer: "# DF1",
+			Kind:        yaml.DocumentNode,
+			Line:        4,
+			Column:      1,
+			HeadComment: "# DH1",
+			FootComment: "# DF1",
 			Children: []*yaml.Node{{
-				Kind:   yaml.SequenceNode,
-				Tag:    "!!seq",
-				Style:  yaml.FlowStyle,
-				Line:   4,
-				Column: 1,
-				Header: "# SH1",
-				Footer: "# SF1",
+				Kind:        yaml.SequenceNode,
+				Tag:         "!!seq",
+				Style:       yaml.FlowStyle,
+				Line:        4,
+				Column:      1,
+				HeadComment: "# SH1",
+				FootComment: "# SF1",
 				Children: []*yaml.Node{{
-					Kind:   yaml.ScalarNode,
-					Tag:    "!!str",
-					Line:   6,
-					Column: 3,
-					Value:  "la",
-					Header: "# HA1",
-					Inline: "# IA",
-					Footer: "# FA1",
+					Kind:        yaml.ScalarNode,
+					Tag:         "!!str",
+					Line:        6,
+					Column:      3,
+					Value:       "la",
+					HeadComment: "# HA1",
+					LineComment: "# IA",
+					FootComment: "# FA1",
 				}, {
-					Kind:   yaml.ScalarNode,
-					Tag:    "!!str",
-					Line:   10,
-					Column: 3,
-					Value:  "lb",
-					Header: "# HB1",
-					Inline: "# IB",
-					Footer: "# FB1",
+					Kind:        yaml.ScalarNode,
+					Tag:         "!!str",
+					Line:        10,
+					Column:      3,
+					Value:       "lb",
+					HeadComment: "# HB1",
+					LineComment: "# IB",
+					FootComment: "# FB1",
 				}},
 			}},
 		},
 	}, {
 		"# DH1\n\n# SH1\n[\n  # HA1\n  la,\n  # FA1\n\n  # HB1\n  lb,\n  # FB1\n]\n# SF1\n\n# DF1\n",
 		yaml.Node{
-			Kind:   yaml.DocumentNode,
-			Line:   4,
-			Column: 1,
-			Header: "# DH1",
-			Footer: "# DF1",
+			Kind:        yaml.DocumentNode,
+			Line:        4,
+			Column:      1,
+			HeadComment: "# DH1",
+			FootComment: "# DF1",
 			Children: []*yaml.Node{{
-				Kind:   yaml.SequenceNode,
-				Tag:    "!!seq",
-				Style:  yaml.FlowStyle,
-				Line:   4,
-				Column: 1,
-				Header: "# SH1",
-				Footer: "# SF1",
+				Kind:        yaml.SequenceNode,
+				Tag:         "!!seq",
+				Style:       yaml.FlowStyle,
+				Line:        4,
+				Column:      1,
+				HeadComment: "# SH1",
+				FootComment: "# SF1",
 				Children: []*yaml.Node{{
-					Kind:   yaml.ScalarNode,
-					Tag:    "!!str",
-					Line:   6,
-					Column: 3,
-					Value:  "la",
-					Header: "# HA1",
-					Footer: "# FA1",
+					Kind:        yaml.ScalarNode,
+					Tag:         "!!str",
+					Line:        6,
+					Column:      3,
+					Value:       "la",
+					HeadComment: "# HA1",
+					FootComment: "# FA1",
 				}, {
-					Kind:   yaml.ScalarNode,
-					Tag:    "!!str",
-					Line:   10,
-					Column: 3,
-					Value:  "lb",
-					Header: "# HB1",
-					Footer: "# FB1",
+					Kind:        yaml.ScalarNode,
+					Tag:         "!!str",
+					Line:        10,
+					Column:      3,
+					Value:       "lb",
+					HeadComment: "# HB1",
+					FootComment: "# FB1",
 				}},
 			}},
 		},
 	}, {
 		"# DH1\n\n# MH1\n{\n  # HA1\n  ka: va, # IA\n  # FA1\n\n  # HB1\n  kb: vb, # IB\n  # FB1\n}\n# MF1\n\n# DF1\n",
 		yaml.Node{
-			Kind:   yaml.DocumentNode,
-			Line:   4,
-			Column: 1,
-			Header: "# DH1",
-			Footer: "# DF1",
+			Kind:        yaml.DocumentNode,
+			Line:        4,
+			Column:      1,
+			HeadComment: "# DH1",
+			FootComment: "# DF1",
 			Children: []*yaml.Node{{
-				Kind:   yaml.MappingNode,
-				Tag:    "!!map",
-				Style:  yaml.FlowStyle,
-				Line:   4,
-				Column: 1,
-				Header: "# MH1",
-				Footer: "# MF1",
+				Kind:        yaml.MappingNode,
+				Tag:         "!!map",
+				Style:       yaml.FlowStyle,
+				Line:        4,
+				Column:      1,
+				HeadComment: "# MH1",
+				FootComment: "# MF1",
 				Children: []*yaml.Node{{
-					Kind:   yaml.ScalarNode,
-					Tag:    "!!str",
-					Line:   6,
-					Column: 3,
-					Value:  "ka",
-					Header: "# HA1",
-					Footer: "# FA1",
+					Kind:        yaml.ScalarNode,
+					Tag:         "!!str",
+					Line:        6,
+					Column:      3,
+					Value:       "ka",
+					HeadComment: "# HA1",
+					FootComment: "# FA1",
 				}, {
-					Kind:   yaml.ScalarNode,
-					Tag:    "!!str",
-					Line:   6,
-					Column: 7,
-					Value:  "va",
-					Inline: "# IA",
+					Kind:        yaml.ScalarNode,
+					Tag:         "!!str",
+					Line:        6,
+					Column:      7,
+					Value:       "va",
+					LineComment: "# IA",
 				}, {
-					Kind:   yaml.ScalarNode,
-					Tag:    "!!str",
-					Line:   10,
-					Column: 3,
-					Value:  "kb",
-					Header: "# HB1",
-					Footer: "# FB1",
+					Kind:        yaml.ScalarNode,
+					Tag:         "!!str",
+					Line:        10,
+					Column:      3,
+					Value:       "kb",
+					HeadComment: "# HB1",
+					FootComment: "# FB1",
 				}, {
-					Kind:   yaml.ScalarNode,
-					Tag:    "!!str",
-					Line:   10,
-					Column: 7,
-					Value:  "vb",
-					Inline: "# IB",
+					Kind:        yaml.ScalarNode,
+					Tag:         "!!str",
+					Line:        10,
+					Column:      7,
+					Value:       "vb",
+					LineComment: "# IB",
 				}},
 			}},
 		},
 	}, {
 		"# DH1\n\n# MH1\n{\n  # HA1\n  ka: va,\n  # FA1\n\n  # HB1\n  kb: vb,\n  # FB1\n}\n# MF1\n\n# DF1\n",
 		yaml.Node{
-			Kind:   yaml.DocumentNode,
-			Line:   4,
-			Column: 1,
-			Header: "# DH1",
-			Footer: "# DF1",
+			Kind:        yaml.DocumentNode,
+			Line:        4,
+			Column:      1,
+			HeadComment: "# DH1",
+			FootComment: "# DF1",
 			Children: []*yaml.Node{{
-				Kind:   yaml.MappingNode,
-				Tag:    "!!map",
-				Style:  yaml.FlowStyle,
-				Line:   4,
-				Column: 1,
-				Header: "# MH1",
-				Footer: "# MF1",
+				Kind:        yaml.MappingNode,
+				Tag:         "!!map",
+				Style:       yaml.FlowStyle,
+				Line:        4,
+				Column:      1,
+				HeadComment: "# MH1",
+				FootComment: "# MF1",
 				Children: []*yaml.Node{{
-					Kind:   yaml.ScalarNode,
-					Tag:    "!!str",
-					Line:   6,
-					Column: 3,
-					Value:  "ka",
-					Header: "# HA1",
-					Footer: "# FA1",
+					Kind:        yaml.ScalarNode,
+					Tag:         "!!str",
+					Line:        6,
+					Column:      3,
+					Value:       "ka",
+					HeadComment: "# HA1",
+					FootComment: "# FA1",
 				}, {
 					Kind:   yaml.ScalarNode,
 					Tag:    "!!str",
@@ -997,13 +997,13 @@ var nodeTests = []struct {
 					Column: 7,
 					Value:  "va",
 				}, {
-					Kind:   yaml.ScalarNode,
-					Tag:    "!!str",
-					Line:   10,
-					Column: 3,
-					Value:  "kb",
-					Header: "# HB1",
-					Footer: "# FB1",
+					Kind:        yaml.ScalarNode,
+					Tag:         "!!str",
+					Line:        10,
+					Column:      3,
+					Value:       "kb",
+					HeadComment: "# HB1",
+					FootComment: "# FB1",
 				}, {
 					Kind:   yaml.ScalarNode,
 					Tag:    "!!str",
@@ -1016,11 +1016,11 @@ var nodeTests = []struct {
 	}, {
 		"# DH1\n\n# DH2\n\n# HA1\n# HA2\n- &x la # IA\n# FA1\n# FA2\n\n# HB1\n# HB2\n- *x # IB\n# FB1\n# FB2\n\n# DF1\n\n# DF2\n",
 		yaml.Node{
-			Kind:   yaml.DocumentNode,
-			Line:   7,
-			Column: 1,
-			Header: "# DH1\n\n# DH2",
-			Footer: "# DF1\n\n# DF2",
+			Kind:        yaml.DocumentNode,
+			Line:        7,
+			Column:      1,
+			HeadComment: "# DH1\n\n# DH2",
+			FootComment: "# DF1\n\n# DF2",
 			Children: []*yaml.Node{{
 				Kind:   yaml.SequenceNode,
 				Tag:    "!!seq",
@@ -1028,24 +1028,24 @@ var nodeTests = []struct {
 				Column: 1,
 				Children: []*yaml.Node{
 					saveNode("x", &yaml.Node{
-						Kind:   yaml.ScalarNode,
-						Tag:    "!!str",
-						Line:   7,
-						Column: 3,
-						Value:  "la",
-						Header: "# HA1\n# HA2",
-						Inline: "# IA",
-						Footer: "# FA1\n# FA2",
-						Anchor: "x",
+						Kind:        yaml.ScalarNode,
+						Tag:         "!!str",
+						Line:        7,
+						Column:      3,
+						Value:       "la",
+						HeadComment: "# HA1\n# HA2",
+						LineComment: "# IA",
+						FootComment: "# FA1\n# FA2",
+						Anchor:      "x",
 					}), {
-						Kind:   yaml.AliasNode,
-						Line:   13,
-						Column: 3,
-						Value:  "x",
-						Alias:  dropNode("x"),
-						Header: "# HB1\n# HB2",
-						Inline: "# IB",
-						Footer: "# FB1\n# FB2",
+						Kind:        yaml.AliasNode,
+						Line:        13,
+						Column:      3,
+						Value:       "x",
+						Alias:       dropNode("x"),
+						HeadComment: "# HB1\n# HB2",
+						LineComment: "# IB",
+						FootComment: "# FB1\n# FB2",
 					},
 				},
 			}},

+ 31 - 31
parserc.go

@@ -58,23 +58,23 @@ func peek_token(parser *yaml_parser_t) *yaml_token_t {
 func yaml_parser_unfold_comments(parser *yaml_parser_t, token *yaml_token_t) {
 	for parser.comments_head < len(parser.comments) && token.start_mark.index >= parser.comments[parser.comments_head].after.index {
 		comment := &parser.comments[parser.comments_head]
-		if len(comment.header) > 0 {
-			if len(parser.header_comment) > 0 {
-				parser.header_comment = append(parser.header_comment, '\n')
+		if len(comment.head) > 0 {
+			if len(parser.head_comment) > 0 {
+				parser.head_comment = append(parser.head_comment, '\n')
 			}
-			parser.header_comment = append(parser.header_comment, comment.header...)
+			parser.head_comment = append(parser.head_comment, comment.head...)
 		}
-		if len(comment.footer) > 0 {
-			if len(parser.footer_comment) > 0 {
-				parser.footer_comment = append(parser.footer_comment, '\n')
+		if len(comment.foot) > 0 {
+			if len(parser.foot_comment) > 0 {
+				parser.foot_comment = append(parser.foot_comment, '\n')
 			}
-			parser.footer_comment = append(parser.footer_comment, comment.footer...)
+			parser.foot_comment = append(parser.foot_comment, comment.foot...)
 		}
-		if len(comment.inline) > 0 {
-			if len(parser.inline_comment) > 0 {
-				parser.inline_comment = append(parser.inline_comment, '\n')
+		if len(comment.line) > 0 {
+			if len(parser.line_comment) > 0 {
+				parser.line_comment = append(parser.line_comment, '\n')
 			}
-			parser.inline_comment = append(parser.inline_comment, comment.inline...)
+			parser.line_comment = append(parser.line_comment, comment.line...)
 		}
 		*comment = yaml_comment_t{}
 		parser.comments_head++
@@ -255,20 +255,20 @@ func yaml_parser_parse_document_start(parser *yaml_parser_t, event *yaml_event_t
 		parser.states = append(parser.states, yaml_PARSE_DOCUMENT_END_STATE)
 		parser.state = yaml_PARSE_BLOCK_NODE_STATE
 
-		var header_comment []byte
-		if len(parser.header_comment) > 0 {
+		var head_comment []byte
+		if len(parser.head_comment) > 0 {
 			// [Go] Scan the header comment backwards, and if an empty line is found, break
 			//      the header so the part before the last empty line goes into the
 			//      document header, while the bottom of it goes into a follow up event.
-			for i := len(parser.header_comment)-1; i > 0; i-- {
-				if parser.header_comment[i] == '\n' {
-					if i == len(parser.header_comment)-1 {
-						header_comment = parser.header_comment[:i]
-						parser.header_comment = parser.header_comment[i+1:]
+			for i := len(parser.head_comment) - 1; i > 0; i-- {
+				if parser.head_comment[i] == '\n' {
+					if i == len(parser.head_comment)-1 {
+						head_comment = parser.head_comment[:i]
+						parser.head_comment = parser.head_comment[i+1:]
 						break
-					} else if parser.header_comment[i-1] == '\n' {
-						header_comment = parser.header_comment[:i-1]
-						parser.header_comment = parser.header_comment[i+1:]
+					} else if parser.head_comment[i-1] == '\n' {
+						head_comment = parser.head_comment[:i-1]
+						parser.head_comment = parser.head_comment[i+1:]
 						break
 					}
 				}
@@ -280,7 +280,7 @@ func yaml_parser_parse_document_start(parser *yaml_parser_t, event *yaml_event_t
 			start_mark: token.start_mark,
 			end_mark:   token.end_mark,
 
-			header_comment: header_comment,
+			head_comment: head_comment,
 		}
 
 	} else if token.typ != yaml_STREAM_END_TOKEN {
@@ -380,19 +380,19 @@ func yaml_parser_parse_document_end(parser *yaml_parser_t, event *yaml_event_t)
 		end_mark:   end_mark,
 		implicit:   implicit,
 
-		footer_comment: parser.header_comment,
+		foot_comment: parser.head_comment,
 	}
-	parser.header_comment = nil
+	parser.head_comment = nil
 	return true
 }
 
 func yaml_parser_set_event_comments(parser *yaml_parser_t, event *yaml_event_t) {
-	event.header_comment = parser.header_comment
-	event.inline_comment = parser.inline_comment
-	event.footer_comment = parser.footer_comment
-	parser.header_comment = nil
-	parser.inline_comment = nil
-	parser.footer_comment = nil
+	event.head_comment = parser.head_comment
+	event.line_comment = parser.line_comment
+	event.foot_comment = parser.foot_comment
+	parser.head_comment = nil
+	parser.line_comment = nil
+	parser.foot_comment = nil
 }
 
 // Parse the productions:

+ 1 - 1
readerc.go

@@ -95,7 +95,7 @@ func yaml_parser_update_buffer(parser *yaml_parser_t, length int) bool {
 
 	// [Go] This function was changed to guarantee the requested length size at EOF.
 	// The fact we need to do this is pretty awful, but the description above implies
-	// for that to be the case, and there are tests 
+	// for that to be the case, and there are tests
 
 	// If the EOF flag is set and the raw buffer is empty, do nothing.
 	if parser.eof && parser.raw_buffer_pos == len(parser.raw_buffer) {

+ 11 - 11
resolve.go

@@ -53,16 +53,16 @@ func init() {
 }
 
 const (
-	nullTag = "!!null"
-	boolTag = "!!bool"
-	strTag = "!!str"
-	intTag = "!!int"
-	floatTag = "!!float"
+	nullTag      = "!!null"
+	boolTag      = "!!bool"
+	strTag       = "!!str"
+	intTag       = "!!int"
+	floatTag     = "!!float"
 	timestampTag = "!!timestamp"
-	seqTag = "!!seq"
-	mapTag = "!!map"
-	binaryTag = "!!binary"
-	mergeTag = "!!merge"
+	seqTag       = "!!seq"
+	mapTag       = "!!map"
+	binaryTag    = "!!binary"
+	mergeTag     = "!!merge"
 )
 
 var longTags = make(map[string]string)
@@ -206,7 +206,7 @@ func resolve(tag string, in string) (rtag string, out interface{}) {
 					return intTag, uintv
 				}
 			} else if strings.HasPrefix(plain, "-0b") {
-				intv, err := strconv.ParseInt("-" + plain[3:], 2, 64)
+				intv, err := strconv.ParseInt("-"+plain[3:], 2, 64)
 				if err == nil {
 					if true || intv == int64(int(intv)) {
 						return intTag, int(intv)
@@ -233,7 +233,7 @@ func resolve(tag string, in string) (rtag string, out interface{}) {
 					return intTag, uintv
 				}
 			} else if strings.HasPrefix(plain, "-0o") {
-				intv, err := strconv.ParseInt("-" + plain[3:], 8, 64)
+				intv, err := strconv.ParseInt("-"+plain[3:], 8, 64)
 				if err == nil {
 					if true || intv == int64(int(intv)) {
 						return intTag, int(intv)

+ 11 - 12
scannerc.go

@@ -729,11 +729,11 @@ func yaml_parser_fetch_next_token(parser *yaml_parser_t) (ok bool) {
 		if !ok {
 			return
 		}
-		if !yaml_parser_scan_inline_comment(parser, comment_mark) {
+		if !yaml_parser_scan_line_comment(parser, comment_mark) {
 			ok = false
 			return
 		}
-		if !yaml_parser_scan_footer_comment(parser, comment_mark) {
+		if !yaml_parser_scan_foot_comment(parser, comment_mark) {
 			ok = false
 			return
 		}
@@ -1478,7 +1478,7 @@ func yaml_parser_scan_to_next_token(parser *yaml_parser_t) bool {
 
 		// Eat a comment until a line break.
 		if parser.buffer[parser.buffer_pos] == '#' {
-			if !yaml_parser_scan_header_comment(parser, parser.mark) {
+			if !yaml_parser_scan_head_comment(parser, parser.mark) {
 				return false
 			}
 		}
@@ -1578,7 +1578,7 @@ func yaml_parser_scan_directive(parser *yaml_parser_t, token *yaml_token_t) bool
 
 	if parser.buffer[parser.buffer_pos] == '#' {
 		// [Go] Discard this inline comment for the time being.
-		//if !yaml_parser_scan_inline_comment(parser, start_mark) {
+		//if !yaml_parser_scan_line_comment(parser, start_mark) {
 		//	return false
 		//}
 		for !is_breakz(parser.buffer, parser.buffer_pos) {
@@ -2151,7 +2151,7 @@ func yaml_parser_scan_block_scalar(parser *yaml_parser_t, token *yaml_token_t, l
 		}
 	}
 	if parser.buffer[parser.buffer_pos] == '#' {
-		if !yaml_parser_scan_inline_comment(parser, start_mark) {
+		if !yaml_parser_scan_line_comment(parser, start_mark) {
 			return false
 		}
 	}
@@ -2716,14 +2716,13 @@ func yaml_parser_scan_plain_scalar(parser *yaml_parser_t, token *yaml_token_t) b
 	return true
 }
 
-
-func yaml_parser_scan_inline_comment(parser *yaml_parser_t, after yaml_mark_t) bool {
+func yaml_parser_scan_line_comment(parser *yaml_parser_t, after yaml_mark_t) bool {
 	if parser.mark.column == 0 {
 		return true
 	}
 
 	parser.comments = append(parser.comments, yaml_comment_t{after: after})
-	comment := &parser.comments[len(parser.comments)-1].inline
+	comment := &parser.comments[len(parser.comments)-1].line
 
 	for peek := 0; peek < 512; peek++ {
 		if parser.unread < peek+1 && !yaml_parser_update_buffer(parser, peek+1) {
@@ -2763,9 +2762,9 @@ func yaml_parser_scan_inline_comment(parser *yaml_parser_t, after yaml_mark_t) b
 	return true
 }
 
-func yaml_parser_scan_header_comment(parser *yaml_parser_t, after yaml_mark_t) bool {
+func yaml_parser_scan_head_comment(parser *yaml_parser_t, after yaml_mark_t) bool {
 	parser.comments = append(parser.comments, yaml_comment_t{after: after})
-	comment := &parser.comments[len(parser.comments)-1].header
+	comment := &parser.comments[len(parser.comments)-1].head
 	breaks := false
 	for peek := 0; peek < 512; peek++ {
 		if parser.unread < peek+1 && !yaml_parser_update_buffer(parser, peek+1) {
@@ -2815,9 +2814,9 @@ func yaml_parser_scan_header_comment(parser *yaml_parser_t, after yaml_mark_t) b
 	return true
 }
 
-func yaml_parser_scan_footer_comment(parser *yaml_parser_t, after yaml_mark_t) bool {
+func yaml_parser_scan_foot_comment(parser *yaml_parser_t, after yaml_mark_t) bool {
 	parser.comments = append(parser.comments, yaml_comment_t{after: after})
-	comment := &parser.comments[len(parser.comments)-1].footer
+	comment := &parser.comments[len(parser.comments)-1].foot
 	original := *comment
 	breaks := false
 	peek := 0

+ 1 - 1
sorter.go

@@ -52,7 +52,7 @@ func (l keyList) Less(i, j int) bool {
 		var ai, bi int
 		var an, bn int64
 		if ar[i] == '0' || br[i] == '0' {
-			for j := i-1; j >= 0 && unicode.IsDigit(ar[j]); j-- {
+			for j := i - 1; j >= 0 && unicode.IsDigit(ar[j]); j-- {
 				if ar[j] != '0' {
 					an = 1
 					bn = 1

+ 3 - 3
yaml.go

@@ -437,9 +437,9 @@ func getStructInfo(st reflect.Type) (*structInfo, error) {
 	}
 
 	sinfo = &structInfo{
-		FieldsMap:  fieldsMap,
-		FieldsList: fieldsList,
-		InlineMap:  inlineMap,
+		FieldsMap:          fieldsMap,
+		FieldsList:         fieldsList,
+		InlineMap:          inlineMap,
 		InlineUnmarshalers: inlineUnmarshalers,
 	}
 

+ 13 - 13
yamlh.go

@@ -280,9 +280,9 @@ type yaml_event_t struct {
 	tag_directives []yaml_tag_directive_t
 
 	// The comments
-	header_comment []byte
-	inline_comment []byte
-	footer_comment []byte
+	head_comment []byte
+	line_comment []byte
+	foot_comment []byte
 
 	// The anchor (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT, yaml_ALIAS_EVENT).
 	anchor []byte
@@ -569,9 +569,9 @@ type yaml_parser_t struct {
 
 	// Comments
 
-	header_comment []byte // The current header comments
-	inline_comment []byte // The current inline comments
-	footer_comment []byte // The current footer comments
+	head_comment []byte // The current head comments
+	line_comment []byte // The current line comments
+	foot_comment []byte // The current foot comments
 
 	comments      []yaml_comment_t // The folded comments for all parsed tokens
 	comments_head int
@@ -609,10 +609,10 @@ type yaml_parser_t struct {
 }
 
 type yaml_comment_t struct {
-	after  yaml_mark_t
-	header []byte
-	inline []byte
-	footer []byte
+	after yaml_mark_t
+	head  []byte
+	line  []byte
+	foot  []byte
 }
 
 // Emitter Definitions
@@ -746,9 +746,9 @@ type yaml_emitter_t struct {
 	}
 
 	// Comments
-	header_comment []byte
-	inline_comment []byte
-	footer_comment []byte
+	head_comment []byte
+	line_comment []byte
+	foot_comment []byte
 
 	// Dumper stuff