Starting on guards
This commit is contained in:
parent
21a8868bcf
commit
8aa33d0872
@ -120,9 +120,12 @@ tuple_struct_pattern := IDENTIFIER '(' (pattern, ',')* ')'
|
|||||||
/* Expression - If */
|
/* Expression - If */
|
||||||
if_expr := 'if' discriminator ('then' condititional | 'is' simple_pattern_match | guard_block)
|
if_expr := 'if' discriminator ('then' condititional | 'is' simple_pattern_match | guard_block)
|
||||||
discriminator := modified_precedence_expression
|
discriminator := modified_precedence_expression
|
||||||
|
modified_precedence_expression := ???
|
||||||
conditional := block else_clause
|
conditional := block else_clause
|
||||||
simple_pattern_match := pattern 'then' conditional
|
simple_pattern_match := pattern 'then' conditional
|
||||||
else_clause := ε | 'else' block
|
else_clause := ε | 'else' block
|
||||||
|
guard_block := '{' (guard, ',')* '}'
|
||||||
|
guard := ??
|
||||||
|
|
||||||
/* Expression - While */
|
/* Expression - While */
|
||||||
while_expr := 'while' while_cond '{' (statement delimiter)* '}'
|
while_expr := 'while' while_cond '{' (statement delimiter)* '}'
|
||||||
@ -688,10 +691,6 @@ impl Parser {
|
|||||||
Ok(IfExpressionBody::SimplePatternMatch(pat, then_clause, else_clause))
|
Ok(IfExpressionBody::SimplePatternMatch(pat, then_clause, else_clause))
|
||||||
});
|
});
|
||||||
|
|
||||||
parse_method!(guard_block(&mut self) -> ParseResult<IfExpressionBody> {
|
|
||||||
ParseError::new("Rest of if not done")
|
|
||||||
});
|
|
||||||
|
|
||||||
parse_method!(else_clause(&mut self) -> ParseResult<Option<Block>> {
|
parse_method!(else_clause(&mut self) -> ParseResult<Option<Block>> {
|
||||||
Ok(if let Keyword(Kw::Else) = self.peek() {
|
Ok(if let Keyword(Kw::Else) = self.peek() {
|
||||||
self.next();
|
self.next();
|
||||||
@ -701,6 +700,15 @@ impl Parser {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
parse_method!(guard_block(&mut self) -> ParseResult<IfExpressionBody> {
|
||||||
|
let guards = delimited!(self, LCurlyBrace, guard, Comma, RCurlyBrace);
|
||||||
|
Ok(IfExpressionBody::GuardList(guards))
|
||||||
|
});
|
||||||
|
|
||||||
|
parse_method!(guard(&mut self) -> ParseResult<Guard> {
|
||||||
|
unimplemented!()
|
||||||
|
});
|
||||||
|
|
||||||
parse_method!(pattern(&mut self) -> ParseResult<Pattern> {
|
parse_method!(pattern(&mut self) -> ParseResult<Pattern> {
|
||||||
if let LParen = self.peek() {
|
if let LParen = self.peek() {
|
||||||
let tuple_pattern_variants = delimited!(self, LParen, pattern, Comma, RParen);
|
let tuple_pattern_variants = delimited!(self, LParen, pattern, Comma, RParen);
|
||||||
|
Loading…
Reference in New Issue
Block a user