From 495de7563e13a8411214dbf5378542d33414424a Mon Sep 17 00:00:00 2001 From: Kohei Morita Date: Sun, 18 Oct 2020 03:39:03 +0900 Subject: [PATCH 1/2] refactor expander.py --- expander.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/expander.py b/expander.py index 7173bed..51dd1fe 100755 --- a/expander.py +++ b/expander.py @@ -17,6 +17,14 @@ class Expander: '#include\s*["<](atcoder/[a-z_]*(|.hpp))[">]\s*') include_guard = re.compile('#.*ATCODER_[A-Z_]*_HPP') + def is_ignored_line(self, line) -> bool: + if self.include_guard.match(line): + return True + if line.strip() == "#pragma once": + return True + if line.strip().startswith('//'): + return True + return False def __init__(self, lib_paths: List[Path]): self.lib_paths = lib_paths @@ -45,14 +53,16 @@ def expand_acl(self, acl_name: str) -> List[str]: result = [] # type: List[str] for line in acl_source.splitlines(): - if self.include_guard.match(line): + if self.is_ignored_line(line): continue - + m = self.atcoder_include.match(line) if m: result.extend(self.expand_acl(m.group(1))) continue + result.append(line) + return result def expand(self, source: str) -> str: From ccecb61e5b0657149189e0d48f5dd521a8876167 Mon Sep 17 00:00:00 2001 From: Kohei Morita Date: Sun, 18 Oct 2020 03:39:58 +0900 Subject: [PATCH 2/2] format --- expander.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/expander.py b/expander.py index 51dd1fe..ff41810 100755 --- a/expander.py +++ b/expander.py @@ -17,6 +17,7 @@ class Expander: '#include\s*["<](atcoder/[a-z_]*(|.hpp))[">]\s*') include_guard = re.compile('#.*ATCODER_[A-Z_]*_HPP') + def is_ignored_line(self, line) -> bool: if self.include_guard.match(line): return True @@ -55,7 +56,7 @@ def expand_acl(self, acl_name: str) -> List[str]: for line in acl_source.splitlines(): if self.is_ignored_line(line): continue - + m = self.atcoder_include.match(line) if m: result.extend(self.expand_acl(m.group(1)))