mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
minor fixes and cleaning up
This commit is contained in:
@@ -229,7 +229,7 @@ pub fn (p &Parser) error_at_line(s string, line_nr int) {
|
||||
}
|
||||
|
||||
pub fn (p &Parser) warn(s string) {
|
||||
println(term.blue('x.v:$p.tok.line_nr: $s'))
|
||||
println(term.blue('$p.file_name:$p.tok.line_nr: $s'))
|
||||
}
|
||||
|
||||
// Implementation of Pratt Precedence
|
||||
@@ -332,7 +332,7 @@ pub fn (p mut Parser) expr(rbp int) (ast.Expr,types.Type) {
|
||||
typ = t2
|
||||
}
|
||||
else {
|
||||
p.error('!unknown token ' + p.tok.str())
|
||||
p.error('expr(): unknown token ' + p.tok.str() + ' kind=$p.tok.kind')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -342,10 +342,9 @@ pub fn (p mut Parser) expr(rbp int) (ast.Expr,types.Type) {
|
||||
p.next()
|
||||
mut t2 := types.Type{}
|
||||
// left denotation (infix / postfix)
|
||||
if prev_tok.is_right_assoc() &&
|
||||
!p.tok.kind in [.plus, .minus] && // think of better way to handle this
|
||||
!p.peek_tok.kind in [.number, .name] { // supposed to be only unary, additive handled in left asssoc
|
||||
|
||||
if prev_tok.is_right_assoc() && !p.tok.kind in [.plus, .minus] && // think of better way to handle this
|
||||
!p.peek_tok.kind in [.number, .name] {
|
||||
// supposed to be only unary, additive handled in left asssoc
|
||||
mut expr := ast.Expr{}
|
||||
expr,t2 = p.expr(prev_tok.precedence() - 1)
|
||||
node = ast.BinaryExpr{
|
||||
@@ -460,8 +459,10 @@ fn (p mut Parser) if_expr() (ast.Expr,types.Type) {
|
||||
}
|
||||
mut typ := types.void_type
|
||||
// mut left := ast.Expr{}
|
||||
// If the last statement is an expression, return its type
|
||||
match stmts[stmts.len - 1] {
|
||||
ast.ExprStmt {
|
||||
p.warn('if expr ret $it.typ.name')
|
||||
typ = it.typ
|
||||
// return node,it.typ
|
||||
// left =
|
||||
|
||||
Reference in New Issue
Block a user