2010-08-11 22:33:04 +04:00
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
|
2011-04-22 09:38:31 +04:00
|
|
|
import validator.testcases.scripting as scripting
|
2010-12-25 03:05:36 +03:00
|
|
|
from validator.testcases.javascript.traverser import MockBundler
|
|
|
|
import validator.testcases.javascript.traverser
|
2011-04-22 09:38:31 +04:00
|
|
|
import validator.testcases.javascript.spidermonkey as spidermonkey
|
2010-12-25 03:05:36 +03:00
|
|
|
validator.testcases.javascript.traverser.DEBUG = True
|
2010-08-11 22:33:04 +04:00
|
|
|
|
2011-04-22 09:38:31 +04:00
|
|
|
if __name__ == '__main__':
|
|
|
|
if len(sys.argv) > 1:
|
|
|
|
path = sys.argv[1]
|
|
|
|
script = open(path).read()
|
|
|
|
err = MockBundler()
|
|
|
|
scripting.test_js_file(err=err,
|
|
|
|
filename=path,
|
|
|
|
data=script)
|
|
|
|
else:
|
|
|
|
err = MockBundler()
|
|
|
|
trav = validator.testcases.javascript.traverser.Traverser(err, "stdin")
|
|
|
|
trav._push_context()
|
|
|
|
while True:
|
|
|
|
line = sys.stdin.readline()
|
|
|
|
tree = spidermonkey.get_tree(line, err)
|
|
|
|
if tree is None:
|
|
|
|
continue
|
|
|
|
tree = tree["body"]
|
|
|
|
for branch in tree:
|
|
|
|
output = trav._traverse_node(branch)
|
|
|
|
if output is not None:
|
|
|
|
print output.output()
|
|
|
|
|