1 Commits

Author SHA1 Message Date
3a8f0e84af wip -- start indexing work 2025-12-21 00:47:47 -07:00
3 changed files with 17 additions and 2 deletions

View File

@@ -13,6 +13,6 @@ lsp-types = { workspace = true }
rust_decimal = { workspace = true }
[dev-dependencies]
anyhow = { version = "1.0" }
anyhow = { workspace = true }
indoc = { version = "2.0" }
pretty_assertions = "1"

View File

@@ -308,7 +308,7 @@ impl<'a> Parser<'a> {
Ok(Some(lhs))
}
/// Handles dot notation chains: x.y.z()
/// Handles dot notation chains (x.y.z()) and array indexing (x[0])
fn parse_postfix(
&mut self,
mut lhs: Spanned<Expression<'a>>,
@@ -411,6 +411,9 @@ impl<'a> Parser<'a> {
}),
};
}
} else if self_matches_peek!(self, TokenType::Symbol(Symbol::LBracket)) {
// consume the `[` token
self.assign_next()?;
} else {
break;
}

View File

@@ -174,6 +174,18 @@ impl<'a> std::fmt::Display for MemberAccessExpression<'a> {
}
}
#[derive(Debug, PartialEq, Eq)]
pub struct MemberIndexingExpression<'a> {
pub object: LiteralOrVariable<'a>,
pub index_of: Box<Spanned<Expression<'a>>>,
}
impl<'a> std::fmt::Display for MemberIndexingExpression<'a> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}[{}]", self.object, self.index_of)
}
}
#[derive(Debug, PartialEq, Eq)]
pub struct MethodCallExpression<'a> {
pub object: Box<Spanned<Expression<'a>>>,