Skip to content

Commit

Permalink
fix lists and improve auto decompile functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
TabulateJarl8 committed May 26, 2021
1 parent 99d841b commit ce466c0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ti842py/__version__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__title__ = "ti842py"
__description__ = "TI-BASIC to Python 3 Transpiler"
__url__ = "https://github.com/TabulateJarl8/ti842py"
__version__ = "0.6.3"
__version__ = "0.6.4"
__author__ = "Tabulate"
__author_email__ = "[email protected]"
__license__ = "GPLv3"
Expand Down
16 changes: 15 additions & 1 deletion ti842py/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,23 @@
from __version__ import __version__


def isUTF8(file):
with open(file, 'rb') as f:
data = f.read()
try:
decoded = data.decode('UTF-8')
except UnicodeDecodeError:
return False
else:
for ch in decoded:
if 0xD800 <= ord(ch) <= 0xDFFF:
return False
return True


def transpile(infile, outfile="stdout", decompileFile=True, forceDecompile=False, multiplication=True, run=False):

decode = os.path.splitext(infile)[1].lower() == ".8xp" and decompileFile is True
decode = not isUTF8(infile) and decompileFile is True

if decode is True or forceDecompile is True:
# Decompile 8Xp file
Expand Down
5 changes: 5 additions & 0 deletions ti842py/tiParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ def convertLine(self, index, line):
# TODO: possible curses interface instead of just printing and outputting

statement = ""

# Fix lists
number_table = {'₁': '1', '₂': '2', '₃': '3', '₄': '4', '₅': '5', '₆': '6'}
line = re.sub('(?:L|l)([₁₂₃₄₅₆]){1}', lambda m: 'L' + number_table[m.group(1)], line)

# TODO: Make rules for :, dont fully understand it yet
if self.skipLine > 0:
self.skipLine -= 1
Expand Down

0 comments on commit ce466c0

Please sign in to comment.