From 715766edb4c74f9b2b96172c491a0d033a4e3103 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Wed, 24 Aug 2022 18:52:31 -0400 Subject: [PATCH 1/6] Objects can only inherit by specifiying an identifier --- parser/objt.go | 2 +- parser/tree.go | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/parser/objt.go b/parser/objt.go index ec64e08..ca8f2db 100644 --- a/parser/objt.go +++ b/parser/objt.go @@ -33,7 +33,7 @@ func (parser *ParsingOperation) parseObjtSection () ( if err != nil { return } err = parser.nextToken() if err != nil { return } - section.inherits, err = parser.parseType() + section.inherits, err = parser.parseIdentifier() if err != nil { return } err = parser.expect(lexer.TokenKindNewline) if err != nil { return } diff --git a/parser/tree.go b/parser/tree.go index e1f2292..b91976d 100644 --- a/parser/tree.go +++ b/parser/tree.go @@ -191,10 +191,9 @@ type ObjtSection struct { name string // TODO: make this Identifier instead of Type - inherits Type + inherits Identifier permission types.Permission // TODO: order matters here we need to store these in an array - // TODO: add bitfield support (:n) members map[string] ObjtMember } From c470997887ca1719c2896304a43477bbc77d9f92 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Wed, 24 Aug 2022 18:57:07 -0400 Subject: [PATCH 2/6] Did the same thing to interfaces --- parser/face.go | 2 +- parser/tree-tostring.go | 2 +- parser/tree.go | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/parser/face.go b/parser/face.go index 3a53381..ca4a3d2 100644 --- a/parser/face.go +++ b/parser/face.go @@ -32,7 +32,7 @@ func (parser *ParsingOperation) parseFaceSection () ( if err != nil { return } err = parser.nextToken(lexer.TokenKindName) if err != nil { return } - section.inherits = parser.token.Value().(string) + section.inherits, err = parser.parseIdentifier() if err != nil { return } err = parser.nextToken(lexer.TokenKindNewline) if err != nil { return } diff --git a/parser/tree-tostring.go b/parser/tree-tostring.go index 114f681..91667d8 100644 --- a/parser/tree-tostring.go +++ b/parser/tree-tostring.go @@ -367,7 +367,7 @@ func (section *FaceSection) ToString (indent int) (output string) { "face ", section.permission.ToString(), " ", section.name, ":", - section.inherits, "\n") + section.inherits.ToString(), "\n") for _, name := range sortMapKeysAlphabetically(section.behaviors) { behavior := section.behaviors[name] diff --git a/parser/tree.go b/parser/tree.go index b91976d..aec04d4 100644 --- a/parser/tree.go +++ b/parser/tree.go @@ -190,7 +190,6 @@ type ObjtSection struct { location file.Location name string - // TODO: make this Identifier instead of Type inherits Identifier permission types.Permission // TODO: order matters here we need to store these in an array @@ -226,8 +225,7 @@ type FaceBehavior struct { type FaceSection struct { location file.Location name string - // TODO: make this Identifier instead of string - inherits string + inherits Identifier permission types.Permission behaviors map[string] FaceBehavior From 777c8df6a49150eb88af9a5d635fb375a485f86b Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Wed, 24 Aug 2022 18:57:45 -0400 Subject: [PATCH 3/6] Changed the logo color because why not lol --- assets/logo.svg | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/assets/logo.svg b/assets/logo.svg index 04dad09..329ebb4 100644 --- a/assets/logo.svg +++ b/assets/logo.svg @@ -1,8 +1,8 @@ - - - - - - + + + + + + From 067bf2f4df8ceb28ae094ad7e7850b53c50a8ed7 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Wed, 24 Aug 2022 20:09:57 -0400 Subject: [PATCH 4/6] Altered tree so that object members are stored in an array --- lexer/token.go | 2 ++ parser/tree-tostring.go | 4 ++-- parser/tree.go | 3 +-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lexer/token.go b/lexer/token.go index f74e575..06e26c3 100644 --- a/lexer/token.go +++ b/lexer/token.go @@ -45,6 +45,8 @@ const ( TokenKindPercent TokenKindTilde + // TODO: add equal to, less than or equal to, greater than or equal to, + // not equal to TokenKindLessThan TokenKindLShift TokenKindGreaterThan diff --git a/parser/tree-tostring.go b/parser/tree-tostring.go index 91667d8..4ce9a14 100644 --- a/parser/tree-tostring.go +++ b/parser/tree-tostring.go @@ -327,8 +327,8 @@ func (section *ObjtSection) ToString (indent int) (output string) { section.name, ":", section.inherits.ToString(), "\n") - for _, name := range sortMapKeysAlphabetically(section.members) { - output += section.members[name].ToString(indent + 1) + for _, member := range section.members { + output += member.ToString(indent + 1) } return } diff --git a/parser/tree.go b/parser/tree.go index aec04d4..8d247c7 100644 --- a/parser/tree.go +++ b/parser/tree.go @@ -192,8 +192,7 @@ type ObjtSection struct { inherits Identifier permission types.Permission - // TODO: order matters here we need to store these in an array - members map[string] ObjtMember + members []ObjtMember } type EnumMember struct { From cd528552c866afd5556a3a1cf3de5e946a213a56 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Wed, 24 Aug 2022 20:19:14 -0400 Subject: [PATCH 5/6] Object sections now parse members into array --- parser/objt.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/parser/objt.go b/parser/objt.go index ca8f2db..255881b 100644 --- a/parser/objt.go +++ b/parser/objt.go @@ -13,10 +13,7 @@ func (parser *ParsingOperation) parseObjtSection () ( err = parser.expect(lexer.TokenKindName) if err != nil { return } - section = &ObjtSection { - location: parser.token.Location(), - members: make(map[string] ObjtMember), - } + section = &ObjtSection { location: parser.token.Location() } // get permission err = parser.nextToken(lexer.TokenKindPermission) @@ -68,7 +65,7 @@ func (parser *ParsingOperation) parseObjtMembers ( // add member to object section var member ObjtMember member, err = parser.parseObjtMember() - into.members[member.name] = member + into.members = append(into.members, member) if err != nil { return } } } From 89a60e620e4cef719ea143890b083081d4afb720 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Wed, 24 Aug 2022 20:20:55 -0400 Subject: [PATCH 6/6] Altered objt section test case to not be alphabetically organized --- parser/objt_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/parser/objt_test.go b/parser/objt_test.go index 16a5439..4490f38 100644 --- a/parser/objt_test.go +++ b/parser/objt_test.go @@ -13,17 +13,17 @@ objt ro BitFields:Obj ro that:Int & 1 ro this:Int & 24 298 objt ro ComplexInit:Obj - ro basic:Int 87 + ro whatever:{Int 3} + 230984 + 849 + 394580 ro complex0:Bird .that 98 .this 2 ro complex1:Bird .that 98902 .this 235 - ro whatever:{Int 3} - 230984 - 849 - 394580 + ro basic:Int 87 objt ro Init:Obj ro that:String "hello world" ro this:Int 23