Compare commits
2 Commits
c720d75c79
...
e2ce25aa24
| Author | SHA1 | Date | |
|---|---|---|---|
| e2ce25aa24 | |||
| b24134ae4e |
@@ -191,9 +191,9 @@ Skips the rest of the current loop body and continues to the next iteration (`DV
|
|||||||
Breaks out of the current loop (`DVM` or `PER`). Has no meaningful return value.
|
Breaks out of the current loop (`DVM` or `PER`). Has no meaningful return value.
|
||||||
|
|
||||||
### LONGITVDO
|
### LONGITVDO
|
||||||
`LONGITVDO array`
|
`LONGITVDO array` or `LONGITVDO string`
|
||||||
|
|
||||||
Returns the length of `array` as an integer.
|
Returns the length of `array` (element count) or `string` (character count) as an integer.
|
||||||
|
|
||||||
## Modules
|
## Modules
|
||||||
Modules are additions to the base `CENTVRION` syntax. They add or change certain features. Modules are included in your code by having
|
Modules are additions to the base `CENTVRION` syntax. They add or change certain features. Modules are included in your code by having
|
||||||
|
|||||||
@@ -909,9 +909,9 @@ class BuiltIn(Node):
|
|||||||
raise CentvrionError("FORTIS_ELECTIONIS: cannot select from an empty array")
|
raise CentvrionError("FORTIS_ELECTIONIS: cannot select from an empty array")
|
||||||
return vtable, lst[random.randint(0, len(lst) - 1)]
|
return vtable, lst[random.randint(0, len(lst) - 1)]
|
||||||
case "LONGITVDO":
|
case "LONGITVDO":
|
||||||
if not isinstance(params[0], ValList):
|
if isinstance(params[0], (ValList, ValStr)):
|
||||||
raise CentvrionError("LONGITVDO requires an array")
|
return vtable, ValInt(len(params[0].value()))
|
||||||
return vtable, ValInt(len(params[0].value()))
|
raise CentvrionError("LONGITVDO requires an array or string")
|
||||||
case "EVERRO":
|
case "EVERRO":
|
||||||
print("\033[2J\033[H", end="", flush=True)
|
print("\033[2J\033[H", end="", flush=True)
|
||||||
return vtable, ValNul()
|
return vtable, ValNul()
|
||||||
|
|||||||
@@ -481,9 +481,10 @@ CentValue cent_avdi_numerus(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CentValue cent_longitudo(CentValue v) {
|
CentValue cent_longitudo(CentValue v) {
|
||||||
if (v.type != CENT_LIST)
|
if (v.type == CENT_LIST) return cent_int(v.lval.len);
|
||||||
cent_type_error("'LONGITVDO' requires a list");
|
if (v.type == CENT_STR) return cent_int((long)strlen(v.sval));
|
||||||
return cent_int(v.lval.len);
|
cent_type_error("'LONGITVDO' requires a list or string");
|
||||||
|
return cent_null(); /* unreachable; silences warning */
|
||||||
}
|
}
|
||||||
|
|
||||||
CentValue cent_fortis_numerus(CentValue lo, CentValue hi) {
|
CentValue cent_fortis_numerus(CentValue lo, CentValue hi) {
|
||||||
|
|||||||
@@ -4,14 +4,12 @@ CVM FORS
|
|||||||
DESIGNA correct VT FORTIS_NVMERVS(I,C)
|
DESIGNA correct VT FORTIS_NVMERVS(I,C)
|
||||||
DESIGNA gvess VT NVLLVS
|
DESIGNA gvess VT NVLLVS
|
||||||
|
|
||||||
DVM FALSITAS FACE {
|
DVM correct EST gvess FACE {
|
||||||
DESIGNA gvess VT AVDI_NVMERVS()
|
DESIGNA gvess VT AVDI_NVMERVS()
|
||||||
SI gvess MINVS correct TVNC {
|
SI gvess MINVS correct TVNC {
|
||||||
DICE("Too low!")
|
DICE("Too low!")
|
||||||
} ALVID SI gvess PLVS correct TVNC {
|
} ALVID SI gvess PLVS correct TVNC {
|
||||||
DICE("Too high!")
|
DICE("Too high!")
|
||||||
} ALVID {
|
|
||||||
ERVMPE
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.9 KiB |
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 8.0 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 9.6 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 27 KiB |
BIN
snippets/dvm.png
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 19 KiB |
@@ -3,15 +3,13 @@ CVM FORS
|
|||||||
DESIGNA correct VT FORTIS_NVMERVS(I,C)
|
DESIGNA correct VT FORTIS_NVMERVS(I,C)
|
||||||
DESIGNA gvess VT NVLLVS
|
DESIGNA gvess VT NVLLVS
|
||||||
|
|
||||||
DVM FALSITAS FACE {
|
DVM correct EST gvess FACE {
|
||||||
DESIGNA gvess VT AVDI_NVMERVS()
|
DESIGNA gvess VT AVDI_NVMERVS()
|
||||||
SI gvess MINVS correct TVNC {
|
SI gvess MINVS correct TVNC {
|
||||||
DICE("Too low!")
|
DICE("Too low!")
|
||||||
} ALVID SI gvess PLVS correct TVNC {
|
} ALVID SI gvess PLVS correct TVNC {
|
||||||
DICE("Too high!")
|
DICE("Too high!")
|
||||||
} ALVID {
|
}
|
||||||
ERVMPE
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DICE("You guessed correctly!")
|
DICE("You guessed correctly!")
|
||||||
|
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 87 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 6.7 KiB |
BIN
snippets/per.png
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 9.3 KiB |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 5.2 KiB |
@@ -1,77 +0,0 @@
|
|||||||
%YAML 1.2
|
|
||||||
---
|
|
||||||
name: Centvrion
|
|
||||||
file_extensions:
|
|
||||||
- cent
|
|
||||||
scope: source.centvrion
|
|
||||||
|
|
||||||
contexts:
|
|
||||||
main:
|
|
||||||
- include: comments
|
|
||||||
- include: strings
|
|
||||||
- include: fractions
|
|
||||||
- include: numerals
|
|
||||||
- include: constants
|
|
||||||
- include: builtins
|
|
||||||
- include: modules
|
|
||||||
- include: keywords
|
|
||||||
- include: operators
|
|
||||||
- include: identifiers
|
|
||||||
|
|
||||||
comments:
|
|
||||||
- match: '//[^\n]*'
|
|
||||||
scope: comment.line.centvrion
|
|
||||||
- match: '/\*'
|
|
||||||
scope: comment.block.centvrion
|
|
||||||
push:
|
|
||||||
- meta_scope: comment.block.centvrion
|
|
||||||
- match: '\*/'
|
|
||||||
pop: true
|
|
||||||
|
|
||||||
strings:
|
|
||||||
- match: '"'
|
|
||||||
scope: string.quoted.double.centvrion
|
|
||||||
push:
|
|
||||||
- meta_scope: string.quoted.double.centvrion
|
|
||||||
- match: '"'
|
|
||||||
pop: true
|
|
||||||
- match: "'"
|
|
||||||
scope: string.quoted.single.centvrion
|
|
||||||
push:
|
|
||||||
- meta_scope: string.quoted.single.centvrion
|
|
||||||
- match: "'"
|
|
||||||
pop: true
|
|
||||||
|
|
||||||
fractions:
|
|
||||||
- match: '\b[IVXLCDM][IVXLCDM_]*(?:S[S:.|]*|:[S:.|]+|\.[S:.|]*)'
|
|
||||||
scope: constant.numeric.fraction.centvrion
|
|
||||||
- match: '(?<![IVXLCDM_])(?:S[S:.|]+|:[S:.|]+)'
|
|
||||||
scope: constant.numeric.fraction.centvrion
|
|
||||||
|
|
||||||
numerals:
|
|
||||||
- match: '\b[IVXLCDM][IVXLCDM_]*\b'
|
|
||||||
scope: constant.numeric.centvrion
|
|
||||||
|
|
||||||
constants:
|
|
||||||
- match: '\b(VERITAS|FALSITAS|NVLLVS)\b'
|
|
||||||
scope: constant.language.centvrion
|
|
||||||
|
|
||||||
builtins:
|
|
||||||
- match: '\b(AVDI_NVMERVS|AVDI|DICE|FORTIS_NVMERVS|FORTIS_ELECTIONIS|LONGITVDO)\b'
|
|
||||||
scope: support.function.builtin.centvrion
|
|
||||||
|
|
||||||
modules:
|
|
||||||
- match: '\b(FORS|FRACTIO|MAGNVM|SVBNVLLA)\b'
|
|
||||||
scope: support.class.module.centvrion
|
|
||||||
|
|
||||||
keywords:
|
|
||||||
- match: '\b(ALVID|AVT|DEFINI|DESIGNA|DONICVM|DVM|ERVMPE|EST|ET|FACE|INVOCA|IN|MINVS|NON|PER|PLVS|REDI|SI|TVNC|VSQVE|VT|CVM)\b'
|
|
||||||
scope: keyword.control.centvrion
|
|
||||||
|
|
||||||
operators:
|
|
||||||
- match: '[+\-*/&]'
|
|
||||||
scope: keyword.operator.centvrion
|
|
||||||
|
|
||||||
identifiers:
|
|
||||||
- match: '[abcdefghiklmnopqrstvxyz_]+'
|
|
||||||
scope: variable.other.centvrion
|
|
||||||
@@ -10,11 +10,11 @@ contexts:
|
|||||||
- include: comments
|
- include: comments
|
||||||
- include: strings
|
- include: strings
|
||||||
- include: fractions
|
- include: fractions
|
||||||
|
- include: keywords
|
||||||
- include: numerals
|
- include: numerals
|
||||||
- include: constants
|
- include: constants
|
||||||
- include: builtins
|
- include: builtins
|
||||||
- include: modules
|
- include: modules
|
||||||
- include: keywords
|
|
||||||
- include: operators
|
- include: operators
|
||||||
- include: identifiers
|
- include: identifiers
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 6.1 KiB |
3
tests.py
@@ -388,6 +388,9 @@ builtin_tests = [
|
|||||||
("CVM FORS\nFORTIS_NVMERVS(I, X)", Program([ModuleCall("FORS")], [ExpressionStatement(BuiltIn("FORTIS_NVMERVS", [Numeral("I"), Numeral("X")]))]), ValInt(3)),
|
("CVM FORS\nFORTIS_NVMERVS(I, X)", Program([ModuleCall("FORS")], [ExpressionStatement(BuiltIn("FORTIS_NVMERVS", [Numeral("I"), Numeral("X")]))]), ValInt(3)),
|
||||||
("AVDI()", Program([], [ExpressionStatement(BuiltIn("AVDI", []))]), ValStr("hello"), "", ["hello"]),
|
("AVDI()", Program([], [ExpressionStatement(BuiltIn("AVDI", []))]), ValStr("hello"), "", ["hello"]),
|
||||||
("LONGITVDO([I, II, III])", Program([], [ExpressionStatement(BuiltIn("LONGITVDO", [DataArray([Numeral("I"), Numeral("II"), Numeral("III")])]))]), ValInt(3)),
|
("LONGITVDO([I, II, III])", Program([], [ExpressionStatement(BuiltIn("LONGITVDO", [DataArray([Numeral("I"), Numeral("II"), Numeral("III")])]))]), ValInt(3)),
|
||||||
|
("LONGITVDO([])", Program([], [ExpressionStatement(BuiltIn("LONGITVDO", [DataArray([])]))]), ValInt(0)),
|
||||||
|
('LONGITVDO("salve")', Program([], [ExpressionStatement(BuiltIn("LONGITVDO", [String("salve")]))]), ValInt(5)),
|
||||||
|
('LONGITVDO("")', Program([], [ExpressionStatement(BuiltIn("LONGITVDO", [String("")]))]), ValInt(0)),
|
||||||
("CVM FORS\nFORTIS_ELECTIONIS([I, II, III])", Program([ModuleCall("FORS")], [ExpressionStatement(BuiltIn("FORTIS_ELECTIONIS", [DataArray([Numeral("I"), Numeral("II"), Numeral("III")])]))]), ValInt(1)),
|
("CVM FORS\nFORTIS_ELECTIONIS([I, II, III])", Program([ModuleCall("FORS")], [ExpressionStatement(BuiltIn("FORTIS_ELECTIONIS", [DataArray([Numeral("I"), Numeral("II"), Numeral("III")])]))]), ValInt(1)),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||