Parse constant access
This commit is contained in:
parent
d568d5efef
commit
7d3074ea2f
|
@ -7,6 +7,7 @@ import "git.tebibyte.media/fspl/fspl/entity"
|
|||
var descriptionExpression = "expression"
|
||||
var startTokensExpression = []lexer.TokenKind {
|
||||
lexer.Ident,
|
||||
lexer.TypeIdent,
|
||||
lexer.LParen,
|
||||
lexer.LBracket,
|
||||
lexer.LBrace,
|
||||
|
@ -95,13 +96,14 @@ func (this *treeParser) parseExpressionRoot () (entity.Expression, error) {
|
|||
if err != nil { return nil, err }
|
||||
|
||||
switch this.Kind() {
|
||||
case lexer.Ident: return this.parseExpressionRootIdent()
|
||||
case lexer.LParen: return this.parseExpressionRootLParen()
|
||||
case lexer.LBracket: return this.parseExpressionRootLBracket()
|
||||
case lexer.LBrace: return this.parseBlock()
|
||||
case lexer.Int: return this.parseLiteralInt()
|
||||
case lexer.Float: return this.parseLiteralFloat()
|
||||
case lexer.String: return this.parseLiteralString()
|
||||
case lexer.Ident: return this.parseExpressionRootIdent()
|
||||
case lexer.TypeIdent: return this.parseConstant()
|
||||
case lexer.LParen: return this.parseExpressionRootLParen()
|
||||
case lexer.LBracket: return this.parseExpressionRootLBracket()
|
||||
case lexer.LBrace: return this.parseBlock()
|
||||
case lexer.Int: return this.parseLiteralInt()
|
||||
case lexer.Float: return this.parseLiteralFloat()
|
||||
case lexer.String: return this.parseLiteralString()
|
||||
}
|
||||
panic(this.bug())
|
||||
}
|
||||
|
@ -155,7 +157,6 @@ func (this *treeParser) parseExpressionRootLParen () (entity.Expression, error)
|
|||
case lexer.Dot: return this.parseLiteralStructCore(pos)
|
||||
default: return this.parseLiteralArrayCore(pos)
|
||||
}
|
||||
panic(this.bug())
|
||||
}
|
||||
|
||||
func (this *treeParser) parseExpressionRootLBracket () (entity.Expression, error) {
|
||||
|
@ -717,3 +718,23 @@ func (this *treeParser) parseFor () (*entity.For, error) {
|
|||
|
||||
return loop, nil
|
||||
}
|
||||
|
||||
func (this *treeParser) parseConstant () (*entity.Constant, error) {
|
||||
err := this.Expect(lexer.TypeIdent)
|
||||
if err != nil { return nil, err }
|
||||
constant := &entity.Constant {
|
||||
Pos: this.Pos(),
|
||||
TypeName: this.Value(),
|
||||
}
|
||||
|
||||
err = this.ExpectNext(lexer.Dot)
|
||||
if err != nil { return nil, err }
|
||||
|
||||
err = this.ExpectNext(lexer.Ident)
|
||||
if err != nil { return nil, err }
|
||||
constant.Pos = constant.Pos.Union(this.Pos())
|
||||
constant.Name = this.Value()
|
||||
|
||||
this.Next()
|
||||
return constant, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue