Infallible extractors, and some fixes to fallibility in return types (Option<T> vs T).

This commit is contained in:
Chris Fallin
2021-09-09 15:33:15 -07:00
parent 6daa55af82
commit a412cce615
7 changed files with 156 additions and 29 deletions

View File

@@ -256,8 +256,17 @@ impl<'a> Parser<'a> {
})
} else if self.is_sym_str("extractor") {
self.symbol()?;
let infallible = if self.is_sym_str("infallible") {
self.symbol()?;
true
} else {
false
};
let term = self.parse_ident()?;
let func = self.parse_ident()?;
let arg_polarity = if self.is_lparen() {
let mut pol = vec![];
self.lparen()?;
@@ -284,6 +293,7 @@ impl<'a> Parser<'a> {
func,
pos: pos.unwrap(),
arg_polarity,
infallible,
})
} else {
Err(self.error(