diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2023-04-11 17:30:08 +0300 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2023-04-11 18:41:56 +0300 |
| commit | a38b64e1a1bf14dd9c42629f219b0e422aebe52a (patch) | |
| tree | 8cc08f712ddd3f8573d2b7c8aa243fcd1b6e52df /src/asm_pass0.py | |
| parent | e240ef3e9a2854cfe390b47fb0b3d519c095193b (diff) | |
Add hover and go to definition to extension
Diffstat (limited to 'src/asm_pass0.py')
| -rw-r--r-- | src/asm_pass0.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/asm_pass0.py b/src/asm_pass0.py new file mode 100644 index 0000000..be6c46a --- /dev/null +++ b/src/asm_pass0.py @@ -0,0 +1,48 @@ +from dataclasses import dataclass +from asm_ops import * +from asm_eval import * + +@dataclass +class Result0Line: + line_num: int + src_file: str + line: str + +@dataclass +class Result0: + lines: list[Result0Line] + options: Options + operations: OpExpansionDict + +def pass_0(lines: list[str], file_name: str) -> Result0: + options = Options() + result_lines: list[Result0Line] = [] + operations: OpExpansionDict = default_expansions.copy() + + for (line_num, line) in enumerate(lines): + line = line.split(";")[0].strip() + if line == "": continue + keyword, *args = line.lower().split() + match keyword: + case "@include": + asm_file_name = args[0] + with open(asm_file_name, "r") as f: + for incl_line in f.readlines(): + result_lines.append(Result0Line( + src_file=asm_file_name, + line_num=line_num, + line=incl_line + )) + + case _: + result_lines.append(Result0Line( + src_file=file_name, + line_num=line_num, + line=line + )) + + return Result0( + operations=operations, + options=options, + lines=result_lines + ) |
