diff --git a/parser/dereference.go b/parser/dereference.go index ce132cf..55d55e5 100644 --- a/parser/dereference.go +++ b/parser/dereference.go @@ -1,12 +1,32 @@ package parser -// import "git.tebibyte.media/arf/arf/lexer" +import "git.tebibyte.media/arf/arf/lexer" // import "git.tebibyte.media/arf/arf/infoerr" func (parser *ParsingOperation) parseDereference () ( dereference Dereference, err error, ) { - // TODO + err = parser.expect(lexer.TokenKindLBrace) + if err != nil { return } + dereference.location = parser.token.Location() + + // parse the value we are dereferencing + err = parser.nextToken(validArgumentStartTokens...) + if err != nil { return } + dereference.argument, err = parser.parseArgument() + if err != nil { return } + + // if there is an offset, parse it + err = parser.expect(lexer.TokenKindUInt, lexer.TokenKindLBrace) + if err != nil { return } + if parser.token.Is(lexer.TokenKindUInt) { + dereference.offset = parser.token.Value().(uint64) + } + + err = parser.nextToken(lexer.TokenKindLBrace) + if err != nil { return } + err = parser.nextToken() + if err != nil { return } return } diff --git a/parser/tree.go b/parser/tree.go index 92bfb34..64c4f01 100644 --- a/parser/tree.go +++ b/parser/tree.go @@ -224,7 +224,7 @@ type Dereference struct { valuable // if a simple dereference was parsed, this should just be zero. - offset int + offset uint64 } // PhraseKind determines what semantic role a phrase plays.