Skip to content
Snippets Groups Projects
Commit 766565a0 authored by Taddeüs Kroes's avatar Taddeüs Kroes
Browse files

Added function to write statements directly to a file.

parent ab89115a
No related branches found
No related tags found
No related merge requests found
def write_statements(statements):
'''Write a list of statements to valid assembly code.'''
s = '';
for i, statement in enumerate(statements):
......@@ -11,7 +12,7 @@ def write_statements(statements):
line = '#' + name
if args['inline']:
newline = '\t\t'
newline = ' '
elif statement_type == 'directive':
line = '\t' + name
elif statement_type == 'command':
......@@ -22,3 +23,9 @@ def write_statements(statements):
s += newline + line
return s
def write_to_file(filename, statements):
'''Convert a list of statements to valid assembly code and write it to a
file.'''
s = write_statements(statements)
open(filename, 'w+').write(s).close()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment