From 9921897aa6358a442b0e9599e6779e813e523a80 Mon Sep 17 00:00:00 2001 From: Joe Conigliaro Date: Thu, 5 Mar 2020 22:44:33 +1100 Subject: [PATCH] v2: add some comments in parser & checker --- vlib/v/checker/checker.v | 3 +++ vlib/v/parser/parser.v | 8 +++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index bba837353b..9566ab0a0a 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -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) } diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 8b773926ba..10fb9b2471 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -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