v2.4.0-generation

This commit is contained in:
Louis Rubet 2022-02-28 16:40:09 +01:00
parent fa69c3c959
commit 325a353d02
10 changed files with 125 additions and 156 deletions

View file

@ -2,7 +2,7 @@ name: CMake
on:
pull_request:
branches: [ v2.4.0-devel ]
branches: [ v2.4.0-devel, master ]
env:
BUILD_TYPE: Release

View file

@ -46,6 +46,7 @@ Be carefull, compatibility is broken on these points compared to last version 2.
- Removed `sqr` function, please use `sq` instead (prev. existing for HP28S compatibility).
- Removed CtrlC for interrupting a program (considered useless).
- Removed old memory management, efficient but poorly maintainable.
- Removed man page generation.
### Fixed

View file

@ -91,13 +91,5 @@ add_executable(rpn ${RPN_SRC_FILES} ${LINENOISE_NG_SRC_FILES})
target_link_libraries(rpn mpfr)
target_link_libraries(rpn gmp)
# man
add_custom_target(man ALL)
add_custom_command(
OUTPUT ${PROJECT_SOURCE_DIR}/doc/rpn.1.gz
COMMAND gzip -f -k ${PROJECT_SOURCE_DIR}/doc/rpn.1
)
# install
install(TARGETS rpn DESTINATION bin)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/doc/rpn.1.gz DESTINATION ${CMAKE_INSTALL_PREFIX}/man/man1)

View file

