-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathast_generator.py
More file actions
34 lines (25 loc) · 874 Bytes
/
ast_generator.py
File metadata and controls
34 lines (25 loc) · 874 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
import sys
from pygccxml import utils
from pygccxml import declarations
from pygccxml import parser
def pygccxml_parser(filename):
"""
Implementation of pygccxml parser
"""
generator_path, generator_name = utils.find_xml_generator()
# Configure the xml generator
xml_generator_config = parser.xml_generator_configuration_t(
xml_generator_path=generator_path,
xml_generator=generator_name)
filename = filename
decls = parser.parse([filename], xml_generator_config)
global_namespace = declarations.get_global_namespace(decls)
ns = global_namespace.namespace("sample_namespace")
return declarations.print_declarations(ns)
def main():
pygccxml_parser(sys.argv[1])
if __name__ == '__main__':
if len(sys.argv) == 2:
main()
else:
raise Exception('Please input only one header file!')