From e42bad5810b0427f22f9cabe6b59707ff1a3be2e Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Mon, 15 Aug 2022 17:05:57 -0400 Subject: [PATCH] Identifiers can no longer have arguments in them Previously [[something something].something] would have been syntactically correct. This can lead to ugly and cluttered syntax due to violating the one thing per line guideline (that I've forgotten to write down) and would make the parser incredibly convoluded. Member selection in arf is not an operator and should not be treated as such. It would be much better to just use variables for this. --- parser/parser_test.go | 17 +---------------- parser/tree-tostring.go | 2 +- parser/tree.go | 2 +- 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/parser/parser_test.go b/parser/parser_test.go index 4e4a21b..fb2bd17 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -7,7 +7,7 @@ import "testing" func checkTree (modulePath string, correct string, test *testing.T) { tree, err := Parse(modulePath) - if err != io.EOF { + if err != io.EOF && err != nil { test.Log("returned error:") test.Log(err.Error()) test.Fail() @@ -26,21 +26,6 @@ func checkTree (modulePath string, correct string, test *testing.T) { } } -// quickIdentifier returns a simple identifier of names -func quickIdentifier (trail ...string) (identifier Identifier) { - for _, item := range trail { - identifier.trail = append ( - identifier.trail, - Argument { - what: ArgumentKindString, - value: item, - }, - ) - } - - return -} - func TestMeta (test *testing.T) { checkTree ("../tests/parser/meta", `:arf diff --git a/parser/tree-tostring.go b/parser/tree-tostring.go index 8689f6c..7135f0f 100644 --- a/parser/tree-tostring.go +++ b/parser/tree-tostring.go @@ -41,7 +41,7 @@ func (identifier *Identifier) ToString () (output string) { output += "." } - output += trailItem.ToString(0, false) + output += trailItem } return } diff --git a/parser/tree.go b/parser/tree.go index 19a6654..08e61eb 100644 --- a/parser/tree.go +++ b/parser/tree.go @@ -17,7 +17,7 @@ type SyntaxTree struct { // Identifier represents a chain of arguments separated by a dot. type Identifier struct { location file.Location - trail []Argument + trail []string } // TypeKind represents what kind of type a type is