diff -r e46fa477007b -r 66c9591b733d linetypes.py --- a/linetypes.py Fri May 24 15:32:10 2019 +0300 +++ b/linetypes.py Fri May 24 17:37:10 2019 +0200 @@ -16,24 +16,27 @@ def typename(self): return 'empty line' +class MetaCommand: + def __init__(self, text, style = 'old'): + self.text = text + def __repr__(self): + return str.format('linetypes.MetaCommand({text!r})', + text = self.text, + ) + def textual_representation(self): + return ('0 ' + self.text).strip() + def typename(self): + return 'metacommand' + class Comment: def __init__(self, text, style = 'old'): - if style == 'old' and text.startswith('//'): - self.text = text[2:].strip() - self.style = 'new' - else: - self.text = text - self.style = style + self.text = text def __repr__(self): - return str.format('linetypes.Comment({text!r}, {style!r})', + return str.format('linetypes.Comment({text!r})', text = self.text, - style = self.style, ) def textual_representation(self): - if self.style == 'old': - return '0 ' + self.text - else: - return '0 // ' + self.text + return '0 //' + self.text def typename(self): return 'comment' @@ -113,3 +116,16 @@ return result def typename(self): return 'contour line segment' + +class Error: + def __init__(self, line, reason): + self.line = line + self.reason = reason + def __repr__(self): + return str.format( + 'linetypes.Error(line = {line!r}, reason = {reason!r})', + line = self.line, + reason = self.reason, + ) + def textual_representation(self): + return self.line