Skip to content

Commit

Permalink
[config][infos] remove noise around regexes for comments
Browse files Browse the repository at this point in the history
  • Loading branch information
apalala committed Jan 6, 2025
1 parent bc30552 commit 3a8e519
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
4 changes: 2 additions & 2 deletions tatsu/buffering.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@ def eat_whitespace(self):
return self._eat_regex(self.whitespace_re)

def eat_comments(self):
comments = self._eat_regex_list(self.config.comments_pattern)
comments = self._eat_regex_list(cached_re_compile(self.config.comments))
self._index_comments(comments, lambda x: x.inline)

def eat_eol_comments(self):
comments = self._eat_regex_list(self.config.eol_comments_pattern)
comments = self._eat_regex_list(cached_re_compile(self.config.eol_comments))
self._index_comments(comments, lambda x: x.eol)

def next_token(self):
Expand Down
13 changes: 0 additions & 13 deletions tatsu/infos.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from .ast import AST
from .tokenizing import Tokenizer
from .util.misc import cached_re_compile
from .util.unicode_characters import C_DERIVE


Expand Down Expand Up @@ -95,18 +94,6 @@ def new(
# NOTE:
# Using functools.cache directly makes objects of this class unhashable

@property
def comments_pattern(self) -> re.Pattern | None:
return cached_re_compile(self.comments)

@property
def eol_comments_pattern(self) -> re.Pattern | None:
return cached_re_compile(self.eol_comments)

@property
def whitespace_pattern(self) -> re.Pattern | None:
return cached_re_compile(self.whitespace)

def effective_rule_name(self):
# note: there are legacy reasons for this mess
return self.start_rule or self.rule_name or self.start
Expand Down

0 comments on commit 3a8e519

Please sign in to comment.