#! /bin/sh
# Copyright (C) 2020 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
cat >input < 1+2*3
7
> '
cat >input < (1+2) * 3
9
> '
run -noerr 0 '> (1+2) * 3
9
> ' -p
cat >input < a = 256
256
> sqrt (a)
16
> '
cat >input < a = .16
0.16
> b = 10 ^ 2
100
> sqrt (a * b)
4
> '
cat >input < *
> err: 1.1: syntax error: expected end of file or - or ( or exit or double precision number or function or variable before *'
cat >input < 1 + 2 * * 3
> err: 1.9: syntax error: expected - or ( or double precision number or function or variable before *'
cat >input < 100%
100
> err: 1.4: error: invalid character'
cat >input < 1 / 0
> err: 1.1-5: error: division by zero'
## ------------ ##
## Completion. ##
## ------------ ##
# Check completion after an operator.
sed -e 's/\\t/ /g' >input < (1+
( cos ln
- double precision number sin
atan exp sqrt
> (1+
> err: 1.4: syntax error: expected - or ( or double precision number or function or variable before end of file'
# Check the completion of a word.
sed -e 's/\\t/ /g' >input < (atan ( ''
> err: 1.9: syntax error: expected - or ( or double precision number or function or variable before end of file'
# Check the completion at the very beginning.
sed -e 's/\\t/ /g' >input < e
end of file exit exp ''
> e
0
> err: '