Implement parsing for tuple accessor functions (.1, .2, etc)

Step 2 of N toward implementing #4465
This commit is contained in:
Joshua Warner 2022-11-08 19:32:14 -05:00
parent 07efb32173
commit f4ce4bf983
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
19 changed files with 144 additions and 55 deletions

View file

@ -34,8 +34,10 @@ impl<'a> Formattable for Expr<'a> {
| Num(..)
| NonBase10Int { .. }
| SingleQuote(_)
| Access(_, _)
| AccessorFunction(_)
| RecordAccess(_, _)
| RecordAccessorFunction(_)
| TupleAccess(_, _)
| TupleAccessorFunction(_)
| Var { .. }
| Underscore { .. }
| MalformedIdent(_, _)
@ -399,12 +401,22 @@ impl<'a> Formattable for Expr<'a> {
sub_expr.format_with_options(buf, Parens::InApply, newlines, indent);
}
AccessorFunction(key) => {
RecordAccessorFunction(key) => {
buf.indent(indent);
buf.push('.');
buf.push_str(key);
}
Access(expr, key) => {
RecordAccess(expr, key) => {
expr.format_with_options(buf, Parens::InApply, Newlines::Yes, indent);
buf.push('.');
buf.push_str(key);
}
TupleAccessorFunction(key) => {
buf.indent(indent);
buf.push('.');
buf.push_str(key);
}
TupleAccess(expr, key) => {
expr.format_with_options(buf, Parens::InApply, Newlines::Yes, indent);
buf.push('.');
buf.push_str(key);