diff --git a/parser/body.go b/parser/body.go index cf48d55..15b9092 100644 --- a/parser/body.go +++ b/parser/body.go @@ -3,8 +3,6 @@ package parser import "git.tebibyte.media/arf/arf/lexer" import "git.tebibyte.media/arf/arf/infoerr" -// TODO: parser must ensure that these names are unique - // parse body parses the body of an arf file, after the metadata header. func (parser *ParsingOperation) parseBody () (err error) { for { diff --git a/parser/data.go b/parser/data.go index 9597972..fa19ff0 100644 --- a/parser/data.go +++ b/parser/data.go @@ -5,13 +5,12 @@ import "git.tebibyte.media/arf/arf/lexer" // parseData parses a data section. func (parser *ParsingOperation) parseDataSection () ( - section *DataSection, + section DataSection, err error, ) { err = parser.expect(lexer.TokenKindName) if err != nil { return } - section = &DataSection { } section.location = parser.token.Location() err = parser.nextToken(lexer.TokenKindPermission) diff --git a/parser/enum.go b/parser/enum.go index 228c9f0..9625dc5 100644 --- a/parser/enum.go +++ b/parser/enum.go @@ -6,13 +6,12 @@ import "git.tebibyte.media/arf/arf/infoerr" // parseEnumSection parses an enumerated type section. func (parser *ParsingOperation) parseEnumSection () ( - section *EnumSection, + section EnumSection, err error, ) { err = parser.expect(lexer.TokenKindName) if err != nil { return } - section = &EnumSection { } section.location = parser.token.Location() // get permission @@ -38,7 +37,7 @@ func (parser *ParsingOperation) parseEnumSection () ( if err != nil { return } // parse members - err = parser.parseEnumMembers(section) + err = parser.parseEnumMembers(§ion) if err != nil { return } if len(section.members) == 0 { diff --git a/parser/face.go b/parser/face.go index 65e8372..62f2605 100644 --- a/parser/face.go +++ b/parser/face.go @@ -6,16 +6,14 @@ import "git.tebibyte.media/arf/arf/infoerr" // parseFaceSection parses an interface section. func (parser *ParsingOperation) parseFaceSection () ( - section *FaceSection, + section FaceSection, err error, ) { err = parser.expect(lexer.TokenKindName) if err != nil { return } - section = &FaceSection { - behaviors: make(map[string] FaceBehavior), - } - section.location = parser.token.Location() + section.behaviors = make(map[string] FaceBehavior) + section.location = parser.token.Location() // get permission err = parser.nextToken(lexer.TokenKindPermission) diff --git a/parser/func.go b/parser/func.go index b42fe0e..f6288f5 100644 --- a/parser/func.go +++ b/parser/func.go @@ -6,13 +6,12 @@ import "git.tebibyte.media/arf/arf/infoerr" // parseFunc parses a function section. func (parser *ParsingOperation) parseFuncSection () ( - section *FuncSection, + section FuncSection, err error, ) { err = parser.expect(lexer.TokenKindName) if err != nil { return } - section = &FuncSection { } section.location = parser.token.Location() // get permission @@ -30,7 +29,7 @@ func (parser *ParsingOperation) parseFuncSection () ( if err != nil { return } err = parser.nextToken() if err != nil { return } - err = parser.parseFuncArguments(section) + err = parser.parseFuncArguments(§ion) if err != nil { return } // check to see if the function is external diff --git a/parser/objt.go b/parser/objt.go index ca72df4..1e83e98 100644 --- a/parser/objt.go +++ b/parser/objt.go @@ -7,13 +7,12 @@ import "git.tebibyte.media/arf/arf/infoerr" // parseObjtSection parses an object type definition. This allows for structured // types to be defined, and for member variables to be added and overridden. func (parser *ParsingOperation) parseObjtSection () ( - section *ObjtSection, + section ObjtSection, err error, ) { err = parser.expect(lexer.TokenKindName) if err != nil { return } - section = &ObjtSection { } section.location = parser.token.Location() // get permission @@ -39,7 +38,7 @@ func (parser *ParsingOperation) parseObjtSection () ( if err != nil { return } // parse members - err = parser.parseObjtMembers(section) + err = parser.parseObjtMembers(§ion) if err != nil { return } if len(section.members) == 0 { diff --git a/parser/tree-tostring.go b/parser/tree-tostring.go index c0dfc2e..ddc5ef2 100644 --- a/parser/tree-tostring.go +++ b/parser/tree-tostring.go @@ -30,7 +30,7 @@ func sortMapKeysAlphabetically[KEY_TYPE any] ( return } -func (tree *SyntaxTree) ToString (indent int) (output string) { +func (tree SyntaxTree) ToString (indent int) (output string) { output += doIndent(indent, ":arf\n") if tree.author != "" { @@ -66,7 +66,7 @@ func (identifier Identifier) ToString () (output string) { return } -func (what *Type) ToString () (output string) { +func (what Type) ToString () (output string) { if what.kind == TypeKindBasic { output += what.name.ToString() } else { @@ -130,7 +130,7 @@ func (values ArrayInitializationValues) ToString ( return } -func (argument *Argument) ToString (indent int, breakLine bool) (output string) { +func (argument Argument) ToString (indent int, breakLine bool) (output string) { if !breakLine { indent = 0 } if argument.kind == ArgumentKindNil { output += "NIL-ARGUMENT" @@ -255,7 +255,7 @@ func (argument *Argument) ToString (indent int, breakLine bool) (output string) return } -func (section *DataSection) ToString (indent int) (output string) { +func (section DataSection) ToString (indent int) (output string) { output += doIndent ( indent, "data ", @@ -279,7 +279,7 @@ func (section *DataSection) ToString (indent int) (output string) { return } -func (section *TypeSection) ToString (indent int) (output string) { +func (section TypeSection) ToString (indent int) (output string) { output += doIndent ( indent, "type ", @@ -331,7 +331,7 @@ func (member ObjtMember) ToString (indent int) (output string) { return } -func (section *ObjtSection) ToString (indent int) (output string) { +func (section ObjtSection) ToString (indent int) (output string) { output += doIndent ( indent, "objt ", @@ -345,7 +345,7 @@ func (section *ObjtSection) ToString (indent int) (output string) { return } -func (section *EnumSection) ToString (indent int) (output string) { +func (section EnumSection) ToString (indent int) (output string) { output += doIndent ( indent, "enum ", @@ -373,7 +373,7 @@ func (section *EnumSection) ToString (indent int) (output string) { return } -func (section *FaceSection) ToString (indent int) (output string) { +func (section FaceSection) ToString (indent int) (output string) { output += doIndent ( indent, "face ", @@ -388,7 +388,7 @@ func (section *FaceSection) ToString (indent int) (output string) { return } -func (behavior *FaceBehavior) ToString (indent int) (output string) { +func (behavior FaceBehavior) ToString (indent int) (output string) { output += doIndent(indent, behavior.name, "\n") for _, inputItem := range behavior.inputs { @@ -455,7 +455,7 @@ func (funcOutput FuncOutput) ToString () (output string) { return } -func (section *FuncSection) ToString (indent int) (output string) { +func (section FuncSection) ToString (indent int) (output string) { output += doIndent ( indent, "func ", diff --git a/parser/tree.go b/parser/tree.go index 0a2b953..e51e280 100644 --- a/parser/tree.go +++ b/parser/tree.go @@ -171,8 +171,7 @@ type DataSection struct { nameable typeable permissionable - - value Argument + valuable } // TypeSection represents a blind type definition. @@ -202,7 +201,7 @@ type ObjtSection struct { permissionable inherits Identifier - members []ObjtMember + members []ObjtMember } // EnumMember represents a member of an enum section. diff --git a/parser/type.go b/parser/type.go index a00c8e7..309e543 100644 --- a/parser/type.go +++ b/parser/type.go @@ -6,13 +6,12 @@ import "git.tebibyte.media/arf/arf/lexer" // parseTypeSection parses a blind type definition, meaning it can inherit from // anything including primitives, but cannot define structure. func (parser *ParsingOperation) parseTypeSection () ( - section *TypeSection, + section TypeSection, err error, ) { err = parser.expect(lexer.TokenKindName) if err != nil { return } - section = &TypeSection { } section.location = parser.token.Location() // get permission