1 | #!/usr/bin/env python
|
2 | """
|
3 | ast_gen.py
|
4 | """
|
5 |
|
6 | import sys
|
7 |
|
8 | from osh.meta import types, Id
|
9 | from asdl import asdl_ as asdl
|
10 | from asdl import gen_cpp
|
11 |
|
12 | lex_mode_e = types.lex_mode_e
|
13 |
|
14 |
|
15 | def main(argv):
|
16 | #print lex_mode_e
|
17 | #print dir(lex_mode_e)
|
18 |
|
19 | app_types = {'id': asdl.UserType(Id)}
|
20 | with open('osh/types.asdl') as f:
|
21 | asdl_module, _ = asdl.LoadSchema(f, app_types)
|
22 |
|
23 | v = gen_cpp.CEnumVisitor(sys.stdout)
|
24 | v.VisitModule(asdl_module)
|
25 |
|
26 | # NOTE: MakeTypes does things in a certain order.
|
27 |
|
28 |
|
29 | if __name__ == '__main__':
|
30 | try:
|
31 | main(sys.argv)
|
32 | except RuntimeError as e:
|
33 | print >>sys.stderr, 'FATAL: %s' % e
|
34 | sys.exit(1)
|