-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
parserParser relatedParser related
Description
Lines 973 to 1130 in 1f72a30
| //let tests = [ | |
| // ( | |
| // " | |
| // { | |
| // 1 * 2 + 3 / (4 + 1 as u8); | |
| // } | |
| // ", | |
| // vec![Stmt::Expr(ExprKind::Binary { | |
| // op: BinOp::Add, | |
| // left: Box::new(ExprKind::Binary { | |
| // op: BinOp::Mul, | |
| // left: Box::new(ExprKind::Lit(ExprLit::UInt(1))), | |
| // right: Box::new(ExprKind::Lit(ExprLit::UInt(2))), | |
| // }), | |
| // right: Box::new(ExprKind::Binary { | |
| // op: BinOp::Div, | |
| // left: Box::new(ExprKind::Lit(ExprLit::UInt(3))), | |
| // right: Box::new(ExprKind::Binary { | |
| // op: BinOp::Add, | |
| // left: Box::new(ExprKind::Lit(ExprLit::UInt(4))), | |
| // right: Box::new(ExprKind::Cast { | |
| // ty: Ty::UInt(UintTy::U8), | |
| // expr: Box::new(ExprKind::Lit(ExprLit::UInt(1))), | |
| // }), | |
| // }), | |
| // }), | |
| // })], | |
| // ), | |
| // ( | |
| // " | |
| // { | |
| // let foo: u8; | |
| // foo = -1 as u8 + 5; | |
| // } | |
| // ", | |
| // vec![ | |
| // Stmt::Local(Variable { | |
| // name: "foo".to_owned(), | |
| // ty: Ty::UInt(UintTy::U8), | |
| // value: None, | |
| // }), | |
| // Stmt::Expr(ExprKind::Binary { | |
| // op: BinOp::Assign, | |
| // left: Box::new(ExprKind::Ident("foo".to_owned())), | |
| // right: Box::new(ExprKind::Binary { | |
| // op: BinOp::Add, | |
| // left: Box::new(ExprKind::Cast { | |
| // ty: Ty::UInt(UintTy::U8), | |
| // expr: Box::new(ExprKind::Unary { | |
| // op: UnOp::Negative, | |
| // expr: Box::new(ExprKind::Lit(ExprLit::UInt(1))), | |
| // }), | |
| // }), | |
| // right: Box::new(ExprKind::Lit(ExprLit::UInt(5))), | |
| // }), | |
| // }), | |
| // ], | |
| // ), | |
| // ( | |
| // " | |
| // { | |
| // let foo: u8; | |
| // let bar: i8; | |
| // bar = foo as i8 + 5 / 10; | |
| // } | |
| // ", | |
| // vec![ | |
| // Stmt::Local(Variable { | |
| // name: "foo".to_owned(), | |
| // ty: Ty::UInt(UintTy::U8), | |
| // value: None, | |
| // }), | |
| // Stmt::Local(Variable { | |
| // name: "bar".to_owned(), | |
| // ty: Ty::Int(IntTy::I8), | |
| // value: None, | |
| // }), | |
| // Stmt::Expr(ExprKind::Binary { | |
| // op: BinOp::Assign, | |
| // left: Box::new(ExprKind::Ident("bar".to_owned())), | |
| // right: Box::new(ExprKind::Binary { | |
| // op: BinOp::Add, | |
| // left: Box::new(ExprKind::Cast { | |
| // ty: Ty::Int(IntTy::I8), | |
| // expr: Box::new(ExprKind::Ident("foo".to_owned())), | |
| // }), | |
| // right: Box::new(ExprKind::Binary { | |
| // op: BinOp::Div, | |
| // left: Box::new(ExprKind::Lit(ExprLit::UInt(5))), | |
| // right: Box::new(ExprKind::Lit(ExprLit::UInt(10))), | |
| // }), | |
| // }), | |
| // }), | |
| // ], | |
| // ), | |
| // ( | |
| // " | |
| // { | |
| // 1 as i8 + 2 / 3; | |
| // } | |
| // ", | |
| // vec![Stmt::Expr(ExprKind::Binary { | |
| // op: BinOp::Add, | |
| // left: Box::new(ExprKind::Cast { | |
| // ty: Ty::Int(IntTy::I8), | |
| // expr: Box::new(ExprKind::Lit(ExprLit::UInt(1))), | |
| // }), | |
| // right: Box::new(ExprKind::Binary { | |
| // op: BinOp::Div, | |
| // left: Box::new(ExprKind::Lit(ExprLit::UInt(2))), | |
| // right: Box::new(ExprKind::Lit(ExprLit::UInt(3))), | |
| // }), | |
| // })], | |
| // ), | |
| // ( | |
| // " | |
| // { | |
| // let a: u8; | |
| // let b: u8; | |
| // a = b = 69; | |
| // } | |
| // ", | |
| // vec![ | |
| // Stmt::Local(Variable { | |
| // name: "a".to_owned(), | |
| // ty: Ty::UInt(UintTy::U8), | |
| // value: None, | |
| // }), | |
| // Stmt::Local(Variable { | |
| // name: "b".to_owned(), | |
| // ty: Ty::UInt(UintTy::U8), | |
| // value: None, | |
| // }), | |
| // Stmt::Expr(ExprKind::Binary { | |
| // op: BinOp::Assign, | |
| // left: Box::new(ExprKind::Ident("a".to_owned())), | |
| // right: Box::new(ExprKind::Binary { | |
| // op: BinOp::Assign, | |
| // left: Box::new(ExprKind::Ident("b".to_owned())), | |
| // right: Box::new(ExprKind::Lit(ExprLit::UInt(69))), | |
| // }), | |
| // }), | |
| // ], | |
| // ), | |
| //]; | |
| //for (input, expected) in tests { | |
| // let mut diagnostics = Diagnostics::new(input); | |
| // let mut parser = Parser::new(Lexer::new(input), &mut diagnostics); | |
| // let ast = parser.parse_block_stmt().unwrap(); | |
| // assert_eq!( | |
| // &ast.stmts, &expected, | |
| // "expected: {:?}, got: {:?}", | |
| // expected, ast | |
| // ); | |
| //} |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
parserParser relatedParser related