alter-fixed-array-syntax #3

Merged
sashakoshka merged 6 commits from alter-fixed-array-syntax into main 2022-09-05 09:39:27 -06:00
3 changed files with 31 additions and 30 deletions
Showing only changes of commit 5127b80630 - Show all commits

View File

@ -15,37 +15,37 @@ func (parser *ParsingOperation) parseBody () (err error) {
section, parseErr := parser.parseDataSection()
err = parser.tree.addSection(section)
if err != nil { return }
if parseErr != nil { return }
if parseErr != nil { return parseErr }
case "type":
section, parseErr := parser.parseTypeSection()
err = parser.tree.addSection(section)
if err != nil { return }
if parseErr != nil { return }
if parseErr != nil { return parseErr }
case "objt":
section, parseErr := parser.parseObjtSection()
err = parser.tree.addSection(section)
if err != nil { return }
if parseErr != nil { return }
if parseErr != nil { return parseErr }
case "face":
section, parseErr := parser.parseFaceSection()
err = parser.tree.addSection(section)
if err != nil { return }
if parseErr != nil { return }
if parseErr != nil { return parseErr }
case "enum":
section, parseErr := parser.parseEnumSection()
err = parser.tree.addSection(section)
if err != nil { return }
if parseErr != nil { return }
if parseErr != nil { return parseErr }
case "func":
section, parseErr := parser.parseFuncSection()
err = parser.tree.addSection(section)
if err != nil { return }
if parseErr != nil { return }
if parseErr != nil { return parseErr }
default:
err = parser.token.NewError (

View File

@ -25,15 +25,15 @@ data ro gIntegerArrayInitialized:Int:16
4785
92
data ro jObject:thing.Thing.thing.thing
.this 324
.that 2139
.this 324
data ro kNestedObject:Obj
.this
.bird0 324
.bird1 "hello world"
.that
.bird2 123.8439
.bird3 9328.21348239
.this
.bird0 324
.bird1 "hello world"
data ro lMutIntegerArray16:Int:16:mut
data ro mIntegerArrayInitialized:Int:16:mut
3948

View File

@ -44,19 +44,11 @@ func (parser *ParsingOperation) parseType () (what Type, err error) {
what.points = &points
err = parser.expect (
lexer.TokenKindUInt,
lexer.TokenKindRBrace,
lexer.TokenKindElipsis)
if err != nil { return }
if parser.token.Is(lexer.TokenKindUInt) {
what.kind = TypeKindArray
what.length = parser.token.Value().(uint64)
err = parser.nextToken(lexer.TokenKindRBrace)
if err != nil { return }
} else if parser.token.Is(lexer.TokenKindElipsis) {
if parser.token.Is(lexer.TokenKindElipsis) {
what.kind = TypeKindVariableArray
err = parser.nextToken(lexer.TokenKindRBrace)
@ -70,19 +62,28 @@ func (parser *ParsingOperation) parseType () (what Type, err error) {
if err != nil { return }
}
if parser.token.Is(lexer.TokenKindColon) {
err = parser.nextToken(lexer.TokenKindName)
for {
if !parser.token.Is(lexer.TokenKindColon) { break }
err = parser.nextToken(lexer.TokenKindName, lexer.TokenKindUInt)
if err != nil { return }
qualifier := parser.token.Value().(string)
switch qualifier {
case "mut":
what.mutable = true
default:
err = parser.token.NewError (
"unknown type qualifier \"" + qualifier + "\"",
infoerr.ErrorKindError)
return
if parser.token.Is(lexer.TokenKindName) {
// parse type qualifier
qualifier := parser.token.Value().(string)
switch qualifier {
case "mut":
what.mutable = true
default:
err = parser.token.NewError (
"unknown type qualifier \"" +
qualifier + "\"",
infoerr.ErrorKindError)
return
}
} else {
// parse fixed array length
what.length = parser.token.Value().(uint64)
}
err = parser.nextToken()