1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

v2: add some comments in parser & checker

This commit is contained in:
Joe Conigliaro 2020-03-05 22:44:33 +11:00
parent 6de44db4eb
commit 9921897aa6
2 changed files with 6 additions and 5 deletions

View File

@ -416,6 +416,7 @@ fn (c mut Checker) stmt(node ast.Stmt) {
for i, expr in it.exprs {
mut field := it.fields[i]
typ := c.expr(expr)
// TODO: once consts are fixed update here
c.table.register_const(table.Var{
name: field.name
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 {
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 {
c.stmt(stmt)
}

View File

@ -1058,10 +1058,6 @@ fn (p mut Parser) for_statement() ast.Stmt {
if p.tok.kind == .comma {
p.check(.comma)
val_name = p.check_name()
// p.table.register_var(table.Var{
// name: val_name
// typ: table.int_type
// })
p.scope.register_var(ast.VarDecl{
name: val_name
typ: table.int_type
@ -1080,9 +1076,10 @@ fn (p mut Parser) for_statement() ast.Stmt {
p.check(.dotdot)
high_expr = p.expr(0)
}
// TODO: update var type in checker
p.scope.register_var(ast.VarDecl{
name: var_name
expr: cond
// expr: cond
})
stmts := p.parse_block()
// println('nr stmts=$stmts.len')
@ -1357,6 +1354,7 @@ fn (p mut Parser) const_decl() ast.ConstDecl {
// typ: typ
}
exprs << expr
// TODO: once consts are fixed reg here & update in checker
// p.table.register_const(table.Var{
// name: name
// // typ: typ