This commit is contained in:
NikolajDanger
2022-06-08 16:16:20 +02:00
parent 935c90f645
commit f4c608aaf2
5 changed files with 130 additions and 120 deletions

144
README.md
View File

@@ -6,19 +6,19 @@
## Example code
### Hello World
```
DESIGNA x UT "Hello World!"
DESIGNA x VT "Hello World!"
DICE x
```
### Recursive Fibonacci number function
```
DEFINI fib x UT {
SI x EST NULLUS TUNC {
REDI NULLUS
} ALUID SI x EST I TUNC {
DEFINI fib x VT {
SI x EST NVLLVS TVNC {
REDI NVLLVS
} ALVID SI x EST I TVNC {
REDI I
} ALUID {
} ALVID {
REDI ((INVOCA fib (x-II)) + (INVOCA fib (x-I)))
}
}
@@ -29,17 +29,17 @@ DEFINI fib x UT {
```
VOCA FORS
DESIGNA correct UT FORTIS_NUMERUS I C
DESIGNA gvess UT NULLUS
DESIGNA correct VT FORTIS_NVMERVS I C
DESIGNA gvess VT NVLLVS
DUM FALSITAS FACE {
DESIGNA gvess UT AUDI_NUMERUS
SI gvess MINUS correct TUNC {
DVM FALSITAS FACE {
DESIGNA gvess VT AVDI_NVMERVS
SI gvess MINVS correct TVNC {
DICE "Too low!"
} ALUID SI gvess PLUS correct TUNC {
} ALVID SI gvess PLVS correct TVNC {
DICE "Too high!"
} ALUID {
ERUMPE
} ALVID {
ERVMPE
}
}
@@ -47,24 +47,24 @@ DICE "You guessed correctly!"
```
## Variables
Variables are set with the `DESIGNA` and `UT` keywords. Type is inferred.
Variables are set with the `DESIGNA` and `VT` keywords. Type is inferred.
```
DESIGNA x UT XXVI
DESIGNA x VT XXVI
```
Variable can consist of lower-case letters, numbers, as well as `_`.
## Data types
### NULLUS
`NULLUS` is a special kind of data type in `CENTVRION`, similar to the `null` value in many other languages. `NULLUS` can be 0 if evaluated as an int or float, or an empty string if evaluated as a string. `NULLUS` cannot be evaluated as a boolean.
### NVLLVS
`NVLLVS` is a special kind of data type in `CENTVRION`, similar to the `null` value in many other languages. `NVLLVS` can be 0 if evaluated as an int or float, or an empty string if evaluated as a string. `NVLLVS` cannot be evaluated as a boolean.
### Strings
Strings are written as text in quotes (`'` or `"`).
```
DESIGNA x UT "this is a string"
DESIGNA x VT "this is a string"
```
### Integers
@@ -82,12 +82,12 @@ Integers must be written in roman numerals using the following symbols:
Each of the symbols written by themself is equal to the value of the symbol. Different symbols written from largest to smallest are equal to the sum of the symbols. Two to three of the same symbol written consecutively is equal to the sum of those symbols (only true for `I`s, `X`s, `C`s or `M`s ). A single `I` written before a `V` or `X` is equal to 1 less than the value of the second symbol. Similarly, an `X` written before a `L` or `C` is 10 less than the second symbol, and a `C` written before a `D` or `M` is 100 less than the second symbol.
Because of the restrictions of roman numerals, numbers above 3.999 are impossible to write in the base `CENTVRION` syntax. If numbers of that size are required, see the `MAGNUM` module.
Because of the restrictions of roman numerals, numbers above 3.999 are impossible to write in the base `CENTVRION` syntax. If numbers of that size are required, see the `MAGNVM` module.
The number 0 can be expressed with the keyword `NULLUS`.
The number 0 can be expressed with the keyword `NVLLVS`.
#### Negative numbers
Negative numbers can be expressed as `NULLUS` minus the value. For an explicit definition of negative numbers, see the `SUBNULLA` module.
Negative numbers can be expressed as `NVLLVS` minus the value. For an explicit definition of negative numbers, see the `SVBNVLLA` module.
### Floats
The base `CENTVRION` syntax does not allow for floats. However, the `FRACTIO` module adds a syntax for fractions.
@@ -99,17 +99,17 @@ Booleans are denoted with the keywords `VERITAS` for true and `FALSITAS` for fal
Arrays are defined using square brackets (`[]`).
## Conditionals
### SI/TUNC
If-then statements are denoted with the keywords `SI` (if) and `TUNC` (then). Thus, the code
### SI/TVNC
If-then statements are denoted with the keywords `SI` (if) and `TVNC` (then). Thus, the code
```
DESIGNA x UT VERITAS
SI x TUNC {
DESIGNA x VT VERITAS
SI x TVNC {
DICE I
REDI NULLLUS
REDI NVLLLVS
}
DICE NULLUS
DICE NVLLVS
> I
```
@@ -117,32 +117,32 @@ DICE NULLUS
Will return `I` (1), as the conditional evaluates `x` to be true.
### Boolean expressions
In conditionals, `EST` functions as an equality evaluation, and `MINUS` (<) and `PLUS` (>) function as inequality evaluation.
In conditionals, `EST` functions as an equality evaluation, and `MINVS` (<) and `PLVS` (>) function as inequality evaluation.
### ALUID
### ALVID
When using `SI`/`TUNC` statements, you can also use `ALUID` as an "else".
When using `SI`/`TVNC` statements, you can also use `ALVID` as an "else".
```
DESIGNA x UT VERITAS
SI x TUNC {
DESIGNA x VT VERITAS
SI x TVNC {
DICE I
} ALUID {
DICE NULLUS
} ALVID {
DICE NVLLVS
}
> I
```
`SI` statements may follow immediately after `ALUID`.
`SI` statements may follow immediately after `ALVID`.
```
DESIGNA x UT II
SI x EST I TUNC
DESIGNA x VT II
SI x EST I TVNC
DICE I
ALUID SI x EST II TUNC
ALVID SI x EST II TVNC
DICE II
ALUID
ALVID
DICE III
> II
@@ -150,16 +150,16 @@ ALUID
### Boolean operators
The keyword `ET` can be used as a boolean "and". The keyword `AUT` can be used as a boolean "or".
The keyword `ET` can be used as a boolean "and". The keyword `AVT` can be used as a boolean "or".
```
DESIGNA x UT VERITAS
DESIGNA y UT FALSITAS
SI x ET y TUNC {
DESIGNA x VT VERITAS
DESIGNA y VT FALSITAS
SI x ET y TVNC {
DICE I
} ALUID SI x AUT y TUNC {
} ALVID SI x AVT y TVNC {
DICE II
} ALUID {
} ALVID {
DICE III
}
@@ -167,23 +167,23 @@ SI x ET y TUNC {
```
## Loops
### DONICUM loops
### DONICVM loops
```
DESIGNA x UT NULLUS
DONICUM y UT NULLUS USQUE X FACE {
DESIGNA x UT x + y
DESIGNA x VT NVLLVS
DONICVM y VT NVLLVS VSQVE X FACE {
DESIGNA x VT x + y
}
DICE x
> XLV
```
### DUM loops
### DVM loops
```
DESIGNA x UT NULLUS
DUM x PLUS X FACE {
DESIGNA x UT x+I
DESIGNA x VT NVLLVS
DVM x PLVS X FACE {
DESIGNA x VT x+I
}
DICE x
@@ -192,7 +192,7 @@ DICE x
### PER loops
```
DESIGNA x UT [I, II, III, IV, V]
DESIGNA x VT [I, II, III, IV, V]
PER y IN x FACE {
DICE y
}
@@ -205,12 +205,12 @@ PER y IN x FACE {
```
## Functions
Functions are defined with the `DEFINI` and `UT` keywords. The `REDI` keyword is used to return. `REDI` must have exactly one parameter. `REDI` can also be used to end the program, if used outside of a function.
Functions are defined with the `DEFINI` and `VT` keywords. The `REDI` keyword is used to return. `REDI` must have exactly one parameter. `REDI` can also be used to end the program, if used outside of a function.
Calling a function is done with the `INVOCA` keyword.
```
DEFINI square x UT {
DEFINI square x VT {
REDI (x*x)
}
@@ -221,28 +221,28 @@ DICE (INVOCA square XI)
## Built-ins
### DICE
### AUDI
### AUDI_NUMERUS
### ERUMPE
### LONGITUDO
### AVDI
### AVDI_NVMERVS
### ERVMPE
### LONGITVDO
## Modules
Modules are additions to the base `CENTVRION` syntax. They add or change certain features. Modules are included in your code by having
```VOCA %MODULE NAME%```
```VOCA %MODVLE NAME%```
In the beginning of your source file.
Unlike many other programming languages with modules, the modules in `CENTVRION` are not libraries that can be "imported" from other scripts written in the language. They are features of the compiler, disabled by default.
Vnlike many other programming languages with modules, the modules in `CENTVRION` are not libraries that can be "imported" from other scripts written in the language. They are features of the compiler, disabled by default.
### FORS
```VOCA FORS```
The `FORS` module allows you to add randomness to your `CENTVRION` program. It adds 2 new built-in functions: `FORTIS_NUMERUS int int` and `FORTIS_ELECTIONIS ['a]`.
The `FORS` module allows you to add randomness to your `CENTVRION` program. It adds 2 new built-in functions: `FORTIS_NVMERVS int int` and `FORTIS_ELECTIONIS ['a]`.
`FORTIS_NUMERUS int int` picks a random int in the (inclusive) range of the two given ints.
`FORTIS_NVMERVS int int` picks a random int in the (inclusive) range of the two given ints.
`FORTIS_ELECTIONIS ['a]` picks a random element from the given array. `FORTIS_ELECTIONIS array` is identical to ```array[FORTIS_NUMERUS NULLUS ((LONGITUDO array)-I)]```.
`FORTIS_ELECTIONIS ['a]` picks a random element from the given array. `FORTIS_ELECTIONIS array` is identical to ```array[FORTIS_NVMERVS NVLLVS ((LONGITVDO array)-I)]```.
### FRACTIO
```VOCA FRACTIO```
@@ -257,16 +257,16 @@ The symbol `|` can be used to denote that the following fraction symbols are 1 "
A single "set" of fraction symbols can only represent up to 11/12, as 12/12 can be written as 1.
### MAGNUM
```VOCA MAGNUM```
### MAGNVM
```VOCA MAGNVM```
`MAGNUM` adds the ability to write integers larger than `MMMCMXCIX` (3.999) in your code, by adding the thousands operator, "`_`".
`MAGNVM` adds the ability to write integers larger than `MMMCMXCIX` (3.999) in your code, by adding the thousands operator, "`_`".
When `_` is added _after_ a numeric symbol, the symbol becomes 1.000 times larger. The operator can be added to the same symbol multiple times. So "`V_`" is 5.000, and "`V__`" is 5.000.000. The strict rules for integers still apply, so 4.999 cannot be written as "`IV_`", but must instead be written as "`MV_CMXCIX`".
All integer symbols except `I` may be given a `_`.
### SUBNULLA
```VOCA SUBNULLA```
### SVBNVLLA
```VOCA SVBNVLLA```
The `SUBNULLA` module adds the ability to write negative numbers as `-II` instead of `NULLUS-II`.
The `SVBNVLLA` module adds the ability to write negative numbers as `-II` instead of `NVLLVS-II`.