diff --git a/example/helloworld.lang b/example/helloworld.lang index 172cd50..559e40e 100644 --- a/example/helloworld.lang +++ b/example/helloworld.lang @@ -1,7 +1,7 @@ import lang.stdlib; (u8, u8) a(u8 a, u8 b) { - bool a = true; + bool c = true; return a, b; } diff --git a/parser.go b/parser.go index 62947d3..03631c6 100644 --- a/parser.go +++ b/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") }