mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Fix compile issue where system don't have python2. I get error below. /bin/sh: line 1: ./treatasm.py: cannot execute: required file not found make[1]: *** [Makefile:15: httpd.rel] Error 127 Debian has python3 a long time so use it. See https://wiki.debian.org/Python
26 lines
588 B
Python
Executable File
26 lines
588 B
Python
Executable File
#!/usr/bin/env python3
|
|
import re
|
|
import sys
|
|
|
|
isBanked = False
|
|
|
|
regex_bank = re.compile(r'^\s*\.area\s+BANK\d+\s*\(CODE\)')
|
|
regex_const = re.compile(r'^\s*\.area\s+CONST\s*\(CODE\)')
|
|
regex_area = re.compile(r'^\s*\.area\s+\(CODE\)')
|
|
|
|
with open(sys.argv[1], "r") as file:
|
|
for line in file:
|
|
line = line.rstrip()
|
|
bmatch = re.search(regex_bank, line)
|
|
if bmatch:
|
|
isBanked = True
|
|
print(line)
|
|
else:
|
|
cmatch = re.search(regex_const, line)
|
|
if not isBanked or not cmatch:
|
|
print(line)
|
|
amatch = re.search(regex_area, line)
|
|
if amatch:
|
|
isBanked = False
|
|
print(line)
|