🐐 EVERRO
This commit is contained in:
@@ -899,6 +899,9 @@ class BuiltIn(Node):
|
|||||||
if not isinstance(params[0], ValList):
|
if not isinstance(params[0], ValList):
|
||||||
raise CentvrionError("LONGITVDO requires an array")
|
raise CentvrionError("LONGITVDO requires an array")
|
||||||
return vtable, ValInt(len(params[0].value()))
|
return vtable, ValInt(len(params[0].value()))
|
||||||
|
case "EVERRO":
|
||||||
|
print("\033[2J\033[H", end="", flush=True)
|
||||||
|
return vtable, ValNul()
|
||||||
case _:
|
case _:
|
||||||
raise NotImplementedError(self.builtin)
|
raise NotImplementedError(self.builtin)
|
||||||
|
|
||||||
|
|||||||
@@ -187,6 +187,10 @@ def _emit_builtin(node, ctx):
|
|||||||
lines.append("break;")
|
lines.append("break;")
|
||||||
lines.append(f"CentValue {tmp} = cent_null();")
|
lines.append(f"CentValue {tmp} = cent_null();")
|
||||||
|
|
||||||
|
case "EVERRO":
|
||||||
|
lines.append("cent_everro();")
|
||||||
|
lines.append(f"CentValue {tmp} = cent_null();")
|
||||||
|
|
||||||
case _:
|
case _:
|
||||||
raise NotImplementedError(node.builtin)
|
raise NotImplementedError(node.builtin)
|
||||||
|
|
||||||
|
|||||||
@@ -458,6 +458,11 @@ void cent_dice(CentValue v) {
|
|||||||
fputc('\n', stdout);
|
fputc('\n', stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cent_everro(void) {
|
||||||
|
fputs("\033[2J\033[H", stdout);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
CentValue cent_avdi(void) {
|
CentValue cent_avdi(void) {
|
||||||
char *buf = cent_arena_alloc(cent_arena, 1024);
|
char *buf = cent_arena_alloc(cent_arena, 1024);
|
||||||
if (!fgets(buf, 1024, stdin)) {
|
if (!fgets(buf, 1024, stdin)) {
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ CentValue cent_avdi_numerus(void); /* AVDI_NVMERVS */
|
|||||||
CentValue cent_longitudo(CentValue v); /* LONGITVDO */
|
CentValue cent_longitudo(CentValue v); /* LONGITVDO */
|
||||||
CentValue cent_fortis_numerus(CentValue lo, CentValue hi); /* FORTIS_NVMERVS */
|
CentValue cent_fortis_numerus(CentValue lo, CentValue hi); /* FORTIS_NVMERVS */
|
||||||
CentValue cent_fortis_electionis(CentValue lst); /* FORTIS_ELECTIONIS */
|
CentValue cent_fortis_electionis(CentValue lst); /* FORTIS_ELECTIONIS */
|
||||||
|
void cent_everro(void); /* EVERRO */
|
||||||
|
|
||||||
/* ------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------ */
|
||||||
/* Array helpers */
|
/* Array helpers */
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ builtin_tokens = [("BUILTIN", i) for i in [
|
|||||||
"AVDI_NVMERVS",
|
"AVDI_NVMERVS",
|
||||||
"AVDI",
|
"AVDI",
|
||||||
"DICE",
|
"DICE",
|
||||||
|
"EVERRO",
|
||||||
"FORTIS_NVMERVS",
|
"FORTIS_NVMERVS",
|
||||||
"FORTIS_ELECTIONIS",
|
"FORTIS_ELECTIONIS",
|
||||||
"LONGITVDO"
|
"LONGITVDO"
|
||||||
|
|||||||
1
tests.py
1
tests.py
@@ -117,6 +117,7 @@ output_tests = [
|
|||||||
("DICE(\"a\", \"b\")", Program([], [ExpressionStatement(BuiltIn("DICE", [String("a"), String("b")]))]), ValStr("a b"), "a b\n"),
|
("DICE(\"a\", \"b\")", Program([], [ExpressionStatement(BuiltIn("DICE", [String("a"), String("b")]))]), ValStr("a b"), "a b\n"),
|
||||||
("DICE(\"line one\")\nDICE(\"line two\")", Program([], [ExpressionStatement(BuiltIn("DICE", [String("line one")])), ExpressionStatement(BuiltIn("DICE", [String("line two")]))]), ValStr("line two"), "line one\nline two\n"),
|
("DICE(\"line one\")\nDICE(\"line two\")", Program([], [ExpressionStatement(BuiltIn("DICE", [String("line one")])), ExpressionStatement(BuiltIn("DICE", [String("line two")]))]), ValStr("line two"), "line one\nline two\n"),
|
||||||
("DICE(DICE(II))", Program([], [ExpressionStatement(BuiltIn("DICE", [BuiltIn("DICE", [Numeral("II")])]))]), ValStr("II"), "II\nII\n"),
|
("DICE(DICE(II))", Program([], [ExpressionStatement(BuiltIn("DICE", [BuiltIn("DICE", [Numeral("II")])]))]), ValStr("II"), "II\nII\n"),
|
||||||
|
("EVERRO()", Program([], [ExpressionStatement(BuiltIn("EVERRO", []))]), ValNul(), "\033[2J\033[H"),
|
||||||
]
|
]
|
||||||
|
|
||||||
class TestOutput(unittest.TestCase):
|
class TestOutput(unittest.TestCase):
|
||||||
|
|||||||
Reference in New Issue
Block a user