From 24e0ecbe7384e1886fc13b908f19c91929891aac Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 3 Sep 2019 21:14:12 -0700 Subject: [PATCH] partial work --- schala-lang/language/src/ast.rs | 2 +- schala-lang/language/src/parsing.rs | 29 ++++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/schala-lang/language/src/ast.rs b/schala-lang/language/src/ast.rs index b30268a..290b513 100644 --- a/schala-lang/language/src/ast.rs +++ b/schala-lang/language/src/ast.rs @@ -243,7 +243,7 @@ pub enum PatternLiteral { StringPattern(Rc), BoolPattern(bool), //TODO I think VarPattern also needs to know about FQSNs - VarPattern(Rc) + VarPattern(QualifiedName) } #[derive(Debug, PartialEq, Clone)] diff --git a/schala-lang/language/src/parsing.rs b/schala-lang/language/src/parsing.rs index 99505b4..3301462 100644 --- a/schala-lang/language/src/parsing.rs +++ b/schala-lang/language/src/parsing.rs @@ -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 { + 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 { Ok({ @@ -970,6 +992,7 @@ impl Parser { } }) } + */ #[recursive_descent_method] fn signed_number_literal(&mut self) -> ParseResult {