Merge pull request #93 from skjdbg/fix_chained_method
Fix chained method
This commit is contained in:
commit
250354e7c6
@ -150,8 +150,20 @@ pub(crate) fn method_call(s: Span) -> IResult<Span, MethodCall> {
|
||||
let (s, a) = method_call_root(s)?;
|
||||
let (s, b) = symbol(".")(s)?;
|
||||
let (s, c) = method_call_body(s)?;
|
||||
let mut init_method_call = MethodCall { nodes: (a, b, c) };
|
||||
|
||||
Ok((s, MethodCall { nodes: (a, b, c) }))
|
||||
// check for chained method
|
||||
let (s, sub_calls) = many0(pair(symbol("."), method_call_body))(s)?;
|
||||
for (dot, body) in sub_calls {
|
||||
let fun_sub_call = Primary::FunctionSubroutineCall(Box::new(FunctionSubroutineCall {
|
||||
nodes: (SubroutineCall::MethodCall(Box::new(init_method_call)),),
|
||||
}));
|
||||
init_method_call = MethodCall {
|
||||
nodes: (MethodCallRoot::Primary(Box::new(fun_sub_call)), dot, body),
|
||||
};
|
||||
}
|
||||
|
||||
Ok((s, init_method_call))
|
||||
}
|
||||
|
||||
#[tracable_parser]
|
||||
|
@ -45,6 +45,13 @@ macro_rules! error_test {
|
||||
mod unit {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_chained_method_call() {
|
||||
test!(method_call, "variable.method1().method2()", Ok((_, _)));
|
||||
test!(method_call, "variable.member.method2()", Ok((_, _)));
|
||||
test!(method_call, "variable.method1().member", Ok((_, _)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_pulldown_strength() {
|
||||
test!(pulldown_strength, "(supply0, strong1)", Ok((_, _)));
|
||||
|
Loading…
x
Reference in New Issue
Block a user