Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow whitespaces in START STENCIL directive for name argument #414

Merged
merged 12 commits into from
Apr 10, 2024
Merged
2 changes: 1 addition & 1 deletion tools/src/icon4pytools/liskov/parsing/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def validate(self, directives: Sequence[ts.ParsedDirective]) -> None:


def _extract_arg_from_directive(directive: str, arg: str) -> str:
match = re.search(f"{arg}=([^;)]+)", directive)
match = re.search(f"{arg}\s*=\s*([^\s;)]+)", directive)
if match:
return match.group(1)
else:
Expand Down
23 changes: 23 additions & 0 deletions tools/tests/liskov/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,29 @@ def test_directive_semantics_validation_unbalanced_stencil_directives(
parser(directives)


@mark.parametrize(
"stencil, directive",
[
(
SINGLE_STENCIL_WITH_COMMENTS,
"!$DSL START STENCIL( name = foo ; x = bar )\n!$DSL END STENCIL(name = foo)",
),
(
SINGLE_STENCIL_WITH_COMMENTS,
"!$DSL START FUSED STENCIL( name = foo ; x = bar )\n!$DSL END FUSED STENCIL(name = foo)",
),
],
)
def test_directive_semantics_validation_allow_whitespaces_in_name_arg(
make_f90_tmpfile, stencil, directive
):
fpath = make_f90_tmpfile(stencil + directive)
opath = fpath.with_suffix(".gen")
directives = scan_for_directives(fpath)
parser = DirectivesParser(fpath, opath)
parser(directives)


@mark.parametrize(
"directive",
(
Expand Down
Loading