From fa1257e2cd665741bdcea1b2b65e96a8567cfd95 Mon Sep 17 00:00:00 2001 From: greg Date: Wed, 12 Jun 2019 00:20:20 +0000 Subject: [PATCH] Starting work on more complicated call expressions Probably won't build yet --- schala-lang/language/src/ast.rs | 12 +++++++++++- schala-lang/language/src/parsing.rs | 10 ++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/schala-lang/language/src/ast.rs b/schala-lang/language/src/ast.rs index 9f47ee0..d440a82 100644 --- a/schala-lang/language/src/ast.rs +++ b/schala-lang/language/src/ast.rs @@ -125,7 +125,7 @@ pub enum ExpressionKind { }, Call { f: Box>, - arguments: Vec>, + arguments: Vec>, }, Index { indexee: Box>, @@ -151,6 +151,16 @@ pub enum ExpressionKind { ListLiteral(Vec>), } +#[derive(Debug, PartialEq, Clone)] +pub enum InvocationArgument { + Positional(Expression), + Keyword { + name: Rc, + expr: Expression, + }, + Ignored +} + #[derive(Debug, PartialEq, Clone)] pub enum Discriminator { Simple(Expression), diff --git a/schala-lang/language/src/parsing.rs b/schala-lang/language/src/parsing.rs index dace2c2..5fa1524 100644 --- a/schala-lang/language/src/parsing.rs +++ b/schala-lang/language/src/parsing.rs @@ -69,8 +69,9 @@ //! precedence_expr := prefix_expr //! prefix_expr := prefix_op call_expr //! prefix_op := "+" | "-" | "!" | "~" -//! call_expr := index_expr ( "(" expr_list ")" )* | ε -//! expr_list := expression ("," expression)* | ε +//! call_expr := index_expr ( "(" invocation_list ")" )* | ε +//! invocation_list := invocation_argument ("," invocation_argument)* | ε +//! invocation_argument := expression | IDENTIFIER "=" expression | "_" //! index_expr := primary ( "[" (expression ("," (expression)* | ε) "]" )* //! primary := literal | paren_expr | if_expr | for_expr | while_expr | identifier_expr | lambda_expr | anonymous_struct | list_expr //! expr_or_block := "{" (statement delimiter)* "}" | expr @@ -627,6 +628,11 @@ impl Parser { Ok(expr) } + #[recursive_descent_method] + fn invocation_argument(&mut self) -> ParseResult { + panic!() + } + #[recursive_descent_method] fn index_expr(&mut self) -> ParseResult { let primary = self.primary()?;