Starting work on more complicated call expressions

Probably won't build yet
This commit is contained in:
greg 2019-06-12 00:20:20 +00:00
parent e9fd20bfe5
commit fa1257e2cd
2 changed files with 19 additions and 3 deletions

View File

@ -125,7 +125,7 @@ pub enum ExpressionKind {
},
Call {
f: Box<Meta<Expression>>,
arguments: Vec<Meta<Expression>>,
arguments: Vec<Meta<InvocationArgument>>,
},
Index {
indexee: Box<Meta<Expression>>,
@ -151,6 +151,16 @@ pub enum ExpressionKind {
ListLiteral(Vec<Meta<Expression>>),
}
#[derive(Debug, PartialEq, Clone)]
pub enum InvocationArgument {
Positional(Expression),
Keyword {
name: Rc<String>,
expr: Expression,
},
Ignored
}
#[derive(Debug, PartialEq, Clone)]
pub enum Discriminator {
Simple(Expression),

View File

@ -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<InvocationExpression> {
panic!()
}
#[recursive_descent_method]
fn index_expr(&mut self) -> ParseResult<Expression> {
let primary = self.primary()?;