extract parse_tuple_field_access_expr
This commit is contained in:
parent
287ba5d0c8
commit
a15d0cde57
1 changed files with 16 additions and 7 deletions
|
@ -708,12 +708,7 @@ impl<'a> Parser<'a> {
|
||||||
e = self.parse_dot_suffix(e, lo)?;
|
e = self.parse_dot_suffix(e, lo)?;
|
||||||
}
|
}
|
||||||
token::Literal(token::Lit { kind: token::Integer, symbol, suffix }) => {
|
token::Literal(token::Lit { kind: token::Integer, symbol, suffix }) => {
|
||||||
let span = self.token.span;
|
e = self.parse_tuple_field_access_expr(lo, e, symbol, suffix);
|
||||||
self.bump();
|
|
||||||
let field = ExprKind::Field(e, Ident::new(symbol, span));
|
|
||||||
e = self.mk_expr(lo.to(span), field, AttrVec::new());
|
|
||||||
|
|
||||||
self.expect_no_suffix(span, "a tuple index", suffix);
|
|
||||||
}
|
}
|
||||||
token::Literal(token::Lit { kind: token::Float, symbol, .. }) => {
|
token::Literal(token::Lit { kind: token::Float, symbol, .. }) => {
|
||||||
self.bump();
|
self.bump();
|
||||||
|
@ -756,7 +751,7 @@ impl<'a> Parser<'a> {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
match self.token.kind {
|
match self.token.kind {
|
||||||
token::OpenDelim(token::Paren) => e = Ok(self.parse_fn_call_expr(lo, e)),
|
token::OpenDelim(token::Paren) => e = self.parse_fn_call_expr(lo, e),
|
||||||
token::OpenDelim(token::Bracket) => e = self.parse_index_expr(lo, e)?,
|
token::OpenDelim(token::Bracket) => e = self.parse_index_expr(lo, e)?,
|
||||||
_ => return Ok(e),
|
_ => return Ok(e),
|
||||||
}
|
}
|
||||||
|
@ -764,6 +759,20 @@ impl<'a> Parser<'a> {
|
||||||
return Ok(e);
|
return Ok(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parse_tuple_field_access_expr(
|
||||||
|
&mut self,
|
||||||
|
lo: Span,
|
||||||
|
base: P<Expr>,
|
||||||
|
field: Symbol,
|
||||||
|
suffix: Option<Symbol>,
|
||||||
|
) -> P<Expr> {
|
||||||
|
let span = self.token.span;
|
||||||
|
self.bump();
|
||||||
|
let field = ExprKind::Field(base, Ident::new(field, span));
|
||||||
|
self.expect_no_suffix(span, "a tuple index", suffix);
|
||||||
|
self.mk_expr(lo.to(span), field, AttrVec::new())
|
||||||
|
}
|
||||||
|
|
||||||
/// Parse a function call expression, `expr(...)`.
|
/// Parse a function call expression, `expr(...)`.
|
||||||
fn parse_fn_call_expr(&mut self, lo: Span, fun: P<Expr>) -> P<Expr> {
|
fn parse_fn_call_expr(&mut self, lo: Span, fun: P<Expr>) -> P<Expr> {
|
||||||
let seq = self.parse_paren_expr_seq().map(|args| {
|
let seq = self.parse_paren_expr_seq().map(|args| {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue