console.py 445 B

12345678910111213141516
  1. import base
  2. class ConsoleInput(base.InputSource):
  3. def __init__(self, token_stream):
  4. self.stream = token_stream
  5. def run(self):
  6. while True:
  7. try:
  8. cmd = raw_input('> ')
  9. for token in cmd.split(' '):
  10. token = token.strip()
  11. if token:
  12. self.stream.add_token(token)
  13. except EOFError:
  14. return