3 # Copyright (C) 2018 Nick Downing <nick@ndcode.org>
4 # SPDX-License-Identifier: GPL-2.0-only
6 # This program is free software; you can redistribute it and/or modify it under
7 # the terms of the GNU General Public License as published by the Free Software
8 # Foundation; version 2.
10 # This program is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 # You should have received a copy of the GNU General Public License along with
16 # this program; if not, write to the Free Software Foundation, Inc., 51
17 # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 import xml.etree.ElementTree
25 root = y_tab.yyparse(ast.AST.TranslationUnit)
26 element.serialize(root, 'a.xml', 'utf-8')
27 root = element.deserialize('a.xml', ast.factory, 'utf-8')
29 context = ast.Context()
30 root.translate_translation_unit(context)
31 sys.stdout.write(''.join(context.lines))