Add expression statements
This commit is contained in:
parent
63ccacba2d
commit
e4c158875e
@ -1,7 +1,7 @@
|
||||
import lang.stdlib;
|
||||
|
||||
(u8, u8) a(u8 a, u8 b) {
|
||||
bool a = true;
|
||||
bool c = true;
|
||||
return a, b;
|
||||
}
|
||||
|
||||
|
14
parser.go
14
parser.go
@ -719,6 +719,20 @@ func (p *Parser) expectStatement() (*Statement, error) {
|
||||
return stmt, nil
|
||||
}
|
||||
|
||||
expr, err := p.tryExpression()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if expr != nil {
|
||||
_, err := p.expectSeparator(Separator_Semicolon)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Statement{Type: Statement_Expression, Value: ExpressionStatement{Expression: *expr}}, nil
|
||||
}
|
||||
|
||||
return nil, p.error("expected statement")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user