Add parsing of dot operator
Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
parent
145d305c94
commit
a590839b21
2 changed files with 33 additions and 0 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
},
|
||||
],
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue