Changed bit field syntax to use an & symbol

This commit is contained in:
Sasha Koshka 2022-08-24 18:37:44 -04:00
parent 731cc828ce
commit e316eb7791
4 changed files with 8 additions and 6 deletions

View File

@ -97,8 +97,10 @@ func (parser *ParsingOperation) parseObjtMember () (
member.what, err = parser.parseType()
if err != nil { return }
println(parser.token.Describe())
// if there is a bit width, get it
if parser.token.Is(lexer.TokenKindColon) {
if parser.token.Is(lexer.TokenKindBinaryAnd) {
err = parser.nextToken(lexer.TokenKindUInt)
if err != nil { return }
member.bitWidth = parser.token.Value().(uint64)

View File

@ -10,8 +10,8 @@ objt ro Basic:Obj
ro that:Basic
ro this:Basic
objt ro BitFields:Obj
ro that:Int:1
ro this:Int:24
ro that:Int & 1
ro this:Int & 24 298
objt ro ComplexInit:Obj
ro basic:Int 87
ro complex0:Bird

View File

@ -299,7 +299,7 @@ func (member ObjtMember) ToString (indent int) (output string) {
output += member.what.ToString()
if member.bitWidth > 0 {
output += fmt.Sprint(":", member.bitWidth)
output += fmt.Sprint(" & ", member.bitWidth)
}
isComplexInitialization :=

View File

@ -5,8 +5,8 @@ objt ro Basic:Obj
ro this:Basic
objt ro BitFields:Obj
ro that:Int:1
ro this:Int:24 298
ro that:Int & 1
ro this:Int & 24 298
objt ro Init:Obj
ro that:String "hello world"