Skip to content

Commit 495de75

Browse files
committed
refactor expander.py
1 parent 3fd5669 commit 495de75

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

expander.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ class Expander:
1717
'#include\s*["<](atcoder/[a-z_]*(|.hpp))[">]\s*')
1818

1919
include_guard = re.compile('#.*ATCODER_[A-Z_]*_HPP')
20+
def is_ignored_line(self, line) -> bool:
21+
if self.include_guard.match(line):
22+
return True
23+
if line.strip() == "#pragma once":
24+
return True
25+
if line.strip().startswith('//'):
26+
return True
27+
return False
2028

2129
def __init__(self, lib_paths: List[Path]):
2230
self.lib_paths = lib_paths
@@ -45,14 +53,16 @@ def expand_acl(self, acl_name: str) -> List[str]:
4553

4654
result = [] # type: List[str]
4755
for line in acl_source.splitlines():
48-
if self.include_guard.match(line):
56+
if self.is_ignored_line(line):
4957
continue
50-
58+
5159
m = self.atcoder_include.match(line)
5260
if m:
5361
result.extend(self.expand_acl(m.group(1)))
5462
continue
63+
5564
result.append(line)
65+
5666
return result
5767

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

0 commit comments

Comments
 (0)