2 * Copyright (C) 2019 Nick Downing <nick@ndcode.org>
3 * SPDX-License-Identifier: GPL-2.0-only
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; version 2.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 51
16 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
41 # Copyright (C) 2018 Nick Downing <nick@ndcode.org>
42 # SPDX-License-Identifier: GPL-2.0-only
44 # This program is free software; you can redistribute it and/or modify it under
45 # the terms of the GNU General Public License as published by the Free Software
46 # Foundation; version 2.
48 # This program is distributed in the hope that it will be useful, but WITHOUT
49 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
50 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
53 # You should have received a copy of the GNU General Public License along with
54 # this program; if not, write to the Free Software Foundation, Inc., 51
55 # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
57 def factory(tag, *args, **kwargs):
58 return tag_to_class[tag](*args, **kwargs)
67 raise NotImplementedException()
70 mantissa = self.children[0].get_text()
71 fraction = self.children[1].get_text() if len(self.children) >= 2 else ''
72 return int(mantissa + fraction) * 10 ** -len(fraction)
75 return self.children[0].eval() + self.children[1].eval()
78 return self.children[0].eval() - self.children[1].eval()
81 return self.children[0].eval() * self.children[1].eval()
84 return self.children[0].eval() / self.children[1].eval()
87 return -self.children[0].eval()