toml: rename sub_key -> dotted_key (#12383)
parent
b963aff8e8
commit
c3b389cde9
|
@ -291,9 +291,9 @@ pub fn (mut p Parser) find_in_table(mut table map[string]ast.Value, key string)
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
// sub_key parses next tokens as sub/nested keys. This is the also referred to as
|
// dotted_key returns a string of the next tokens parsed as
|
||||||
// a "dotted" key (`a.b.c`). sub_key returns a string in dotted form.
|
// sub/nested/path keys (e.g. `a.b.c`). In TOML, this form of key is referred to as a "dotted" key.
|
||||||
pub fn (mut p Parser) sub_key() ?string {
|
pub fn (mut p Parser) dotted_key() ?string {
|
||||||
util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'parsing nested key...')
|
util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'parsing nested key...')
|
||||||
key := p.key() ?
|
key := p.key() ?
|
||||||
p.ignore_while_peek(parser.space_formatting)
|
p.ignore_while_peek(parser.space_formatting)
|
||||||
|
@ -342,13 +342,13 @@ pub fn (mut p Parser) root_table() ? {
|
||||||
|
|
||||||
if peek_tok.kind == .period {
|
if peek_tok.kind == .period {
|
||||||
p.ignore_while(parser.space_formatting)
|
p.ignore_while(parser.space_formatting)
|
||||||
subkey := p.sub_key() ?
|
dotkey := p.dotted_key() ?
|
||||||
p.ignore_while(parser.space_formatting)
|
p.ignore_while(parser.space_formatting)
|
||||||
p.check(.assign) ?
|
p.check(.assign) ?
|
||||||
p.ignore_while(parser.space_formatting)
|
p.ignore_while(parser.space_formatting)
|
||||||
val := p.value() ?
|
val := p.value() ?
|
||||||
|
|
||||||
sub_table, key := p.sub_table_key(subkey)
|
sub_table, key := p.sub_table_key(dotkey)
|
||||||
|
|
||||||
t := p.find_sub_table(sub_table) ?
|
t := p.find_sub_table(sub_table) ?
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -380,7 +380,7 @@ pub fn (mut p Parser) root_table() ? {
|
||||||
util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'leaving double bracket at "$p.tok.kind" "$p.tok.lit". NEXT is "$p.peek_tok.kind "$p.peek_tok.lit"')
|
util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'leaving double bracket at "$p.tok.kind" "$p.tok.lit". NEXT is "$p.peek_tok.kind "$p.peek_tok.lit"')
|
||||||
} else if peek_tok.kind == .period {
|
} else if peek_tok.kind == .period {
|
||||||
p.ignore_while(parser.space_formatting)
|
p.ignore_while(parser.space_formatting)
|
||||||
p.root_map_key = p.sub_key() ?
|
p.root_map_key = p.dotted_key() ?
|
||||||
p.ignore_while(parser.space_formatting)
|
p.ignore_while(parser.space_formatting)
|
||||||
util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'setting root map key to `$p.root_map_key` at "$p.tok.kind" "$p.tok.lit"')
|
util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'setting root map key to `$p.root_map_key` at "$p.tok.kind" "$p.tok.lit"')
|
||||||
p.expect(.rsbr) ?
|
p.expect(.rsbr) ?
|
||||||
|
@ -462,13 +462,13 @@ pub fn (mut p Parser) inline_table(mut tbl map[string]ast.Value) ? {
|
||||||
|
|
||||||
if peek_tok.kind == .period {
|
if peek_tok.kind == .period {
|
||||||
p.ignore_while(parser.space_formatting)
|
p.ignore_while(parser.space_formatting)
|
||||||
subkey := p.sub_key() ?
|
dotkey := p.dotted_key() ?
|
||||||
p.ignore_while(parser.space_formatting)
|
p.ignore_while(parser.space_formatting)
|
||||||
p.check(.assign) ?
|
p.check(.assign) ?
|
||||||
p.ignore_while(parser.space_formatting)
|
p.ignore_while(parser.space_formatting)
|
||||||
val := p.value() ?
|
val := p.value() ?
|
||||||
|
|
||||||
sub_table, key := p.sub_table_key(subkey)
|
sub_table, key := p.sub_table_key(dotkey)
|
||||||
|
|
||||||
mut t := p.find_in_table(mut tbl, sub_table) ?
|
mut t := p.find_in_table(mut tbl, sub_table) ?
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -614,11 +614,11 @@ pub fn (mut p Parser) array_of_tables_contents() ?[]ast.Value {
|
||||||
mut tbl := map[string]ast.Value{}
|
mut tbl := map[string]ast.Value{}
|
||||||
for p.tok.kind in [.bare, .quoted, .boolean, .number] {
|
for p.tok.kind in [.bare, .quoted, .boolean, .number] {
|
||||||
if p.peek_tok.kind == .period {
|
if p.peek_tok.kind == .period {
|
||||||
subkey := p.sub_key() ?
|
dotkey := p.dotted_key() ?
|
||||||
p.check(.assign) ?
|
p.check(.assign) ?
|
||||||
val := p.value() ?
|
val := p.value() ?
|
||||||
|
|
||||||
sub_table, key := p.sub_table_key(subkey)
|
sub_table, key := p.sub_table_key(dotkey)
|
||||||
|
|
||||||
mut t := p.find_in_table(mut tbl, sub_table) ?
|
mut t := p.find_in_table(mut tbl, sub_table) ?
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
Loading…
Reference in New Issue