Update yaml parser
Mark the top level Loglevel field as deprecated Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
parent
94deea2951
commit
f0ee5720a5
19 changed files with 855 additions and 492 deletions
72
vendor/gopkg.in/yaml.v2/scannerc.go
generated
vendored
72
vendor/gopkg.in/yaml.v2/scannerc.go
generated
vendored
|
@ -9,7 +9,7 @@ import (
|
|||
// ************
|
||||
//
|
||||
// The following notes assume that you are familiar with the YAML specification
|
||||
// (http://yaml.org/spec/cvs/current.html). We mostly follow it, although in
|
||||
// (http://yaml.org/spec/1.2/spec.html). We mostly follow it, although in
|
||||
// some cases we are less restrictive that it requires.
|
||||
//
|
||||
// The process of transforming a YAML stream into a sequence of events is
|
||||
|
@ -611,7 +611,7 @@ func yaml_parser_set_scanner_tag_error(parser *yaml_parser_t, directive bool, co
|
|||
if directive {
|
||||
context = "while parsing a %TAG directive"
|
||||
}
|
||||
return yaml_parser_set_scanner_error(parser, context, context_mark, "did not find URI escaped octet")
|
||||
return yaml_parser_set_scanner_error(parser, context, context_mark, problem)
|
||||
}
|
||||
|
||||
func trace(args ...interface{}) func() {
|
||||
|
@ -871,12 +871,6 @@ func yaml_parser_save_simple_key(parser *yaml_parser_t) bool {
|
|||
|
||||
required := parser.flow_level == 0 && parser.indent == parser.mark.column
|
||||
|
||||
// A simple key is required only when it is the first token in the current
|
||||
// line. Therefore it is always allowed. But we add a check anyway.
|
||||
if required && !parser.simple_key_allowed {
|
||||
panic("should not happen")
|
||||
}
|
||||
|
||||
//
|
||||
// If the current position may start a simple key, save it.
|
||||
//
|
||||
|
@ -961,7 +955,7 @@ func yaml_parser_roll_indent(parser *yaml_parser_t, column, number int, typ yaml
|
|||
}
|
||||
|
||||
// Pop indentation levels from the indents stack until the current level
|
||||
// becomes less or equal to the column. For each intendation level, append
|
||||
// becomes less or equal to the column. For each indentation level, append
|
||||
// the BLOCK-END token.
|
||||
func yaml_parser_unroll_indent(parser *yaml_parser_t, column int) bool {
|
||||
// In the flow context, do nothing.
|
||||
|
@ -969,7 +963,7 @@ func yaml_parser_unroll_indent(parser *yaml_parser_t, column int) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
// Loop through the intendation levels in the stack.
|
||||
// Loop through the indentation levels in the stack.
|
||||
for parser.indent > column {
|
||||
// Create a token and append it to the queue.
|
||||
token := yaml_token_t{
|
||||
|
@ -1546,7 +1540,7 @@ func yaml_parser_scan_directive(parser *yaml_parser_t, token *yaml_token_t) bool
|
|||
// Unknown directive.
|
||||
} else {
|
||||
yaml_parser_set_scanner_error(parser, "while scanning a directive",
|
||||
start_mark, "found uknown directive name")
|
||||
start_mark, "found unknown directive name")
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -1944,7 +1938,7 @@ func yaml_parser_scan_tag_handle(parser *yaml_parser_t, directive bool, start_ma
|
|||
} else {
|
||||
// It's either the '!' tag or not really a tag handle. If it's a %TAG
|
||||
// directive, it's an error. If it's a tag token, it must be a part of URI.
|
||||
if directive && !(s[0] == '!' && s[1] == 0) {
|
||||
if directive && string(s) != "!" {
|
||||
yaml_parser_set_scanner_tag_error(parser, directive,
|
||||
start_mark, "did not find expected '!'")
|
||||
return false
|
||||
|
@ -1959,6 +1953,7 @@ func yaml_parser_scan_tag_handle(parser *yaml_parser_t, directive bool, start_ma
|
|||
func yaml_parser_scan_tag_uri(parser *yaml_parser_t, directive bool, head []byte, start_mark yaml_mark_t, uri *[]byte) bool {
|
||||
//size_t length = head ? strlen((char *)head) : 0
|
||||
var s []byte
|
||||
hasTag := len(head) > 0
|
||||
|
||||
// Copy the head if needed.
|
||||
//
|
||||
|
@ -2000,10 +1995,10 @@ func yaml_parser_scan_tag_uri(parser *yaml_parser_t, directive bool, head []byte
|
|||
if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
|
||||
return false
|
||||
}
|
||||
hasTag = true
|
||||
}
|
||||
|
||||
// Check if the tag is non-empty.
|
||||
if len(s) == 0 {
|
||||
if !hasTag {
|
||||
yaml_parser_set_scanner_tag_error(parser, directive,
|
||||
start_mark, "did not find expected tag URI")
|
||||
return false
|
||||
|
@ -2085,14 +2080,14 @@ func yaml_parser_scan_block_scalar(parser *yaml_parser_t, token *yaml_token_t, l
|
|||
return false
|
||||
}
|
||||
if is_digit(parser.buffer, parser.buffer_pos) {
|
||||
// Check that the intendation is greater than 0.
|
||||
// Check that the indentation is greater than 0.
|
||||
if parser.buffer[parser.buffer_pos] == '0' {
|
||||
yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
|
||||
start_mark, "found an intendation indicator equal to 0")
|
||||
start_mark, "found an indentation indicator equal to 0")
|
||||
return false
|
||||
}
|
||||
|
||||
// Get the intendation level and eat the indicator.
|
||||
// Get the indentation level and eat the indicator.
|
||||
increment = as_digit(parser.buffer, parser.buffer_pos)
|
||||
skip(parser)
|
||||
}
|
||||
|
@ -2102,7 +2097,7 @@ func yaml_parser_scan_block_scalar(parser *yaml_parser_t, token *yaml_token_t, l
|
|||
|
||||
if parser.buffer[parser.buffer_pos] == '0' {
|
||||
yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
|
||||
start_mark, "found an intendation indicator equal to 0")
|
||||
start_mark, "found an indentation indicator equal to 0")
|
||||
return false
|
||||
}
|
||||
increment = as_digit(parser.buffer, parser.buffer_pos)
|
||||
|
@ -2157,7 +2152,7 @@ func yaml_parser_scan_block_scalar(parser *yaml_parser_t, token *yaml_token_t, l
|
|||
|
||||
end_mark := parser.mark
|
||||
|
||||
// Set the intendation level if it was specified.
|
||||
// Set the indentation level if it was specified.
|
||||
var indent int
|
||||
if increment > 0 {
|
||||
if parser.indent >= 0 {
|
||||
|
@ -2217,7 +2212,7 @@ func yaml_parser_scan_block_scalar(parser *yaml_parser_t, token *yaml_token_t, l
|
|||
|
||||
leading_break = read_line(parser, leading_break)
|
||||
|
||||
// Eat the following intendation spaces and line breaks.
|
||||
// Eat the following indentation spaces and line breaks.
|
||||
if !yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark) {
|
||||
return false
|
||||
}
|
||||
|
@ -2245,15 +2240,15 @@ func yaml_parser_scan_block_scalar(parser *yaml_parser_t, token *yaml_token_t, l
|
|||
return true
|
||||
}
|
||||
|
||||
// Scan intendation spaces and line breaks for a block scalar. Determine the
|
||||
// intendation level if needed.
|
||||
// Scan indentation spaces and line breaks for a block scalar. Determine the
|
||||
// indentation level if needed.
|
||||
func yaml_parser_scan_block_scalar_breaks(parser *yaml_parser_t, indent *int, breaks *[]byte, start_mark yaml_mark_t, end_mark *yaml_mark_t) bool {
|
||||
*end_mark = parser.mark
|
||||
|
||||
// Eat the intendation spaces and line breaks.
|
||||
// Eat the indentation spaces and line breaks.
|
||||
max_indent := 0
|
||||
for {
|
||||
// Eat the intendation spaces.
|
||||
// Eat the indentation spaces.
|
||||
if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
|
||||
return false
|
||||
}
|
||||
|
@ -2267,10 +2262,10 @@ func yaml_parser_scan_block_scalar_breaks(parser *yaml_parser_t, indent *int, br
|
|||
max_indent = parser.mark.column
|
||||
}
|
||||
|
||||
// Check for a tab character messing the intendation.
|
||||
// Check for a tab character messing the indentation.
|
||||
if (*indent == 0 || parser.mark.column < *indent) && is_tab(parser.buffer, parser.buffer_pos) {
|
||||
return yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
|
||||
start_mark, "found a tab character where an intendation space is expected")
|
||||
start_mark, "found a tab character where an indentation space is expected")
|
||||
}
|
||||
|
||||
// Have we found a non-empty line?
|
||||
|
@ -2474,6 +2469,10 @@ func yaml_parser_scan_flow_scalar(parser *yaml_parser_t, token *yaml_token_t, si
|
|||
}
|
||||
}
|
||||
|
||||
if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Check if we are at the end of the scalar.
|
||||
if single {
|
||||
if parser.buffer[parser.buffer_pos] == '\'' {
|
||||
|
@ -2486,10 +2485,6 @@ func yaml_parser_scan_flow_scalar(parser *yaml_parser_t, token *yaml_token_t, si
|
|||
}
|
||||
|
||||
// Consume blank characters.
|
||||
if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
|
||||
return false
|
||||
}
|
||||
|
||||
for is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos) {
|
||||
if is_blank(parser.buffer, parser.buffer_pos) {
|
||||
// Consume a space or a tab character.
|
||||
|
@ -2591,19 +2586,10 @@ func yaml_parser_scan_plain_scalar(parser *yaml_parser_t, token *yaml_token_t) b
|
|||
// Consume non-blank characters.
|
||||
for !is_blankz(parser.buffer, parser.buffer_pos) {
|
||||
|
||||
// Check for 'x:x' in the flow context. TODO: Fix the test "spec-08-13".
|
||||
if parser.flow_level > 0 &&
|
||||
parser.buffer[parser.buffer_pos] == ':' &&
|
||||
!is_blankz(parser.buffer, parser.buffer_pos+1) {
|
||||
yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
|
||||
start_mark, "found unexpected ':'")
|
||||
return false
|
||||
}
|
||||
|
||||
// Check for indicators that may end a plain scalar.
|
||||
if (parser.buffer[parser.buffer_pos] == ':' && is_blankz(parser.buffer, parser.buffer_pos+1)) ||
|
||||
(parser.flow_level > 0 &&
|
||||
(parser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == ':' ||
|
||||
(parser.buffer[parser.buffer_pos] == ',' ||
|
||||
parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == '[' ||
|
||||
parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '{' ||
|
||||
parser.buffer[parser.buffer_pos] == '}')) {
|
||||
|
@ -2655,10 +2641,10 @@ func yaml_parser_scan_plain_scalar(parser *yaml_parser_t, token *yaml_token_t) b
|
|||
for is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos) {
|
||||
if is_blank(parser.buffer, parser.buffer_pos) {
|
||||
|
||||
// Check for tab character that abuse intendation.
|
||||
// Check for tab characters that abuse indentation.
|
||||
if leading_blanks && parser.mark.column < indent && is_tab(parser.buffer, parser.buffer_pos) {
|
||||
yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
|
||||
start_mark, "found a tab character that violate intendation")
|
||||
start_mark, "found a tab character that violates indentation")
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -2687,7 +2673,7 @@ func yaml_parser_scan_plain_scalar(parser *yaml_parser_t, token *yaml_token_t) b
|
|||
}
|
||||
}
|
||||
|
||||
// Check intendation level.
|
||||
// Check indentation level.
|
||||
if parser.flow_level == 0 && parser.mark.column < indent {
|
||||
break
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue