forked from jasder/antlr
Merge pull request #2336 from m-novikov/stdin-stream
Add StdninStream for python3 runtime. Closes: #2271
This commit is contained in:
commit
7d0787e29c
|
@ -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
|
||||
|
|
|
@ -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)
|
Loading…
Reference in New Issue