Skip to content
This repository was archived by the owner on Oct 16, 2022. It is now read-only.

Commit d735809

Browse files
committed
wip
1 parent cccb001 commit d735809

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

parser/statements.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,26 @@ func (p *Parser) parseStmt() ast.Statement {
4848
return nil
4949
case token.Static:
5050
if p.peek().Typ == token.ScopeResolutionOperator {
51+
p.errorf("static keyword outside of class context")
5152
expr := p.parseExpression()
5253
p.expectStmtEnd()
5354
return expr
5455
}
56+
5557
s := &ast.StaticVariableDeclaration{Declarations: make([]ast.Dynamic, 0)}
5658
for {
57-
p.expect(token.VariableOperator)
58-
p.expect(token.Identifier)
59-
v := ast.NewVariable(p.current.Val)
59+
p.next()
60+
v, ok := p.parseVariable().(*ast.Variable)
61+
if !ok {
62+
p.errorf("global static declaration must be a variable")
63+
return nil
64+
}
65+
66+
if _, ok := v.Name.(*ast.Identifier); !ok {
67+
p.errorf("static variable declarations must not be dynamic")
68+
}
69+
70+
// check if there's an initial assignment
6071
if p.peek().Typ == token.AssignmentOperator {
6172
p.expect(token.AssignmentOperator)
6273
op := p.current.Val

0 commit comments

Comments
 (0)