Skip to content

Commit 856c79d

Browse files
authored
Merge pull request #65 from atcoder/patch/expander
Refactor expander.py
2 parents 3fd5669 + ccecb61 commit 856c79d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

expander.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ class Expander:
1818

1919
include_guard = re.compile('#.*ATCODER_[A-Z_]*_HPP')
2020

21+
def is_ignored_line(self, line) -> bool:
22+
if self.include_guard.match(line):
23+
return True
24+
if line.strip() == "#pragma once":
25+
return True
26+
if line.strip().startswith('//'):
27+
return True
28+
return False
29+
2130
def __init__(self, lib_paths: List[Path]):
2231
self.lib_paths = lib_paths
2332

@@ -45,14 +54,16 @@ def expand_acl(self, acl_name: str) -> List[str]:
4554

4655
result = [] # type: List[str]
4756
for line in acl_source.splitlines():
48-
if self.include_guard.match(line):
57+
if self.is_ignored_line(line):
4958
continue
5059

5160
m = self.atcoder_include.match(line)
5261
if m:
5362
result.extend(self.expand_acl(m.group(1)))
5463
continue
64+
5565
result.append(line)
66+
5667
return result
5768

5869
def expand(self, source: str) -> str:

0 commit comments

Comments
 (0)