forked from rpavlik/cmake-multitool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dump-parsed.py
executable file
·63 lines (50 loc) · 1.45 KB
/
dump-parsed.py
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
#!/usr/bin/env python
"""
Script that dumps the internal parse tree used by the CMakeScript packages.
Original Author:
2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
http://academic.cleardefinition.com
Iowa State University HCI Graduate Program/VRAC
Copyright Iowa State University 2010.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
"""
###
# standard packages
import sys
import os
import subprocess
from optparse import OptionParser
###
# third-party packages
# - none
###
# internal packages
import cmakescript
class App:
def __init__(self, args_in=sys.argv[1:]):
self.args_in = args_in
def main(self):
for infile in self.args_in:
print
self.processFile(infile)
def processFile(self, filename):
try:
parser = cmakescript.parse_file(filename)
except cmakescript.IncompleteStatementError:
print
"Error parsing file: IncompleteStatementError"
return None
except cmakescript.UnclosedChildBlockError:
print
"Error parsing file: UnclosedChildBlockError"
return None
tree = cmakescript.CMakeBlock(parser.parsetree)
return repr(tree)
###
# __main__
if __name__ == "__main__":
## Can be used as a tool when executed directly
app = App()
app.main()