Removed many cringe pass-by-references

This commit is contained in:
Sasha Koshka 2022-09-04 19:55:47 -04:00
parent f3c72f8f30
commit 691df94ef4
9 changed files with 23 additions and 33 deletions

View File

@ -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 {

View File

@ -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)

View File

@ -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(&section)
if err != nil { return }
if len(section.members) == 0 {

View File

@ -6,15 +6,13 @@ 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.behaviors = make(map[string] FaceBehavior)
section.location = parser.token.Location()
// get permission

View File

@ -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(&section)
if err != nil { return }
// check to see if the function is external

View File

@ -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(&section)
if err != nil { return }
if len(section.members) == 0 {

View File

@ -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 ",

View File

@ -171,8 +171,7 @@ type DataSection struct {
nameable
typeable
permissionable
value Argument
valuable
}
// TypeSection represents a blind type definition.

View File

@ -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