mewmew / uc

A compiler for the µC language.
57 stars 5 forks source link

parser: "error: invalid block statements type; expected []ast.Stmt, got *ast.ExprStmt" #37

Closed mewmew closed 8 years ago

mewmew commented 8 years ago
u@x1 ~/D/g/s/g/m/uc> uparse testdata/quiet/mips/m03.c 
Parsing "testdata/quiet/mips/m03.c"

…

S42 ;(3,;) reduce:58(Expr15 : ident << astx.NewIdent(X[0]) >>)
S61 ;(3,;) reduce:54(Expr14 : Expr15    <<  >>)
S60 ;(3,;) reduce:51(Expr13L : Expr14   <<  >>)
S58 ;(3,;) reduce:48(Expr12L : Expr13L  <<  >>)
S57 ;(3,;) reduce:43(Expr10L : Expr12L  <<  >>)
S56 ;(3,;) reduce:40(Expr9L : Expr10L   <<  >>)
S55 ;(3,;) reduce:38(Expr5L : Expr9L    <<  >>)
S54 ;(3,;) reduce:36(Expr2R : Expr5L    <<  >>)
S53 ;(3,;) reduce:35(Expr : Expr2R  <<  >>)
S86 ;(3,;) shift:156
pos: 91
typ: 14
lit: }

S156 }(14,}) reduce:26(Stmt : "return" Expr ";" << astx.NewReturnStmt(X[1]) >>)
S47 }(14,}) reduce:23(Stmts : empty <<  >>)
S83 }(14,}) reduce:24(Stmts : Stmt Stmts    <<  >>)
S83 }(14,}) reduce:24(Stmts : Stmt Stmts    <<  >>)
S83 }(14,}) reduce:24(Stmts : Stmt Stmts    <<  >>)
S231 }(14,}) shift:272
pos: 95
typ: 16
lit: return

S272 return(16,return) reduce:30(Stmt : "{" Stmts "}"   << astx.NewBlockStmt(X[1]) >>)
2016/04/10 00:45:55 main.parseFile (uparse.go:71): error: Error in S90: return(16,return), Pos(offset=95, line=15, column=10)github.com/mewmew/uc/ast/astx.NewBlockStmt (astx.go:167): error: invalid block statements type; expected []ast.Stmt, got *ast.ExprStmt
mewmew commented 8 years ago

Another issue related to NewBlockStmt:

The following input:

int main(void) {
    {
    }
}

Results in the following error:

S156 }(14,}) reduce:28(Stmt : "{" Stmts "}" << astx.NewBlockStmt(X[1]) >>)
stmts: <nil>
stmts type: <nil>
2016/04/10 00:59:13 main.parseFile (uparse.go:71): error: Error in S38: }(14,}), Pos(offset=23, line=8, column=1)github.com/mewmew/uc/ast/astx.NewBlockStmt (astx.go:173): error: invalid block statements type; expected []ast.Stmt, got <nil>