Handle function calls in call args

This commit is contained in:
ConnorSkees 2020-02-09 14:27:54 -05:00
parent bc0c1d35f6
commit d6ed0391db
2 changed files with 26 additions and 0 deletions

View File

@ -202,6 +202,27 @@ pub(crate) fn eat_call_args<I: Iterator<Item = Token>>(
} }
} }
} }
TokenKind::Symbol(Symbol::OpenParen) => {
val.push(Token { kind, pos });
let mut unclosed_parens = 0;
while let Some(tok) = toks.next() {
match &tok.kind {
TokenKind::Symbol(Symbol::OpenParen) => {
unclosed_parens += 1;
}
TokenKind::Symbol(Symbol::CloseParen) => {
if unclosed_parens <= 1 {
val.push(tok);
break;
} else {
unclosed_parens -= 1;
}
}
_ => {}
}
val.push(tok);
}
}
TokenKind::Symbol(Symbol::CloseParen) => { TokenKind::Symbol(Symbol::CloseParen) => {
if val.is_empty() { if val.is_empty() {
break; break;

View File

@ -23,6 +23,11 @@ test!(
"@function a($a) {\n @return $a;\n}\n\nb {\ncolor: a(1);\n}\n", "@function a($a) {\n @return $a;\n}\n\nb {\ncolor: a(1);\n}\n",
"b {\n color: 1;\n}\n" "b {\n color: 1;\n}\n"
); );
test!(
function_call_as_arg,
"@function a($a) {\n @return $a;\n}\n\nb {\ncolor: a(a(2));\n}\n",
"b {\n color: 2;\n}\n"
);
// test!( // test!(
// return_no_semicolon, // return_no_semicolon,
// "@function a() {\n @return 1\n}\n\nb {\ncolor: a();\n}\n", // "@function a() {\n @return 1\n}\n\nb {\ncolor: a();\n}\n",