Skip to content

Commit

Permalink
Merge pull request #275 from gerlero/files
Browse files Browse the repository at this point in the history
Update parsing
  • Loading branch information
gerlero authored Nov 16, 2024
2 parents 7ff3acb + 7c684e0 commit 5c53f23
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions foamlib/_files/_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _list_of(entry: ParserElement) -> ParserElement:


def _counted_tensor_list(*, size: int, ignore: Regex) -> ParserElement:
float_pattern = r"[+-]?((\d+\.?\d*(e[+-]?\d+)?)|nan|inf(inity)?)"
float_pattern = r"(?i:[+-]?((\d+\.?\d*(e[+-]?\d+)?)|nan|inf(inity)?))"
ignore_pattern = rf"(?:\s|{ignore.re.pattern})+"

if size == 1:
Expand All @@ -82,8 +82,7 @@ def count_parse_action(tks: ParseResults) -> None:
assert isinstance(length, int)

list_ <<= Regex(
rf"\((?:{ignore_pattern})?(?:{tensor_pattern}{ignore_pattern}){{{length - 1}}}{tensor_pattern}(?:{ignore_pattern})?\)",
flags=re.IGNORECASE,
rf"\((?:{ignore_pattern})?(?:{tensor_pattern}{ignore_pattern}){{{length - 1}}}{tensor_pattern}(?:{ignore_pattern})?\)"
)

count = common.integer.add_parse_action(count_parse_action)
Expand Down

0 comments on commit 5c53f23

Please sign in to comment.