/runtime/Python2/src/antlr4/StdinStream.py

https://github.com/antlr/antlr4
Python | 21 lines | 8 code | 4 blank | 9 comment | 0 complexity | 08c625d70b65356f9a9cca4f8efb3c6a MD5 | raw file
  1. #
  2. # Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
  3. # Use of this file is governed by the BSD 3-clause license that
  4. # can be found in the LICENSE.txt file in the project root.
  5. #
  6. #
  7. # This is an InputStream that is loaded from stdin all at once
  8. # when you construct the object.
  9. #
  10. import codecs
  11. import sys
  12. from antlr4.InputStream import InputStream
  13. class StdinStream(InputStream):
  14. def __init__(self, encoding='ascii', errors='strict'):
  15. bytes = sys.stdin.read()
  16. data = codecs.decode(bytes, encoding, errors)
  17. super(type(self), self).__init__(data)