Leonardus
|
Leonardus is licensed under the GNU General Public License v3.0.
See the LICENSE file for more details.
Leonardus is a minimalist, stack-based programming system designed as
a flexible framework for implementing and exploring algorithms. The syntax
and semantics of its scripting language, LeoScript, are inspired by
PostScript and Forth. It is extended with a prototype-based, object-oriented
paradigm and provides a concise and expressive environment for learning and
experimentation.
The project name is a nod to Leonardus Pisanus, who was named and
became known as Fibonacci.
For the documentation open the GitLab Pages of the project.
There you can find the latest user and developer information including the
parts generated from the source code files.
Alternatively look for it in the Docker image under
/usr/local/share/doc/leonardus/
.
Type lc -h
and lb -h
to get command line help.
The GitLab pipelines generate a Docker image on Docker hub. Pull the image
hagenbund2/leonardus and run it with:
docker run -it --rm hagenbund2/leonardus:latest
The CLI applications lc
and lb
will be available in the opening shell.
Or even execute the calculator within the docker image in one line with e.g.:
docker run --rm hagenbund2/leonardus lc 41 1 add
Install, if not already on your system:
To build the artifacts and run all end2end tests:
make e2e
Optionally install Doxygen and LaTeX to generate the HTML documentation
and the man pages in ./public/
with:
make public
To run an example:
make leon; make parser; ./lb Examples/Factorial.leo
To run all end2end tests:
make e2e
To run all examples:
make runxtest
Use it as a calculator:
lc 25346 95095 gcd
lc 1 2 1 33 { mul } for
Leonardus is an open-source project.
To use Leonardus, you can use the published Docker image or compile
the programs yourself.
The following interests could be addressed by the project:
The project and the code are written in English.
For mathematical operators, whose creation is a primary goal of the project,
multilingualism is enabled.
Readability and clarity of the program code take precedence over optimization
in the implementation.
All artifacts can be built with a minimal toolset. Currently, these are
the GNU C++ compiler, make, flex, Bash, Boost and git. The project is hosted
on GitLab, and the environment's features like CI/CD are used. However, a
build of all artifacts and tests must always be possible without GitLab.
Documentation is preferably embedded in the code and should be cleanly
extractable with Doxygen. All documentation is included in the git repository.
The main branch of the code must always allow a build of the artifacts
at the turn of the day, and these must pass the automated tests.
There is a constant refactoring of the code and documentation.
There is an extensive catalog of automated tests. When making design
decisions, the testability of a possible solution is given high priority.
No technical debt should be accumulated. Corresponding tickets always
have high priority.
This project leverages the following core technologies:
Optional tools:
Recommendations:
gs
without rendering, you can set the environment export GS_DEVICE=nullpage
.Tools from the GitLab pipeline:
There are three build types for different software processes
and environments: DEVELOP PRODUCTION PROFILE
If a LeoScript operator is coded directly in C++, it is referred to as core code.
The second interpreter pass reads and interprets its leon-format input.
The exchange format between the first interpreter pass called "parser"
und the second interpreter pass called "leon". Stored leon-format files
use the file name extension .leon
The stack-based scripting language and its file format of project Leonardus.
Each line of code can contain commands, which are short, case-sensitive
keywords, and operands, which are pushed onto a data stack and
manipulated by operators. The language supports various data types,
including integers, real numbers, booleans, strings, arrays, stacks and
dictionaries, and follows a reverse Polish notation (RPN) syntax, where
operators follow their operands.
Most of the core code operators are referenced as values in the dictionaries
at start up time. They are called registered.
There are other core code operators for internal use. These are called
unregistered.
A subspecies of semantic objects, that operates on other semantic
objects, the stacks or the interpreter itself. Some of the operators are
LeoScript procedures and the others are core code.
A one character code for each SO class. The virtual ot() member function
of all SO classes return this code and allows explicit type-based decisions
beside the C++ language poylmorphisms.
See: object types
Optimzes LeoScript procedures as part of the bind
operator.
The first interpreter pass checks the syntax and converts the program
into leon-format.
The procedure level counts the nesting level of curly braces in the
program code.
For the classes Interpreter and Context there are attributes, together with
setters and getters, which change the behaviour. These properties can be set
with LeoScript operators.
To distinguish them from semantic objects (SOs), the objects at the LeoScript
level are referred to as prototype-based objects (PTBOs). They provide the
features of inheritance and encapsulation.
The PostScript Red Book, officially titled "PostScript Language Reference,"
is the authoritative manual for the PostScript programming language,
detailing its syntax, semantics, and graphics operators.
We use it as a reference for the LeoScript operators, for which we have
explicitly established full compatibility in behavior.
Forth calls them words.
We use IDEA:
, TODO:
and FIXME:
as Task Tags
All tools support a -v
option to generate more run time information.
A subdirectory as container of LeoScript files which creates one or more
functional related dictionaries if executed.
Extension | Description |
---|---|
cloc | CLOC configuration |
cpp, h | C++ source |
Dockerfile | Docker configuration |
drawio | draw.io XML diagram |
gcda | profiling run data |
gcno | profiling structure information |
html, css | mostly generated HTML page |
js, map, md5 | generated HTML page helper |
png, svg | more generated HTML page helper |
info | lcov data |
json | JSON configuration for development tools |
kdev4 | Kdevelop configuration |
leo | LeoScript source |
leon | leon-format, the parser output |
l, c | flex source and generated C code |
md | Markdown documentation |
out | end-2-end test reference output |
sh, inc | Bash script |
tpl | Bash template |
yml, yaml | YAML data for CI/CD |
none | executables and some Bash scripts |
Single Files | Description |
---|---|
.gitignore | git ignore |
formual.repository | generated HTML page helper |
compile_flags.txt | clang configuration |
Doxyfile | Doxygen configuration |
LICENSE | License ASCII text |
makefile | central build configuration |
post-commit | git configuration proposal |
./Coverage
Test coverage data.
./Docker
Dockerfiles to build the images used in GitLab CI/CD.
./Examples
Example programs.
./Index
Source for the documentation main page.
./.git
That's the git Repository.
./.kdev4
Is a living propsal for a KDevelop configuration.
./man
The Doxygen-generated man pages.
./public
Location for GitLab Pages web server files.
The Doxygen-generated HTML documentation can be found in ./public/doxygen/
./Suite*
Each 'Suite' directory contains a collection of test cases.
./tmp
Exists for temporary files e.g. for testing purposes.
./Tools
Contains TOOLS for the development, e.g. git hooks.
./vocabularies
Is only a container for its subdirectories.
These subdirecories are called vocabularies and the names of the
subdirectories are used to identify the vocabularies.
./.vscode
Is a living propsal for a Visual Studio Code configuration.
/usr/local/bin
Contain the user programs: parser leon lb lc
/usr/local/lib/leonardus/
System files: boot.leo dry.inc
/usr/local/lib/leonardus/vocabularies/
The location for the vocabularies.
/usr/local/lib/leonardus/Examples/
Example *.leo LeoScripts
There is an Examples
direcory. A content overview will be generated by
the build process as EXAMPLES.md
.
See LANGUAGE
Leonardus integrates the traditional UNIX man page subsystem.
Generated man pages are categorized under section 7 (Miscellaneous
Information Manual).
Doxygen generates man pages for the operators in systemdict, leodict
and userdict.
lb -C manpage
generates man pages for the operators from vocabularies.
The tool mandb
must be accessible in the PATH to update the database for apropos