Rename to picalc.*, improve messages slightly
[picalc.git] / picalc.py
1 #!/usr/bin/env python3
2
3 # Copyright (C) 2018 Nick Downing <nick@ndcode.org>
4 # SPDX-License-Identifier: GPL-2.0-only
5 #
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.
9 #
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
13 # details.
14 #
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
18
19 import t_def
20 import element
21 import sys
22 import y_tab
23
24 sys.stdout.write('Enter an expression:\n')
25 sys.stdout.flush()
26 _ast = y_tab.yyparse(t_def.AST)
27 element.serialize(_ast, sys.stdout)
28 #element.serialize(_ast, 'a.xml', 'utf-8')
29 #_ast = element.deserialize('a.xml', t_def.factory, 'utf-8')
30 for i in _ast.children:
31   sys.stdout.write('{0:g}\n'.format(i.eval()))