Merge pull request #2336 from m-novikov/stdin-stream

Add StdninStream for python3 runtime. Closes: #2271
This commit is contained in:
Terence Parr 2018-07-27 17:18:36 -07:00 committed by GitHub
commit 7d0787e29c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -187,4 +187,5 @@ YYYY/MM/DD, github id, Full name, email
2018/05/17, sinopsysHK, Eric Bardes, sinofwd@gmail.com
2018/05/23, srvance, Stephen Vance, steve@vance.com
2018/06/14, alecont, Alessandro Contenti, alecontenti@hotmail.com
2018/06/16, EternalPhane, Zongyuan Zuo, eternalphane@gmail.com
2018/06/16, EternalPhane, Zongyuan Zuo, eternalphane@gmail.com
2018/07/27, Maksim Novikov, mnovikov.work@gmail.com

View File

@ -0,0 +1,11 @@
import codecs
import sys
from antlr4.InputStream import InputStream
class StdinStream(InputStream):
def __init__(self, encoding:str='ascii', errors:str='strict') -> None:
bytes = sys.stdin.buffer.read()
data = codecs.decode(bytes, encoding, errors)
super().__init__(data)