MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / parse_expr

Method parse_expr

cranelift/isle/isle/src/parser.rs:949–972  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

947 }
948
949 fn parse_expr(&mut self) -> Result<Expr> {
950 let pos = self.pos();
951 if self.is_lparen() {
952 self.expect_lparen()?;
953 let ret = self.parse_expr_inner_parens(pos)?;
954 self.expect_rparen()?;
955 Ok(ret)
956 } else if self.is_const() {
957 let val = self.parse_const()?;
958 Ok(Expr::ConstPrim { val, pos })
959 } else if self.eat_sym_str("true")? {
960 Ok(Expr::ConstBool { val: true, pos })
961 } else if self.eat_sym_str("false")? {
962 Ok(Expr::ConstBool { val: false, pos })
963 } else if self.is_sym() {
964 let name = self.parse_ident()?;
965 Ok(Expr::Var { name, pos })
966 } else if self.is_int() {
967 let val = self.expect_int()?;
968 Ok(Expr::ConstInt { val, pos })
969 } else {
970 Err(self.error(pos, "Invalid expression".into()))
971 }
972 }
973
974 fn parse_expr_inner_parens(&mut self, pos: Pos) -> Result<Expr> {
975 if self.eat_sym_str("let")? {

Callers 5

parse_iflet_or_exprMethod · 0.80
parse_ifletMethod · 0.80
parse_iflet_ifMethod · 0.80
parse_letdefMethod · 0.80

Calls 14

OkFunction · 0.85
is_lparenMethod · 0.80
expect_lparenMethod · 0.80
expect_rparenMethod · 0.80
parse_constMethod · 0.80
eat_sym_strMethod · 0.80
parse_identMethod · 0.80
expect_intMethod · 0.80
posMethod · 0.45
is_constMethod · 0.45
is_symMethod · 0.45

Tested by

no test coverage detected