-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpseudo_string.py
More file actions
37 lines (30 loc) · 866 Bytes
/
Copy pathpseudo_string.py
File metadata and controls
37 lines (30 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/python
import token_string
import translate
import sys
import re
def main():
if len(sys.argv) > 2:
print "pseudo: " + " ".join(sys.argv) + ". Too many arguments. Usage: pseudo file"
exit()
#elif len(sys.argv) < 2:
#print "pseudo: Too few arguments. Usage: pseudo file"
#exit()
#filename = sys.argv[1]
#if re.match(r'(.*)\.psu$', filename) == None:
#print "pseudo: Not a '.psu' file. Usage: pseudo file"
#exit()
#f = open(filename, 'r')
str = ""
for line in sys.stdin:
str = str + line
tokens = token_string.tokenize(str)
translation = translate.parse(tokens)
#f.close()
code = open("translated_code" + '.py', 'w+')
code.write(translation)
code.close()
exec(translation)
print "Code has been run and has been translated into " + "translated_code" + ".py"
if __name__ == "__main__":
main()