-
Notifications
You must be signed in to change notification settings - Fork 0
/
stan
executable file
·94 lines (84 loc) · 3.06 KB
/
stan
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env python
# A simple command line interface for stan. If you want to add your own methods,
# please modify the usage function, add a new parameter name to getopt and
# handle this parameter.
import getopt
import sys
from Grammar.Parser import Parser
from Tools.Project import Project
from Stylesheets.f77 import f77
# ==============================================================================
# This functions imports all Test Suites, adds them to a global test suite
# and then runs all tests. I moved all test related import statements to here.
# It shouldn't make much of a difference.
def RunAllTests():
from Tools.Test import TestSuite
from Scanner.RunAllTests import CreateScannerTestSuite
from AOR.RunAllTests import CreateAORTestSuite
from Grammar.RunAllTests import CreateGrammarTestSuite
from Tools.RunAllTests import CreateToolsTestSuite
ts = TestSuite('All Test', bIsMain=1)
ts.AddTest(CreateScannerTestSuite())
ts.AddTest(CreateAORTestSuite() )
ts.AddTest(CreateGrammarTestSuite())
ts.AddTest(CreateToolsTestSuite() )
ts.RunAllTests()
# ==============================================================================
def usage():
print "Usage: Parser.py [-o] [-i] [-c] [-T] [-P] <list of files>"
print
print "-o: Print the file"
print "-i: Generate interface"
print "-c: Generate calltree"
print "-T: Run unit tests (no filename required). For more detailed"
print " options use Grammar/RunAllTests directly. You can then"
print " increase the verbosity by adding '-v's or '-v 4'"
print "-P: A run with the python profiler"
# ------------------------------------
if __name__=="__main__":
bDoProfile = 0
bDoPrint = 0
bDoTest = 0
bInterface = 0
bCallTree = 0
lOpt, lArgs = getopt.getopt(sys.argv[1:],"PoTic")
for i in lOpt:
if i[0]=="-P":
bDoProfile=1
elif i[0]=="-o":
bDoPrint=1
elif i[0]=="-T":
bDoTest=1
elif i[0]=="-i":
bInterface=1
elif i[0]=="-c":
bCallTree=1
if bDoTest:
RunAllTests()
sys.exit()
if len(lArgs)<1:
usage()
if not bDoProfile:
project = Project()
ssheet = f77()
for i in lArgs:
objFile = project.oGetObjectForIdentifier(i, "file")
if bDoPrint:
print ssheet.ToString(objFile)
if bInterface:
from Analyser.Interface import GenerateInterface
from Stylesheets.f77 import f77
ssheet = f77()
for i in objFile.GetAllSubroutines():
print GenerateInterface(i, ssheet)
if bCallTree:
from Analyser.CallTree import GenerateFileCallTree
print GenerateFileCallTree(objFile,i)
else:
import profile
profile.run(
"""
project = Project()
for i in lArgs:
objFile = project.oGetObjectForIdentifier(i, "file")
""")