Script tests re-added, all tests can run under gdb

Also fixed a minor bug with printing, and removed the ability to
configure the parser.

Added and updated QUICKSTART.md as a quick way to get people started.

There's some broken scripts under 'scripts/' that require functions to
work properly.
This commit is contained in:
2026-04-10 15:28:56 +10:00
parent 211744535e
commit 547229e150
26 changed files with 916 additions and 48 deletions

View File

@@ -43,7 +43,7 @@ reference: https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape
#define TOY_CC_WARN "\033[" TOY_CC_FONT_YELLOW ";" TOY_CC_BACK_DEFAULT "m"
#define TOY_CC_ERROR "\033[" TOY_CC_FONT_RED ";" TOY_CC_BACK_DEFAULT "m"
#define TOY_CC_ASSERT "\033[" TOY_CC_FONT_BLACK ";" TOY_CC_BACK_MAGENTA "m"
#define TOY_CC_RESET "\033[" "0" "m"
#define TOY_CC_RESET "\033[" TOY_CC_FONT_DEFAULT ";" TOY_CC_BACK_DEFAULT "m"
//for unsupported platforms, these become no-ops
#else

View File

@@ -818,18 +818,12 @@ static void makeAssertStmt(Toy_Bucket** bucketHandle, Toy_Parser* parser, Toy_As
Toy_Ast* ast = NULL; //assert's emit function is a bit different
makeExpr(bucketHandle, parser, &ast);
//if assert is disabled, don't emit the assert
if (parser->removeAssert) {
Toy_private_emitAstPass(bucketHandle, rootHandle);
//NOTE: if it's an aggregate node, then it's got a second arg
if (ast->type == TOY_AST_AGGREGATE) {
Toy_private_emitAstAssert(bucketHandle, rootHandle, ast->aggregate.left, ast->aggregate.right);
}
else {
//NOTE: if it's an aggregate node, then it's got a second arg
if (ast->type == TOY_AST_AGGREGATE) {
Toy_private_emitAstAssert(bucketHandle, rootHandle, ast->aggregate.left, ast->aggregate.right);
}
else {
Toy_private_emitAstAssert(bucketHandle, rootHandle, ast, NULL);
}
Toy_private_emitAstAssert(bucketHandle, rootHandle, ast, NULL);
}
consume(parser, TOY_TOKEN_OPERATOR_SEMICOLON, "Expected ';' at the end of assert statement");
@@ -1159,10 +1153,4 @@ void Toy_resetParser(Toy_Parser* parser) {
parser->error = false;
parser->panic = false;
parser->removeAssert = false;
}
void Toy_configureParser(Toy_Parser* parser, bool removeAssert) {
parser->removeAssert = removeAssert;
}

View File

@@ -14,14 +14,8 @@ typedef struct Toy_Parser {
bool error;
bool panic; //currently processing an error
//configs
bool removeAssert;
} Toy_Parser;
TOY_API void Toy_bindParser(Toy_Parser* parser, Toy_Lexer* lexer);
TOY_API Toy_Ast* Toy_scanParser(Toy_Bucket** bucketHandle, Toy_Parser* parser);
TOY_API void Toy_resetParser(Toy_Parser* parser);
//configure certain options
TOY_API void Toy_configureParser(Toy_Parser* parser, bool removeAssert);

View File

@@ -838,11 +838,11 @@ static void processIndex(Toy_VM* vm) {
//extract cstring, based on type
if (str->info.type == TOY_STRING_LEAF) {
const char* cstr = str->leaf.data;
result = Toy_toStringLength(&vm->memoryBucket, cstr + i, l);
result = Toy_createStringLength(&vm->memoryBucket, cstr + i, l);
}
else if (str->info.type == TOY_STRING_NODE) {
char* cstr = Toy_getStringRaw(str);
result = Toy_toStringLength(&vm->memoryBucket, cstr + i, l);
result = Toy_createStringLength(&vm->memoryBucket, cstr + i, l);
free(cstr);
}
else {