OILS / opy / _regtest / src / osh / ast_gen.py View on Github | oilshell.org

34 lines, 17 significant
1#!/usr/bin/env python
2"""
3ast_gen.py
4"""
5
6import sys
7
8from osh.meta import types, Id
9from asdl import asdl_ as asdl
10from asdl import gen_cpp
11
12lex_mode_e = types.lex_mode_e
13
14
15def 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
29if __name__ == '__main__':
30 try:
31 main(sys.argv)
32 except RuntimeError as e:
33 print >>sys.stderr, 'FATAL: %s' % e
34 sys.exit(1)