@ -4,60 +4,26 @@ rpn is proposed for **GNU/Linux**.
It can be generated following the steps below.
## Version identification
rpn is dynamically linked against GNU MP and GNU MPFR and integrates [linenoise-ng](https://github.com/louisrubet/linenoise-ng.git) and [mpreal](http://www.holoborodko.com/pavel/mpfr/) code as git submodules.
rpn is dynamically linked against GNU MP and GNU MPFR.
and embeds the source code of linenoise-ng and as a submodule
It is necessary to get MPFR to generate rpn
## Install GNU MPFR headers
ubuntu 20.04
git libmpfr6 cmake
- download **GNU MPFR** from http://www.mpfr.org
- install it with usual autotools commands `./configure && make && make install`
## Generate rpn
- clone [rpn project](https://github.com/louisrubet/rpn/) or download a zipped version from [the release directory](https://github.com/louisrubet/rpn/releases)
## Generate and install under Ubuntu 20.04 LTS
```shell
git clone https://github.com/louisrubet/rpn.git
```
- make
CMake must be installed on the generation machine
```shell
cd rpn/
mkdir build
cd build && cmake .. && make
```
- install
```
cd rpn/build
sudo apt install git cmake g++ libmpfr6 libmpfr-dev
git clone https://github.com/louisrubet/rpn/
mkdir -p rpn/build && cd rpn/build
cmake ..
make -j
sudo make install
```
- packages
To build RPM package you should install CMake 2.6.0 or higher
## Generate and install under Fedora 35
```shell
cd rpn/build
sudo make package
[100%] Built target rpn
Run CPack packaging tool...
CPack: Create package using DEB
(...)
CPack: Create package using RPM
(...)
CPack: Create package using TGZ
(...)
sudo dnf install git cmake g++ mpfrf mpfr-devel
git clone https://github.com/louisrubet/rpn/
mkdir -p rpn/build && cd rpn/build
cmake ..
make -j
sudo make install
```

View file

@ -17,7 +17,7 @@ A help command is provided by rpn:
```
rpn> help
rpn v2.3.2, (c) 2017 <louis@rubet.fr>, GNU LGPL v3
rpn v2.4.0, (c) 2022 <louis@rubet.fr>, GNU LGPL v3
Reverse Polish Notation language
@ -47,6 +47,7 @@ rpn> 2 sqrt
```
### **programs** and **variables**
```
rpn> << rot * swap 2 / neg dup sq rot - sqrt >> 'quadratic_solution' sto
rpn> 1 2 -3 quadratic_solution
@ -77,7 +78,7 @@ rpn>
### object types
The following objects are managed: **floating numbers**, **complexes**, **symbols**, **strings**, **programs**, plus language **keywords** (commands and flow controls)
The following objects are managed: **floating numbers**, **complexes**, **symbols**, **strings**, **programs**, plus language **keywords** (commands and flow controls).
```
5> 12.3456
4> (1,-2.33)
@ -89,7 +90,7 @@ rpn>
### structured programming
Provided loop keywords **for|start..next|step**, **do..until**, **while..repeat** and control keywords **if..then..[else]..end**, **ift**, **ifte** allow you to program powerfull algorithms
Provided loop keywords **for|start..next|step**, **do..until**, **while..repeat** and control keywords **if..then..[else]..end**, **ift**, **ifte** allow you to program powerfull algorithms.
### command line
@ -99,15 +100,12 @@ Autocompletion works like those in Linux shells, with keys \<tab\>, Ctrl-R \<sea
## entry
**reals** can be entered in decimal, binary, hexadecimal or arbitrary base from 2 to 62
- **reals** can be entered in decimal, binary, hexadecimal or arbitrary base from 2 to 62.
- Binaries (base 2) are entered as `0b<number>` or `0B<number>`.
- Hexadecimals (base 16) are entered as `0x<number>` or `0X<number>`.
- Arbitrary base numbers are entered as `<base>b<number>`.
- Representation can be individualy changed with keywords `dec`, `bin`, `hex` and `<n> base`.
binaries (base 2) are entered as `0b<number>` or `0B<number>`
hexadecimals (base 16) are entered as `0x<number>` or `0X<number>`
arbitrary base numbers are entered as `<base>b<number>`
representation can be individualy changed with keywords `dec`, `bin`, `hex` and `<n> base`
ex:
```
@ -258,9 +256,9 @@ rpn> 7b1252 dec
|`next`| used with start and for
|`step`| used with start and for
|`do`| `do (instructions) until (condition) end`
|`until` `unti` | used with do
|`while` `whil`| `while (test-instruction) repeat (loop-instructions) end`
|`repeat` `repea`| used with while
|`until` | used with do
|`while` | `while (test-instruction) repeat (loop-instructions) end`
|`repeat` | used with while
### store

View file

@ -1,23 +0,0 @@
# Development methods
## Versioning
The software version number conforms to [SemVer semantic 2.0.0](https://semver.org/), aka `v<MAJOR>.<MINOR>.<PATCH>`
Suffixes `alpha` or `beta` are not used
## Workflow
This project conforms to the usual **gitflow** workflow as seen in ![gitflow image](https://i.stack.imgur.com/QxVmJ.png)
Report to Vincent Driessen page [a-successful-git-branching-model](http://nvie.com/posts/a-successful-git-branching-model/) for a detailed explanation of this workflow
Branches are named as follows:
|branch name| description |
|-|-|
|`master`|usual main git branch, always holds the last software version and its tag plus documents not changing the sw version |
|`hotfix-vx.y.z`|hotfixes branches|
|`release-vx.y.0`|releases branches, patch number should always be 0 here|
|`develop`|dev branch|
|`any name`|feature branches|

123
README.md
View file

@ -1,67 +1,118 @@
# **rpn** - **R**everse **P**olish **N**otation language [![License: LGPLv3](https://www.gnu.org/graphics/lgplv3-88x31.png)](https://www.gnu.org/licenses/lgpl-3.0.en.html)
# **rpn** - **R**everse **P**olish **N**otation CLI calculator [![License: LGPLv3](https://www.gnu.org/graphics/lgplv3-88x31.png)](https://www.gnu.org/licenses/lgpl-3.0.en.html)
### a math functional language using reverse polish notation
A math functional language using reverse polish notation.
```
### A math functional language using reverse polish notation
```rpn
rpn> 1 2 + 2 sqrt
2> 3
1> 1.4142135623730950488
```
### arbitrary precision provided by GNU MPFR
### Manipulating reals, complexes, strings, variables on a stack
```rpn
rpn> 1 2 + 2
2> 3
1> 2
rpn> r->c sq conj (1,1) /
(-3.5,-8.5)
```
```rpn
rpn> "sqrt of 2 is " 2 sqrt ->str +
"sqrt of 2 is 1.4142135623730950488016887242096980786"
```
```rpn
rpn> << -> x << x 3 ^ 2 x * - 3 + >> >> 'f' sto
rpn> 2 f
7
rpn> (1,2) f
(-10,-6)
```
### Arbitrary precision provided by GNU MPFR
```rpn
rpn> 256 prec
rpn> pi
3.1415926535897932384626433832795028841971693993751058209749445923078164062862
rpn>
```
### variables, programs
```
rpn> << rot * swap 2 / chs dup sq rot - sqrt >> 'quad' sto
rpn> << -> x y << x y + ln >> >> 'P' sto
### Variables, strings, structured programming
```rpn
rpn> « rot * swap 2 / chs dup sq rot - sqrt » 'quad' sto
rpn> 0 1 10000 for i i sq + next
333383335000
rpn> a 1 > if then a sq 'calc' eval else 'stop' eval end
```
### and a bunch of functions
```
### Available functions
```rpn
rpn>
Display all 150 possibilities? (y or n)
nop pow fp >= dupn next sto* exp
help sqrt min < pick step sto/ expm
h sq max <= depth ift sneg log10
? sqr re != roll ifte sinv alog10
quit abs im == rolld do eval exp10
q dec conj and over until -> log2
exit hex arg or ->str unti pi alog2
test bin c->r xor str-> while sin exp2
version base r->c not chr whil asin sinh
uname sign p->r same num repeat cos asinh
history % r->p swap size repea acos cosh
+ %CH std drop pos sto tan acosh
- mod fix drop2 sub rcl atan tanh
chs fact sci dropn if purge d->r atanh
neg mant prec del then vars r->d time
* xpon round erase else clusr e date
/ floor default rot end edit ln ticks
inv ceil type dup start sto+ log
^ ip > dup2 for sto- lnp1
Display all 146 possibilities? (y or n)
nop pow conj < pick step eval exp10
help sqrt arg <= depth ift -> log2
h sq c->r != roll ifte pi alog2
? abs r->c == rolld do sin exp2
quit sign p->r and over until asin sinh
q % r->p or ->str while cos asinh
exit %CH std xor str-> repeat acos cosh
test mod fix not chr sto tan acosh
version fact sci same num rcl atan tanh
uname mant prec swap size purge d->r atanh
history xpon round drop pos vars r->d time
+ floor default drop2 sub clusr e date
- ceil type dropn if edit ln ticks
* ip hex del then sto+ log
/ fp dec erase else sto- lnp1
inv min bin rot end sto* exp
chs max base dup start sto/ expm
neg re > dup2 for sneg log10
^ im >= dupn next sinv alog10
```
## Download
deb, rpm and tgz files can be found [there](liv/)
Available as source code and flatpak under [flathub](https://flathub.org/apps/category/Science) (_coming soon_).
## Manual
A reference manual is provided [here](MANUAL.md)
## Methods
Development methods are set at [this page](METHODS.md)
## Generation
Generation instructions can be found [here](GENERATION.md)
rpn is written in C++ and is dynamically linked against GNU MP and GNU MPFR.
It integrates [linenoise-ng](https://github.com/louisrubet/linenoise-ng.git) and [mpreal](http://www.holoborodko.com/pavel/mpfr/) code as git submodules.
It can be generated following the steps below:
## Generate and install under Ubuntu 20.04 LTS
```shell
sudo apt install git cmake g++ libmpfr6 libmpfr-dev
git clone https://github.com/louisrubet/rpn/
mkdir -p rpn/build && cd rpn/build
cmake ..
make -j
sudo make install
```
## Generate and install under Fedora 35
```shell
sudo dnf install git cmake g++ mpfrf mpfr-devel
git clone https://github.com/louisrubet/rpn/
mkdir -p rpn/build && cd rpn/build
cmake ..
make -j
sudo make install
```
## Contact, contribution, bug report

View file

@ -1,10 +0,0 @@
.TH RPN 1
.SH NAME
rpn \- Reverse Polish Notation calculator
.SH SYNOPSIS
.B rpn
.IR commands ...
.SH DESCRIPTION
.B rpn is a full-featured math-oriented structured language inspired by Hewlett-Packard Reverse Polish Lisp
Please visit https://github.com/louisrubet/rpn for source code, a manual and generation instructions

View file

@ -9,27 +9,22 @@ using std::cout, std::string, std::pair;
#include "program.h"
#include "version.h"
// description
#define ATTR_BOLD "\33[1m"
#define ATTR_OFF "\33[0m"
#define XSTR(a) STR(a)
#define STR(a) #a
static const char _description[] = ATTR_BOLD
"R" ATTR_OFF "everse " ATTR_BOLD "P" ATTR_OFF "olish " ATTR_BOLD "N" ATTR_OFF "otation language\n\nusing " ATTR_BOLD
"GMP" ATTR_OFF " v" XSTR(__GNU_MP_VERSION) "." XSTR(__GNU_MP_VERSION_MINOR) "." XSTR(
__GNU_MP_VERSION_PATCHLEVEL) " under GNU LGPL\n" ATTR_BOLD "MPFR" ATTR_OFF " v" MPFR_VERSION_STRING
" under GNU LGPL\nand " ATTR_BOLD "linenoise-ng" ATTR_OFF " v" LINENOISE_VERSION
" under BSD\n";
static const char _syntax[] = ATTR_BOLD "Syntax" ATTR_OFF ": rpn [command]\nwith optional command = list of commands";
#define MPFR_ROUND \
{"nearest (even)", MPFR_RNDN}, {"toward zero", MPFR_RNDZ}, {"toward +inf", MPFR_RNDU}, {"toward -inf", MPFR_RNDD}, \
{"away from zero", MPFR_RNDA}, {"faithful rounding", MPFR_RNDF}, { \
"nearest (away from zero)", MPFR_RNDNA \
}
static const char _description[] =
ATTR_BOLD "R" ATTR_OFF "everse " ATTR_BOLD "P" ATTR_OFF "olish " ATTR_BOLD "N" ATTR_OFF "otation CLI calculator";
static const char _syntax[] = ATTR_BOLD "Syntax" ATTR_OFF ": rpn [command]\nwith optional command = list of commands";
static const char _uname[] = ATTR_BOLD "rpn v" RPN_VERSION ", (c) 2022 <louis@rubet.fr>" ATTR_OFF;
/// @brief nop keyword implementation
///
void program::RpnNop() {
@ -45,7 +40,7 @@ void program::RpnQuit() { ERROR_CONTEXT(kGoodbye); }
///
void program::RpnHelp() {
// software name
cout << endl << ATTR_BOLD << RPN_UNAME << ATTR_OFF << endl;
cout << endl << _uname << endl;
// _description
cout << _description << endl << endl;
@ -90,7 +85,7 @@ void program::RpnHelp() {
cout << "Current rounding mode is '" << rn.first << '\'' << endl;
break;
}
cout << endl << endl;
cout << endl;
}
/// @brief whether a printed precision is in the precision min/max
@ -161,7 +156,7 @@ void program::RpnVersion() { stack_.push_front(new String(RPN_VERSION)); }
/// @brief _uname keyword implementation
///
void program::RpnUname() { stack_.push_front(new String(RPN_UNAME)); }
void program::RpnUname() { stack_.push_front(new String(_uname)); }
/// @brief history keyword implementation
///

View file

@ -4,6 +4,5 @@
#define SRC_VERSION_H_
#define RPN_VERSION GIT_VERSION // set by cmake from git tag
#define RPN_UNAME "rpn v" RPN_VERSION ", (c) 2017 <louis@rubet.fr>, GNU LGPL v3"
#endif // SRC_VERSION_H_