-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
23 lines (18 loc) · 694 Bytes
/
Copy pathmain.py
File metadata and controls
23 lines (18 loc) · 694 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import sys
from antlr4 import *
from SubsetJavaScriptLexer import SubsetJavaScriptLexer
from SubsetJavaScriptParser import SubsetJavaScriptParser
from JavaScript2PythonTranspiler import JavaScript2PythonTranspiler
def main(argv):
input = FileStream(argv[1])
lexer = SubsetJavaScriptLexer(input)
stream = CommonTokenStream(lexer)
parser = SubsetJavaScriptParser(stream)
tree = parser.program()
with open("output.py","w") as output:
JavaScript2PythonListen = JavaScript2PythonTranspiler(output)
walker = ParseTreeWalker()
walker.walk(JavaScript2PythonListen, tree)
output.close()
if __name__ == '__main__':
main(sys.argv)