From ba4cd9da39dd609ce1b70b2e092a6edd8500dbc2 Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 19 Jun 2018 00:07:28 -0700 Subject: [PATCH] Kill match keyword + data structures And add new unified keywords --- schala-lang/src/ast.rs | 10 ---------- schala-lang/src/parsing.rs | 4 +++- schala-lang/src/tokenizing.rs | 6 ++++-- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/schala-lang/src/ast.rs b/schala-lang/src/ast.rs index 95f5cfb..afbb1be 100644 --- a/schala-lang/src/ast.rs +++ b/schala-lang/src/ast.rs @@ -94,7 +94,6 @@ pub enum ExpressionType { indexers: Vec, }, IfExpression(Box, Block, Option), - MatchExpression(Box, Vec), WhileExpression { condition: Option>, body: Block, @@ -121,12 +120,3 @@ pub enum ForBody { MonadicReturn(Expression), StatementBlock(Block), } - -#[derive(Debug, PartialEq, Clone)] -pub struct MatchArm { - pub pat: Pattern, - pub expr: Expression, -} - -#[derive(Debug, PartialEq, Clone)] -pub struct Pattern(pub Rc); diff --git a/schala-lang/src/parsing.rs b/schala-lang/src/parsing.rs index aaca001..0f9a79c 100644 --- a/schala-lang/src/parsing.rs +++ b/schala-lang/src/parsing.rs @@ -542,7 +542,7 @@ impl Parser { LParen => self.paren_expr(), LSquareBracket => self.list_expr(), Keyword(Kw::If) => self.if_expr(), - Keyword(Kw::Match) => self.match_expr(), + //Keyword(Kw::Match) => self.match_expr(), Keyword(Kw::For) => self.for_expr(), Keyword(Kw::While) => self.while_expr(), Identifier(_) => self.identifier_expr(), @@ -642,6 +642,7 @@ impl Parser { Ok(delimited!(self, LCurlyBrace, statement, Newline | Semicolon, RCurlyBrace, nonstrict)) }); + /* parse_method!(match_expr(&mut self) -> ParseResult { expect!(self, Keyword(Kw::Match)); let expr = { @@ -669,6 +670,7 @@ impl Parser { let identifier = self.identifier()?; Ok(Pattern(identifier)) }); + */ parse_method!(while_expr(&mut self) -> ParseResult { use self::ExpressionType::*; diff --git a/schala-lang/src/tokenizing.rs b/schala-lang/src/tokenizing.rs index 6eb6773..2b4b8fd 100644 --- a/schala-lang/src/tokenizing.rs +++ b/schala-lang/src/tokenizing.rs @@ -45,7 +45,8 @@ impl fmt::Display for TokenType { #[derive(Debug, Clone, Copy, PartialEq)] pub enum Kw { - If, Else, + If, Then, Else, + Is, Func, For, While, Match, @@ -61,11 +62,12 @@ lazy_static! { static ref KEYWORDS: HashMap<&'static str, Kw> = hashmap! { "if" => Kw::If, + "then" => Kw::Then, "else" => Kw::Else, + "is" => Kw::Is, "fn" => Kw::Func, "for" => Kw::For, "while" => Kw::While, - "match" => Kw::Match, "var" => Kw::Var, "const" => Kw::Const, "let" => Kw::Let,