- if code[0].isspace():
- toks = code.lstrip().split()
- self.acc = toks[0]
- if 1 == len(toks):
- self.type = 'value'
- elif 3 == len(toks):
- amt_dec = Decimal(toks[1])
- exp = amt_dec.as_tuple().exponent
- assert isinstance(exp, int)
- self.amt = (f'{amt_dec:.1f}…' if exp < -2
- else f'{amt_dec:.2f}')
- self.curr = toks[2]
- self.type = 'value'
- else:
- self.type = 'intro'
+ if not code[0].isspace():
+ self.error = 'non-intro line not indented'
+ return
+ toks = code.lstrip().split()
+ self.acc = toks[0]
+ if len(toks) not in {1, 3}:
+ self.error = 'illegal number of tokens'
+ return
+ if 3 == len(toks):
+ amt_dec = Decimal(toks[1])
+ exp = amt_dec.as_tuple().exponent
+ assert isinstance(exp, int)
+ self.amt = (f'{amt_dec:.1f}…' if exp < -2
+ else f'{amt_dec:.2f}')
+ self.curr = toks[2]