Added expr? syntax
This commit is contained in:
@@ -71,6 +71,7 @@ pub enum Postfix {
|
|||||||
StructCall(Vec<(Identifier, Expression)>),
|
StructCall(Vec<(Identifier, Expression)>),
|
||||||
Index(Expression),
|
Index(Expression),
|
||||||
As(TypeExpr),
|
As(TypeExpr),
|
||||||
|
Try,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
|
|||||||
@@ -500,6 +500,10 @@ as_px = {
|
|||||||
"as" ~ type_expr
|
"as" ~ type_expr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try_px = {
|
||||||
|
"?"
|
||||||
|
}
|
||||||
|
|
||||||
postfix = {
|
postfix = {
|
||||||
field_px
|
field_px
|
||||||
| call_px
|
| call_px
|
||||||
@@ -507,6 +511,7 @@ postfix = {
|
|||||||
| struct_px
|
| struct_px
|
||||||
| index_px
|
| index_px
|
||||||
| as_px
|
| as_px
|
||||||
|
| try_px
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------
|
// ------------------------------------------------------
|
||||||
|
|||||||
@@ -183,6 +183,8 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for Postfix {
|
|||||||
ast_expr!(Postfix::As(inner.next().unwrap().try_into()))
|
ast_expr!(Postfix::As(inner.next().unwrap().try_into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rule::try_px => Ok(Postfix::Try),
|
||||||
|
|
||||||
_ => AstError::bug_unimplemented(pair),
|
_ => AstError::bug_unimplemented(pair),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -302,6 +302,8 @@ impl GetRust for Postfix {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Postfix::As(ty) => format!(" as {}", ty.get_rust()),
|
Postfix::As(ty) => format!(" as {}", ty.get_rust()),
|
||||||
|
|
||||||
|
Postfix::Try => String::from("?"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user