The last item of object sections is now saved.

This commit is contained in:
Sasha Koshka 2022-08-20 15:22:25 -04:00
parent 5271876196
commit b878017b81
1 changed files with 47 additions and 33 deletions

View File

@ -42,6 +42,7 @@ func (parser *ParsingOperation) parseObjtSection () (
// parse members // parse members
err = parser.parseObjtMembers(section) err = parser.parseObjtMembers(section)
if err != nil { return }
if len(section.members) == 0 { if len(section.members) == 0 {
infoerr.NewError ( infoerr.NewError (
@ -52,6 +53,8 @@ func (parser *ParsingOperation) parseObjtSection () (
return return
} }
// parseObjtMembers parses a list of members for an object section. Indentation
// level is assumed.
func (parser *ParsingOperation) parseObjtMembers ( func (parser *ParsingOperation) parseObjtMembers (
into *ObjtSection, into *ObjtSection,
) ( ) (
@ -62,10 +65,23 @@ func (parser *ParsingOperation) parseObjtMembers (
if !parser.token.Is(lexer.TokenKindIndent) { return } if !parser.token.Is(lexer.TokenKindIndent) { return }
if parser.token.Value().(int) != 1 { return } if parser.token.Value().(int) != 1 { return }
// add member to object section
var member ObjtMember
member, err = parser.parseObjtMember()
into.members[member.name] = member
if err != nil { return }
}
}
// parseObjtMember parses a single member of an object section. Indentation
// level is assumed.
func (parser *ParsingOperation) parseObjtMember () (
member ObjtMember,
err error,
) {
// get permission // get permission
err = parser.nextToken(lexer.TokenKindPermission) err = parser.nextToken(lexer.TokenKindPermission)
if err != nil { return } if err != nil { return }
member := ObjtMember { }
member.permission = parser.token.Value().(types.Permission) member.permission = parser.token.Value().(types.Permission)
// get name // get name
@ -99,7 +115,5 @@ func (parser *ParsingOperation) parseObjtMembers (
if err != nil { return } if err != nil { return }
} }
// add member to object section return
into.members[member.name] = member
}
} }