Generate an InstructionFormat enum.

This is a no-payload enum which will have the same variants as InstructionData.
This makes it possible to talk about the format of an instruction without
actually creating an InstructionData instance.
This commit is contained in:
Jakob Stoklund Olesen
2016-05-13 11:54:05 -07:00
parent 3909cdbc2d
commit e3927e205e
4 changed files with 57 additions and 7 deletions

View File

@@ -49,9 +49,12 @@ class Formatter(object):
assert self.indent != '', 'Already at top level indentation'
self.indent = self.indent[0:-self.shiftwidth]
def line(self, s):
def line(self, s=None):
"""And an indented line."""
self.lines.append('{}{}\n'.format(self.indent, s))
if s:
self.lines.append('{}{}\n'.format(self.indent, s))
else:
self.lines.append('\n')
def writelines(self, f=None):
"""Write all lines to `f`."""