-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cocas] Move exception class declarations into modules
- Loading branch information
Showing
21 changed files
with
125 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from .assembler import assemble_files, assemble_module | ||
from .ast_builder import build_ast | ||
from .exceptions import CdmAssemblerException | ||
from .macro_processor import process_macros | ||
from .object_generator import generate_object_module | ||
from .targets import import_target, list_assembler_targets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from colorama import Fore, Style | ||
|
||
from cocas.assembler import CdmAssemblerException | ||
from cocas.linker import CdmLinkException | ||
from cocas.object_file import CdmObjectFileException | ||
|
||
|
||
def log_exception(tag: str, message: str): | ||
print(f'[{tag}] {Fore.RED}ERROR{Fore.RESET}') | ||
print(message) | ||
|
||
|
||
def log_os_error(e: OSError): | ||
message = e.strerror | ||
if e.filename is not None: | ||
message += f': {Style.BRIGHT}{e.filename}{Style.NORMAL}' | ||
log_exception("Main", message) | ||
exit(1) | ||
|
||
|
||
def log_asm_exception(e: CdmAssemblerException): | ||
print(f'[{e.tag.value}] {Fore.RED}ERROR{Fore.RESET} at line {Style.BRIGHT}{e.line}{Style.RESET_ALL} of ' | ||
f'{Style.BRIGHT}{e.file}{Style.RESET_ALL}') | ||
print(f'{e.description}') | ||
|
||
|
||
def log_object_file_exception(e: CdmObjectFileException): | ||
print(f'[Object file] {Fore.RED}ERROR{Fore.RESET} at line {Style.BRIGHT}{e.line}{Style.RESET_ALL} of ' | ||
f'{Style.BRIGHT}{e.file}{Style.RESET_ALL}') | ||
print(f'{e.description}') | ||
|
||
|
||
def log_link_exception(_: CdmLinkException): | ||
# todo: find this code from previous revisions | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .debug_export import debug_export, write_debug_export | ||
from .exceptions import CdmLinkException | ||
from .image import write_image | ||
from .linker import link |
Oops, something went wrong.