diff --git a/bsc/__init__.py b/bsc/__init__.py index 59985f7..0a04d99 100644 --- a/bsc/__init__.py +++ b/bsc/__init__.py @@ -83,7 +83,8 @@ def compile(self): self.sema.check_files(self.source_files) if report.errors > 0: exit(1) - self.codegen.gen_files(self.source_files) + if not self.prefs.is_check: + self.codegen.gen_files(self.source_files) def import_modules(self): for sf in self.source_files: diff --git a/bsc/prefs.py b/bsc/prefs.py index 2fd31a1..45f5cfb 100644 --- a/bsc/prefs.py +++ b/bsc/prefs.py @@ -12,6 +12,7 @@ def __init__(self): self.is_library = False self.pkg_name = "" + self.is_check = False self.is_verbose = False def parse_args(self): @@ -27,14 +28,19 @@ def parse_args(self): '--lib', action = 'store_true', help = 'specifies whether the input is a library or not' ) + parser.add_argument( + '--check', action = 'store_true', + help = 'scans, parses, and checks the files without compiling.' + ) parser.add_argument( '-v', '--verbose', action = 'store_true', - help = 'Enable verbosity in the compiler while compiling' + help = 'enable verbosity in the compiler while compiling' ) args = parser.parse_args() self.is_library = args.lib self.pkg_name = args.pkg_name or "" + self.is_check = args.check self.is_verbose = args.verbose # check input file diff --git a/bsc/sym.py b/bsc/sym.py index 972d7d6..15660e4 100644 --- a/bsc/sym.py +++ b/bsc/sym.py @@ -71,7 +71,9 @@ def has_access_to(self, other): case AccessModifier.internal: return self.get_pkg() == other.get_pkg() case AccessModifier.private: - return self.get_mod() == other.get_mod() + if self_mod := self.get_mod(): + if other_mod := other.get_mod(): + return self_mod == other_mod return False def kind_of(self): diff --git a/tests/check_invalid_code.py b/tests/check_invalid_code.py index c2fc3e2..b5c9919 100644 --- a/tests/check_invalid_code.py +++ b/tests/check_invalid_code.py @@ -17,7 +17,7 @@ for i, bs_file in enumerate(bs_files): out_file = bs_file[:-3] + ".out" print(f" [{i+1}/{len(bs_files)}] {utils.bold(bs_file)}", end = "") - res = utils.execute(f"python3", "bsc", bs_file) + res = utils.execute(f"python3", "bsc", "--check", bs_file) if res.exit_code == 0: print(utils.bold(utils.red(" -> FAILED"))) fail += 1