diff --git a/src/parser/mod.rs b/src/parser/mod.rs index d45eea7..94fba56 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -710,6 +710,7 @@ fn parse_expression<'input>( Left GreaterOrEqual => 15, Left Lesser => 15, Left LesserOrEqual => 15, + Left Dot => 23, ] }).postfix(dispatch! { surrounded(ws, parse_operator); TokenOperator::QuestionMark => Postfix(22, |input, rhs| { @@ -1071,4 +1072,15 @@ mod tests { insta::assert_debug_snapshot!(ast); } + + #[test] + fn check_access_operator() { + let input = "{{= foo?.bar }}"; + + let parsed = crate::lexer::parse(input.into()).unwrap(); + + let ast = panic_pretty(input, parse(parsed.tokens())); + + insta::assert_debug_snapshot!(ast); + } } diff --git a/src/parser/snapshots/nomo__parser__tests__check_access_operator.snap b/src/parser/snapshots/nomo__parser__tests__check_access_operator.snap new file mode 100644 index 0000000..3fcf602 --- /dev/null +++ b/src/parser/snapshots/nomo__parser__tests__check_access_operator.snap @@ -0,0 +1,21 @@ +--- +source: src/parser/mod.rs +expression: ast +--- +TemplateAst { + root: [ + Interpolation { + prev_whitespace_content: None, + expression: Operation { + op: Dot, + lhs: ConditionalAccess( + [Ident]"foo" (4..7), + ), + rhs: VariableAccess( + [Ident]"bar" (9..12), + ), + }, + post_whitespace_content: None, + }, + ], +}