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

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,
) ( ) (
@ -61,45 +64,56 @@ func (parser *ParsingOperation) parseObjtMembers (
// if we've left the block, stop parsing // if we've left the block, stop parsing
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 }
// get permission // add member to object section
err = parser.nextToken(lexer.TokenKindPermission) var member ObjtMember
member, err = parser.parseObjtMember()
into.members[member.name] = member
if err != nil { return } if err != nil { return }
member := ObjtMember { } }
member.permission = parser.token.Value().(types.Permission) }
// get name // parseObjtMember parses a single member of an object section. Indentation
err = parser.nextToken(lexer.TokenKindName) // level is assumed.
func (parser *ParsingOperation) parseObjtMember () (
member ObjtMember,
err error,
) {
// get permission
err = parser.nextToken(lexer.TokenKindPermission)
if err != nil { return }
member.permission = parser.token.Value().(types.Permission)
// get name
err = parser.nextToken(lexer.TokenKindName)
if err != nil { return }
member.name = parser.token.Value().(string)
// get type
err = parser.nextToken(lexer.TokenKindColon)
if err != nil { return }
err = parser.nextToken()
if err != nil { return }
member.what, err = parser.parseType()
if err != nil { return }
// parse default value
if parser.token.Is(lexer.TokenKindNewline) {
err = parser.nextToken()
if err != nil { return } if err != nil { return }
member.name = parser.token.Value().(string)
// get type member.defaultValue,
err = parser.nextToken(lexer.TokenKindColon) err = parser.parseInitializationValues(1)
if err != nil { return }
} else {
member.defaultValue, err = parser.parseArgument()
if err != nil { return }
err = parser.expect(lexer.TokenKindNewline)
if err != nil { return } if err != nil { return }
err = parser.nextToken() err = parser.nextToken()
if err != nil { return } if err != nil { return }
member.what, err = parser.parseType()
if err != nil { return }
// parse default value
if parser.token.Is(lexer.TokenKindNewline) {
err = parser.nextToken()
if err != nil { return }
member.defaultValue,
err = parser.parseInitializationValues(1)
if err != nil { return }
} else {
member.defaultValue, err = parser.parseArgument()
if err != nil { return }
err = parser.expect(lexer.TokenKindNewline)
if err != nil { return }
err = parser.nextToken()
if err != nil { return }
}
// add member to object section
into.members[member.name] = member
} }
return
} }