partial work

This commit is contained in:
greg 2019-09-03 21:14:12 -07:00
parent fd66a9711d
commit 24e0ecbe73
2 changed files with 27 additions and 4 deletions

View File

@ -243,7 +243,7 @@ pub enum PatternLiteral {
StringPattern(Rc<String>),
BoolPattern(bool),
//TODO I think VarPattern also needs to know about FQSNs
VarPattern(Rc<String>)
VarPattern(QualifiedName)
}
#[derive(Debug, PartialEq, Clone)]

View File

@ -107,11 +107,11 @@
//! ```text
//! pattern := "(" (pattern, ",")* ")" | simple_pattern
//! simple_pattern := pattern_literal | record_pattern | tuple_struct_pattern
//! pattern_literal := "true" | "false" | signed_number_literal | STR_LITERAL | IDENTIFIER
//! pattern_literal := "true" | "false" | signed_number_literal | STR_LITERAL | qualified_identifier
//! signed_number_literal := "-"? number_literal
//! record_pattern := IDENTIFIER "{" (record_pattern_entry, ",")* "}"
//! record_pattern := qualified_identifier "{" (record_pattern_entry, ",")* "}"
//! record_pattern_entry := IDENTIFIER | IDENTIFIER ":" Pattern
//! tuple_struct_pattern := IDENTIFIER "(" (pattern, ",")* ")"
//! tuple_struct_pattern := qualified_identifier "(" (pattern, ",")* ")"
//! ```
//!
//! ### If-expressions
@ -929,6 +929,28 @@ impl Parser {
}
}
#[recursive_descent_method]
fn simple_pattern(&mut self) -> ParseResult<Pattern> {
match self.token_handler.peek_kind() {
Identifier(_) => {
let qualified_name = self.qualified_name()?;
match self.token_handler.peek_kind() {
LCurlyBrace => {
},
LParen => {
},
_ => {
},
}
},
_ => self.pattern_literal()
}
}
/*
#[recursive_descent_method]
fn simple_pattern(&mut self) -> ParseResult<Pattern> {
Ok({
@ -970,6 +992,7 @@ impl Parser {
}
})
}
*/
#[recursive_descent_method]
fn signed_number_literal(&mut self) -> ParseResult<Pattern> {