fix parser_test.v

pull/3253/head
Alexander Medvednikov 2019-12-29 06:41:25 +01:00
parent 5a6428f1ff
commit c81fbee4ab
2 changed files with 4 additions and 46 deletions

View File

@ -230,23 +230,9 @@ pub fn (p mut Parser) expr(rbp int) (ast.Expr,types.Type) {
if prev_tok.is_right_assoc() {
mut expr := ast.Expr{}
expr,t2 = p.expr(prev_tok.precedence() - 1)
/*
if prev_tok.is_assign() {
return ast.AssignStmt {
left: node
op: prev_tok.kind
right: expr
}, types.void_type
}
*/
node = ast.BinaryExpr{
left: node
// left_type: t1
op: prev_tok.kind
// right: p.expr(prev_tok.precedence() - 1)
right: expr
}
if !types.check(&typ, &t2) {
@ -266,34 +252,6 @@ pub fn (p mut Parser) expr(rbp int) (ast.Expr,types.Type) {
return node,typ
}
/*
fn (p mut Parser) stmt() ast.Stmt {
if p.tok == .name {
name := p.lit
p.next()
if p.tok == .decl_assign {
p.next()
return ast.VarDecl{
name: name
expr: p.expr(token.lowest_prec)
}
}
}
/*
match node {
Ident {
}
}
*/
return ast.VarDecl{}
}
*/
fn (p mut Parser) parse_string_literal() (ast.Expr,types.Type) {
mut node := ast.Expr{}
node = ast.StringLiteral{

View File

@ -39,8 +39,8 @@ fn test_parse_expr() {
'a := 12',
'ab := 10 + 3 * 9',
's := "hi"',
'1 += 2',
// 'a += 10',
// '1 += 2',
'a += 10',
'1.2 + 3.4',
'4 + 4',
'1 + 2 * 5',
@ -65,8 +65,8 @@ fn test_parse_expr() {
'int a = 12;',
'int ab = 10 + 3 * 9;',
'string s = tos3("hi");',
'1 += 2;',
// 'a += 10;',
// '1 += 2;',
'a += 10;',
'1.2 + 3.4;',
'4 + 4;',
'1 + 2 * 5;',