toml: simplify bool keys in scanner and parser (#12625)
parent
1b691e7612
commit
f50f409ad7
|
@ -463,7 +463,7 @@ pub fn (mut p Parser) root_table() ? {
|
||||||
util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'skipping formatting "$p.tok.kind" "$p.tok.lit"')
|
util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'skipping formatting "$p.tok.kind" "$p.tok.lit"')
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
.bare, .quoted, .boolean, .number, .minus, .underscore { // NOTE .boolean allows for use of "true" and "false" as table keys
|
.bare, .quoted, .number, .minus, .underscore {
|
||||||
// Peek forward as far as we can skipping over space formatting tokens.
|
// Peek forward as far as we can skipping over space formatting tokens.
|
||||||
peek_tok, _ := p.peek_over(1, parser.keys_and_space_formatting) ?
|
peek_tok, _ := p.peek_over(1, parser.keys_and_space_formatting) ?
|
||||||
|
|
||||||
|
@ -652,7 +652,7 @@ pub fn (mut p Parser) table_contents(mut tbl map[string]ast.Value) ? {
|
||||||
util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'skipping formatting "$p.tok.kind" "$p.tok.lit"')
|
util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'skipping formatting "$p.tok.kind" "$p.tok.lit"')
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
.bare, .quoted, .boolean, .number, .minus, .underscore { // NOTE .boolean allows for use of "true" and "false" as table keys
|
.bare, .quoted, .number, .minus, .underscore {
|
||||||
// Peek forward as far as we can skipping over space formatting tokens.
|
// Peek forward as far as we can skipping over space formatting tokens.
|
||||||
peek_tok, _ := p.peek_over(1, parser.keys_and_space_formatting) ?
|
peek_tok, _ := p.peek_over(1, parser.keys_and_space_formatting) ?
|
||||||
|
|
||||||
|
@ -735,7 +735,7 @@ pub fn (mut p Parser) inline_table(mut tbl map[string]ast.Value) ? {
|
||||||
// '}' bracket
|
// '}' bracket
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
.bare, .quoted, .boolean, .number, .minus, .underscore {
|
.bare, .quoted, .number, .minus, .underscore {
|
||||||
// Peek forward as far as we can skipping over space formatting tokens.
|
// Peek forward as far as we can skipping over space formatting tokens.
|
||||||
peek_tok, _ := p.peek_over(1, parser.space_formatting) ?
|
peek_tok, _ := p.peek_over(1, parser.space_formatting) ?
|
||||||
|
|
||||||
|
@ -836,7 +836,7 @@ pub fn (mut p Parser) array_of_tables_contents() ?[]ast.Value {
|
||||||
util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'parsing token "$p.tok.kind"')
|
util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'parsing token "$p.tok.kind"')
|
||||||
|
|
||||||
match p.tok.kind {
|
match p.tok.kind {
|
||||||
.bare, .quoted, .boolean, .number, .minus, .underscore {
|
.bare, .quoted, .number, .minus, .underscore {
|
||||||
// Peek forward as far as we can skipping over space formatting tokens.
|
// Peek forward as far as we can skipping over space formatting tokens.
|
||||||
peek_tok, _ := p.peek_over(1, parser.space_formatting) ?
|
peek_tok, _ := p.peek_over(1, parser.space_formatting) ?
|
||||||
|
|
||||||
|
@ -972,7 +972,7 @@ pub fn (mut p Parser) double_array_of_tables_contents(target_key DottedKey) ?[]a
|
||||||
}
|
}
|
||||||
|
|
||||||
match p.tok.kind {
|
match p.tok.kind {
|
||||||
.bare, .quoted, .boolean, .number, .minus, .underscore {
|
.bare, .quoted, .number, .minus, .underscore {
|
||||||
// Peek forward as far as we can skipping over space formatting tokens.
|
// Peek forward as far as we can skipping over space formatting tokens.
|
||||||
peek_tok, _ = p.peek_over(1, parser.space_formatting) ?
|
peek_tok, _ = p.peek_over(1, parser.space_formatting) ?
|
||||||
|
|
||||||
|
|
|
@ -125,8 +125,7 @@ pub fn (mut s Scanner) scan() ?token.Token {
|
||||||
|
|
||||||
if util.is_key_char(byte_c) {
|
if util.is_key_char(byte_c) {
|
||||||
key := s.extract_key()
|
key := s.extract_key()
|
||||||
key_lower_case := key.to_lower()
|
if !s.is_left_of_assign && (key == 'true' || key == 'false') {
|
||||||
if key_lower_case == 'true' || key_lower_case == 'false' {
|
|
||||||
util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'identified a boolean "$key" ($key.len)')
|
util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'identified a boolean "$key" ($key.len)')
|
||||||
return s.new_token(.boolean, key, key.len)
|
return s.new_token(.boolean, key, key.len)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue