Merge pull request 'tree-cleanup' (#9) from tree-cleanup into main

Reviewed-on: #9
main
Sasha Koshka 5 months ago
commit e74aff3299

@ -1,8 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 288 80" width="288" height="80">
<path d="M48 0L112 0L112 32L96 32L96 16L56 16L40 32L16 32L48 0Z" fill="#bf616a" fill-rule="evenodd" opacity="1" stroke="none"/>
<path d="M96 64L136 64L136 80L104 80L96 72L96 64Z" fill="#bf616a" fill-rule="evenodd" opacity="1" stroke="none"/>
<path d="M120 0L120 32L136 32L136 16L184 16L184 32L176 40L8 40L0 48L0 56L184 56L200 40L200 32L200 0L120 0Z" fill="#bf616a" fill-rule="evenodd" opacity="1" stroke="none"/>
<path d="M191 61L204 48L236 80L210 80L191 61Z" fill="#bf616a" fill-rule="evenodd" opacity="1" stroke="none"/>
<path d="M256 40L208 40L224 56L256 56L256 40Z" fill="#bf616a" fill-rule="evenodd" opacity="1" stroke="none"/>
<path d="M208 0L288 0L288 16L224 16L224 32L208 32L208 0Z" fill="#bf616a" fill-rule="evenodd" opacity="1" stroke="none"/>
<path d="M48 0L112 0L112 32L96 32L96 16L56 16L40 32L16 32L48 0Z" fill="#b81414" fill-rule="evenodd" opacity="1" stroke="none"/>
<path d="M96 64L136 64L136 80L104 80L96 72L96 64Z" fill="#b81414" fill-rule="evenodd" opacity="1" stroke="none"/>
<path d="M120 0L120 32L136 32L136 16L184 16L184 32L176 40L8 40L0 48L0 56L184 56L200 40L200 32L200 0L120 0Z" fill="#b81414" fill-rule="evenodd" opacity="1" stroke="none"/>
<path d="M191 61L204 48L236 80L210 80L191 61Z" fill="#b81414" fill-rule="evenodd" opacity="1" stroke="none"/>
<path d="M256 40L208 40L224 56L256 56L256 40Z" fill="#b81414" fill-rule="evenodd" opacity="1" stroke="none"/>
<path d="M208 0L288 0L288 16L224 16L224 32L208 32L208 0Z" fill="#b81414" fill-rule="evenodd" opacity="1" stroke="none"/>
</svg>

Before

Width:  |  Height:  |  Size: 847 B

After

Width:  |  Height:  |  Size: 847 B

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

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

@ -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)
@ -33,7 +30,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 }
@ -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 }
}
}

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

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

@ -190,12 +190,9 @@ type ObjtSection struct {
location file.Location
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
members []ObjtMember
}
type EnumMember struct {
@ -227,8 +224,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