From cf4ec674d52417a3f032cc0314e78c534e45ad37 Mon Sep 17 00:00:00 2001 From: Centrix14 Date: Tue, 31 Dec 2019 12:33:29 +0300 Subject: [PATCH] everything is ready for the release of version 1.0 --- .gitignore | 4 --- Makefile | 2 ++ README.md | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 77 insertions(+), 6 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 11ea122..0000000 --- a/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -*.exe -prog -math -help.sp \ No newline at end of file diff --git a/Makefile b/Makefile index 96a3691..b71e7ff 100644 --- a/Makefile +++ b/Makefile @@ -2,3 +2,5 @@ saol: gcc -o saol saol.c unitok/unitok.c arr_lib.c isi: gcc -o isi isi.c unitok/unitok.c arr_lib.c +ssp: + gcc -o ssp ssp.c unitok/unitok.c diff --git a/README.md b/README.md index 04aaf8f..16843ac 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,75 @@ -# saol -simple array-oriented language +# saol (simple array-oriented language) +## "Hello world!" programm + ``` + @|(Hello world!)(-!) + ``` + +## picking + + `saol` -- standard interpreter + + `isi` -- interactive interpreter + + `ssp` -- simple standard preprocessor + +## Overview + + `(` / `)` -- take everything in parentheses as a whole works like quotation marks in other languages (`(word1 word2)` - will be read as "word1 word2") + + `:` -- initialize the current selected element with a value (`:12` - now element 0 stores the value 12) + + `^` -- go to the item with the number (`^123` - now 123 is the current work item) + + `>` / `<` -- move right / left in the array (`>>` - move the current work item pointer 2 items forward) + + `_!` -- display the value of the current item (`:123(_!)` - displays the value of element 123 on the screen) + + `~` -- a comment that continues until the next language command (`~ comment`) + + `|` -- fills the array from the current position with elements (`|6 8 2` - the numbers 6, 8, 2 will be added to the array) + + `-!` -- displays the values of all array elements (`^0|6 8 12(-!)` - displays 6, 8, 12 if the array was initially empty) + + `;` -- reports that the data entered is a number (`;:12` - writes 12 to the currently selected element, and reports that it is a number) + + `@` -- indicates that the input data is characters (`@:A` - writes the letter 'A' to the currently selected element) + + `+` -- returns the sum of all array elements in element 2047 (`;|12 56 9+^2047(_!)` - displays the sum of 12, 56, and 9) + + `'` -- returns the difference of all array elements in element 2047 (`;|12 56 9'^2047(_!)` - will represent the difference between 12, 56, and 9) + + `*` -- returns the product of all array elements in element 2047 (`;|12 56 9*^2047(_!)` - displays the product 12, 56, and 9) + + `/` -- returns the quotient of all array elements in element 2047 (`;|12 56 9/^2047(_!)` - displays private 12, 56, and 9) + + `#` -- filling an array with specific values (`;#0` - fills the array with zeros) + + `[` / `]` -- limit the scope of commands (`[0]2(-!)` - displays the values of elements from 0 to 2) + + `:-` -- copy the value of the current item to the selected one (`:123(:-)2` - now element 2 stores the value 123) + + `!-` -- copies the inverted value from the current work item to the selected one (`:123(!-)2` - now element 2 stores 0) + + `&` -- returns the conjunction of all array elements in element 2047 (`|1 2 3&` - in element 2047, 1 will be returned) + + `\` -- returns the disjunction of all array elements in element 2047 (`|1 2 0\` - in element 2047, 1 will be returned) + + `?~` -- predicative execution tool, if the result of the previous operation is true, then all subsequent commands will be executed, if it is not, then all subsequent operations will be skipped, analogous to "if" in other languages (`|1 2 3+(?~)^0|(true)@(-!)` - will display "true", since 1+2+3 not equal to 0) + + `?!` -- inverts the result of the previous operation, similar to else in other languages (`|0 0 0+(?~)^0|(true)@(-!)(?!)|(false)@(-!)` - will output "false" as 0+0+0 early 0) + + `|~` -- iterator, performs some action on all elements of the array (`(|~)(_! )` - displays the values of all elements of the array, in fact analog ( -!), it is important that operations that must be performed iteratively are enclosed in brackets and end with a space) + + `<->` -- exchanges values between the current work item and the selected one (`^2047(<->)2` - the values of elements 2047 and 2 will be reversed) + +## Some remarks + + some commands must be surrounded by parentheses, as follows: `(_!)`, `(-!)`, `(:-)`, `(!-)`, `(?~)`, `(?!)`, `(|~)`, `(<->) + + specifically for saol, I wrote a preprocessor called ssp (standard SAOL preprocessor), it runs separately from the main interpreter, and has the following features: + + `.link ... ` -- connecting third-party files + + `.macro ` -- creates a macro named name, the next time it is encountered, expr will be substituted for it + + `.prog` -- end of the preprocessor command block and start of the program + +### Template for using a preprocessor in a program + ``` + .link... + .macro... + .prog + + ~ your programm + ``` + +## Installation and use +### Installation +to install, you will need: + + C compiler (gcc, clang) + + git + + make + +###### typical installation scenario + ``` + git clone https://github.com/Centrix14/saol + cd saol + make saol + make isi + make ssp + ``` + +### use + ``` + ./saol my_programm.saol // for simple interpretation + ./ssp my_programm.saol out.saol // for preprocessing my_programm.saol in out.saol + ./isi // to call an interactive interpreter + ```