Skip to content

Commit 65eacc7

Browse files
authored
Merge pull request #130 from rage/c-available-points
fixed c points parser incorrectly parsing points from tmc-check.c
2 parents 4117d33 + d409950 commit 65eacc7

File tree

1 file changed

+46
-10
lines changed

1 file changed

+46
-10
lines changed

plugins/make/src/plugin.rs

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -338,26 +338,45 @@ impl LanguagePlugin for MakePlugin {
338338
}
339339

340340
fn points_parser(i: &str) -> IResult<&str, &str, VerboseError<&str>> {
341-
combinator::map(
341+
fn tmc_register_test_parser(i: &str) -> IResult<&str, &str, VerboseError<&str>> {
342342
sequence::delimited(
343343
sequence::tuple((
344344
bytes::complete::tag("tmc_register_test"),
345345
character::complete::multispace0,
346346
character::complete::char('('),
347-
bytes::complete::is_not("\""),
347+
character::complete::multispace0,
348+
arg_parser,
349+
arg_parser,
348350
)),
349-
sequence::delimited(
350-
character::complete::char('"'),
351-
bytes::complete::is_not("\""),
352-
character::complete::char('"'),
353-
),
351+
string_parser,
354352
sequence::tuple((
355353
character::complete::multispace0,
356354
character::complete::char(')'),
357355
)),
358-
),
359-
str::trim,
360-
)(i)
356+
)(i)
357+
}
358+
359+
// todo: currently cannot handle function calls with multiple parameters, probably not a problem
360+
fn arg_parser(i: &str) -> IResult<&str, &str, VerboseError<&str>> {
361+
combinator::value(
362+
"",
363+
sequence::tuple((
364+
bytes::complete::take_till(|c: char| c.is_whitespace() || c == ','),
365+
character::complete::char(','),
366+
character::complete::multispace0,
367+
)),
368+
)(i)
369+
}
370+
371+
fn string_parser(i: &str) -> IResult<&str, &str, VerboseError<&str>> {
372+
sequence::delimited(
373+
character::complete::char('"'),
374+
bytes::complete::is_not("\""),
375+
character::complete::char('"'),
376+
)(i)
377+
}
378+
379+
tmc_register_test_parser(i)
361380
}
362381
}
363382

@@ -598,4 +617,21 @@ test [invalid] point6
598617
"dlink_insert"
599618
);
600619
}
620+
621+
#[test]
622+
fn does_not_parse_check_function() {
623+
assert!(MakePlugin::points_parser(
624+
r#"tmc_register_test(Suite *s, TFun tf, const char *fname, const char *points)
625+
{
626+
// stuff
627+
}
628+
629+
int tmc_run_tests(int argc, const char **argv, Suite *s)
630+
{
631+
func("--print-available-points")
632+
}
633+
"#
634+
)
635+
.is_err())
636+
}
601637
}

0 commit comments

Comments
 (0)