Skip to content

Commit e2269ac

Browse files
committed
feat: Introduce ProXPL parser with support for declarations, statements, async functions, classes, and module imports, alongside native I/O functionalities.
1 parent 0265eb8 commit e2269ac

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/compiler/parser/parser.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ static Expr *call(Parser *p) {
715715
check(p, TOKEN_ELSE) || check(p, TOKEN_WHILE) ||
716716
check(p, TOKEN_FOR) || check(p, TOKEN_BREAK) ||
717717
check(p, TOKEN_CONTINUE) || check(p, TOKEN_RETURN) ||
718-
check(p, TOKEN_FUNC) ||
718+
check(p, TOKEN_FUNC) || check(p, TOKEN_PRINT) ||
719719
check(p, TOKEN_USE) || check(p, TOKEN_FROM) ||
720720
check(p, TOKEN_ASYNC) || check(p, TOKEN_AWAIT) ||
721721
check(p, TOKEN_TRY) || check(p, TOKEN_CATCH) ||

src/stdlib/io_native.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,21 @@ static Value native_eprint_raw(int argCount, Value* args) {
5959
return NIL_VAL;
6060
}
6161

62+
// println(val) - Print value with newline
63+
static Value native_println(int argCount, Value* args) {
64+
if (argCount > 0) {
65+
if (IS_STRING(args[0])) {
66+
printf("%s\n", AS_CSTRING(args[0]));
67+
} else {
68+
printValue(args[0]);
69+
printf("\n");
70+
}
71+
} else {
72+
printf("\n");
73+
}
74+
return NIL_VAL;
75+
}
76+
6277
// input_raw() - Read line from stdin
6378
static Value native_input_raw(int argCount, Value* args) {
6479
char buffer[1024];
@@ -97,6 +112,9 @@ ObjModule* create_std_io_module() {
97112
push(&vm, OBJ_VAL(module));
98113

99114
defineModuleFn(module, "print_raw", native_print_raw);
115+
defineModuleFn(module, "print", native_print_raw);
116+
defineModuleFn(module, "write", native_print_raw);
117+
defineModuleFn(module, "println", native_println);
100118
defineModuleFn(module, "eprint_raw", native_eprint_raw);
101119
defineModuleFn(module, "input_raw", native_input_raw);
102120
defineModuleFn(module, "flush_raw", native_flush_raw);

0 commit comments

Comments
 (0)