Skip to content

Commit

Permalink
[buffering] drop forced multiline match for string patterns
Browse files Browse the repository at this point in the history
Previously, when scanning for matches to a regex, if the type of the
pattern was `str`, the pattern was always compiled with `re.MULTILINE`.

Recent changes to `ParserConfig` [0] changed the type used for regex
matches in generated code from `str` to `re.Pattern` which could lead to
a difference in behavior from previous versions where a defined comments
or eol_comments may have been implicitly relying on the `re.MULTILINE`
flag.

After discussion [1], it has been determined that usage of `re` flags
within TatSu should be deprecated in favor of users specifying the
necessary flags within patterns.

As such, drop the `re.MULTILINE` flag for strings compiled on the fly.

[0]: neogeny#338
[1]: neogeny#351 (comment)
  • Loading branch information
vfazio committed Dec 28, 2024
1 parent 1b632e8 commit bd1c0a4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tatsu/buffering.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def _scanre(self, pattern):
if isinstance(pattern, RETYPE):
cre = pattern
else:
cre = re.compile(pattern, re.MULTILINE)
cre = re.compile(pattern)
return cre.match(self.text, self.pos)

@property
Expand Down

0 comments on commit bd1c0a4

Please sign in to comment.