Update
This commit is contained in:
parent
7f787d6e58
commit
760193c6c6
12 changed files with 87 additions and 21 deletions
50
comun.md
50
comun.md
|
@ -6,7 +6,9 @@ The language is intended to be the foundation of a completely new, non-[capitali
|
|||
|
||||
**A quick sum up** is following: comun is **[minimalist](minimalism.md)**, **[low level](low_level.md)** with minimum [abstraction](abstraction.md), **[portable](portability.md)**, **[imperative](imperative.md)** and **[stack](stack.md)-based**, using **reverse Polish notation**. It can be **both [compiled](compiler.md) and [interpreted](interpreter.md)**. There are **only primitive integer [data types](data_type.md)** (native integer size by default with possibility to specify exact width where necessary, signed/unsigned interpretation is left to the programmer) and **optional [pointers](pointer.md)** that can be used as variables, for managing multiple stacks, creating [arrays](array.md) etc. Its **specification can fit on a sheet of paper** and is **completely [public domain](public_domain.md)** under [CC0](cc0.md) (as is its current implementation). It has **no [standard library](stdlib.md)**. There are **no [English](english.md) keywords**; commands are rather very short (mostly 1 to three symbols) math-like symbols. Source code only allows [ASCII](ascii.md) symbols (no [unicode](unicode.md)). There is an **optional [preprocessor](preprocessor.md) that uses comun itself** (i.e. it doesn't use any extra language). **[Functions](function.md) and [recursion](recursion.md)** are supported. Many features of the language are optional and never burden the programmer if he doesn't use them. Simplified versions of the language (minicomun and microcomun) are also specified.
|
||||
|
||||
Here is a very short showcase of comun code:
|
||||
## Examples
|
||||
|
||||
Here is a very short showcase of comun code, demonstrating some common functions:
|
||||
|
||||
```
|
||||
max: <' ? >< . ^ . # takes maximum of two values
|
||||
|
@ -34,4 +36,50 @@ factI:
|
|||
.
|
||||
```
|
||||
|
||||
The following is a [quine](quine.md) in comun:
|
||||
|
||||
```
|
||||
0 46 32 34 S 34 32 58 83 S --> S: "0 46 32 34 S 34 32 58 83 S --> " .
|
||||
```
|
||||
|
||||
The following code translates [brainfuck](brainfuck.md) to comun:
|
||||
|
||||
```
|
||||
0 "$>0 " -->
|
||||
|
||||
@@
|
||||
<? ?
|
||||
<-
|
||||
|
||||
$0 "+" = $1 "-" = | ?
|
||||
$0 -> $0 -> " " ->
|
||||
.
|
||||
|
||||
$0 "<" = $1 ">" = | ?
|
||||
"$" -> $0 -> "0" -> " " ->
|
||||
.
|
||||
|
||||
$0 "." = ?
|
||||
0 "->' " -->
|
||||
.
|
||||
|
||||
$0 "," = ?
|
||||
0 "$<0 <- " -->
|
||||
.
|
||||
|
||||
$0 91 = ? # left bracket
|
||||
0 "@' " -->
|
||||
.
|
||||
|
||||
$0 93 = ? # right bracker
|
||||
0 ". " -->
|
||||
.
|
||||
|
||||
^
|
||||
;
|
||||
!@
|
||||
.
|
||||
.
|
||||
```
|
||||
|
||||
TODO: more, code examples, compare the above with C, ...
|
Loading…
Add table
Add a link
Reference in a new issue