diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-10-04 22:36:20 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-10-04 22:36:20 +0200 |
| commit | 605ab104c5e041c345007020d277b4c6267debe6 (patch) | |
| tree | c18f3333a0c0e0527ad1039a498cb210300f7fd9 /src/parse/mod.rs | |
| parent | ef8aa763faa59fd62c90c6d6245e8d2c5eece35e (diff) | |
Better argument parsing 🥙
Diffstat (limited to 'src/parse/mod.rs')
| -rw-r--r-- | src/parse/mod.rs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/parse/mod.rs b/src/parse/mod.rs index ca2375f2..7fbbf141 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -163,14 +163,14 @@ fn bracket_call(p: &mut Parser) -> ExprCall { if p.peek() == Some(Token::LeftBracket) { let expr = p.span(|p| Expr::Lit(Lit::Content(bracket_body(p)))); inner.span.expand(expr.span); - inner.v.args.0.push(LitDictEntry { key: None, expr }); + inner.v.args.v.0.push(LitDictEntry { key: None, expr }); } while let Some(mut top) = outer.pop() { let span = inner.span; let node = inner.map(Expr::Call).map(SynNode::Expr); let expr = Expr::Lit(Lit::Content(vec![node])).span_with(span); - top.v.args.0.push(LitDictEntry { key: None, expr }); + top.v.args.v.0.push(LitDictEntry { key: None, expr }); inner = top; } @@ -194,14 +194,16 @@ fn bracket_subheader(p: &mut Parser) -> ExprCall { p.skip_white(); let args = if p.eat_if(Token::Colon) { - dict_contents(p).0 + p.span(|p| dict_contents(p).0) } else { // Ignore the rest if there's no colon. - if !p.eof() { - p.diag_expected_at("colon", p.pos()); - } - p.eat_while(|_| true); - LitDict::new() + p.span(|p| { + if !p.eof() { + p.diag_expected_at("colon", p.pos()); + } + p.eat_while(|_| true); + LitDict::new() + }) }; p.end_group(); @@ -221,7 +223,7 @@ fn bracket_body(p: &mut Parser) -> SynTree { /// Parse a parenthesized function call. fn paren_call(p: &mut Parser, name: Spanned<Ident>) -> ExprCall { p.start_group(Group::Paren); - let args = dict_contents(p).0; + let args = p.span(|p| dict_contents(p).0); p.end_group(); ExprCall { name, args } } |
