v2: add some comments in parser & checker
parent
6de44db4eb
commit
9921897aa6
|
@ -416,6 +416,7 @@ fn (c mut Checker) stmt(node ast.Stmt) {
|
||||||
for i, expr in it.exprs {
|
for i, expr in it.exprs {
|
||||||
mut field := it.fields[i]
|
mut field := it.fields[i]
|
||||||
typ := c.expr(expr)
|
typ := c.expr(expr)
|
||||||
|
// TODO: once consts are fixed update here
|
||||||
c.table.register_const(table.Var{
|
c.table.register_const(table.Var{
|
||||||
name: field.name
|
name: field.name
|
||||||
typ: typ
|
typ: typ
|
||||||
|
@ -438,6 +439,8 @@ fn (c mut Checker) stmt(node ast.Stmt) {
|
||||||
if !it.is_inf && table.type_idx(typ) != table.bool_type_idx {
|
if !it.is_inf && table.type_idx(typ) != table.bool_type_idx {
|
||||||
c.error('non-bool used as for condition', it.pos)
|
c.error('non-bool used as for condition', it.pos)
|
||||||
}
|
}
|
||||||
|
// TODO: update loop var type
|
||||||
|
// how does this work currenly?
|
||||||
for stmt in it.stmts {
|
for stmt in it.stmts {
|
||||||
c.stmt(stmt)
|
c.stmt(stmt)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1058,10 +1058,6 @@ fn (p mut Parser) for_statement() ast.Stmt {
|
||||||
if p.tok.kind == .comma {
|
if p.tok.kind == .comma {
|
||||||
p.check(.comma)
|
p.check(.comma)
|
||||||
val_name = p.check_name()
|
val_name = p.check_name()
|
||||||
// p.table.register_var(table.Var{
|
|
||||||
// name: val_name
|
|
||||||
// typ: table.int_type
|
|
||||||
// })
|
|
||||||
p.scope.register_var(ast.VarDecl{
|
p.scope.register_var(ast.VarDecl{
|
||||||
name: val_name
|
name: val_name
|
||||||
typ: table.int_type
|
typ: table.int_type
|
||||||
|
@ -1080,9 +1076,10 @@ fn (p mut Parser) for_statement() ast.Stmt {
|
||||||
p.check(.dotdot)
|
p.check(.dotdot)
|
||||||
high_expr = p.expr(0)
|
high_expr = p.expr(0)
|
||||||
}
|
}
|
||||||
|
// TODO: update var type in checker
|
||||||
p.scope.register_var(ast.VarDecl{
|
p.scope.register_var(ast.VarDecl{
|
||||||
name: var_name
|
name: var_name
|
||||||
expr: cond
|
// expr: cond
|
||||||
})
|
})
|
||||||
stmts := p.parse_block()
|
stmts := p.parse_block()
|
||||||
// println('nr stmts=$stmts.len')
|
// println('nr stmts=$stmts.len')
|
||||||
|
@ -1357,6 +1354,7 @@ fn (p mut Parser) const_decl() ast.ConstDecl {
|
||||||
// typ: typ
|
// typ: typ
|
||||||
}
|
}
|
||||||
exprs << expr
|
exprs << expr
|
||||||
|
// TODO: once consts are fixed reg here & update in checker
|
||||||
// p.table.register_const(table.Var{
|
// p.table.register_const(table.Var{
|
||||||
// name: name
|
// name: name
|
||||||
// // typ: typ
|
// // typ: typ
|
||||||
|
|
Loading…
Reference in New Issue