2 * Copyright (C) 2018 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
35 sys.stdout.write('Answer: {0:g}\nEnter an expression:\n'.format($2))
40 yyerror('Error, please try again:\n')
44 E : %space (?E{t_def.AST.Add}E '+' E) {
47 | %space (?E{t_def.AST.Sub}E '-' E) {
50 | %space (?E{t_def.AST.Mul}E '*' E) {
53 | %space (?E{t_def.AST.Div}E '/' E) {
59 | %space (?E{t_def.AST.Neg}'-' E) %prec UMINUS {
67 sys.stdout.write('{0:s}\n'.format(s))