Wrote Toy_Parser with minimal features, tests missing

It's too late at night, so I'm packing this up with only a dummy warning
message for the tests. I'll keep going tomorrow, hopefully.
This commit is contained in:
2024-09-12 20:53:34 +10:00
parent eca3350c64
commit b00a6838be
9 changed files with 628 additions and 35 deletions

View File

@@ -62,9 +62,8 @@ int test_type_emission() {
//build the AST
Toy_Ast* ast = NULL;
Toy_Ast* child = NULL;
Toy_private_emitAstValue(&bucket, &child, TOY_VALUE_TO_INTEGER(42));
Toy_private_emitAstUnary(&bucket, &ast, TOY_AST_FLAG_NEGATE, child);
Toy_private_emitAstValue(&bucket, &ast, TOY_VALUE_TO_INTEGER(42));
Toy_private_emitAstUnary(&bucket, &ast, TOY_AST_FLAG_NEGATE);
//check if it worked
if (
@@ -90,11 +89,10 @@ int test_type_emission() {
//build the AST
Toy_Ast* ast = NULL;
Toy_Ast* left = NULL;
Toy_Ast* right = NULL;
Toy_private_emitAstValue(&bucket, &left, TOY_VALUE_TO_INTEGER(42));
Toy_private_emitAstValue(&bucket, &ast, TOY_VALUE_TO_INTEGER(42));
Toy_private_emitAstValue(&bucket, &right, TOY_VALUE_TO_INTEGER(69));
Toy_private_emitAstBinary(&bucket, &ast, TOY_AST_FLAG_ADD, left, right);
Toy_private_emitAstBinary(&bucket, &ast, TOY_AST_FLAG_ADD, right);
//check if it worked
if (
@@ -122,13 +120,11 @@ int test_type_emission() {
//build the AST
Toy_Ast* ast = NULL;
Toy_Ast* addition = NULL;
Toy_Ast* left = NULL;
Toy_Ast* right = NULL;
Toy_private_emitAstValue(&bucket, &left, TOY_VALUE_TO_INTEGER(42));
Toy_private_emitAstValue(&bucket, &ast, TOY_VALUE_TO_INTEGER(42));
Toy_private_emitAstValue(&bucket, &right, TOY_VALUE_TO_INTEGER(69));
Toy_private_emitAstBinary(&bucket, &addition, TOY_AST_FLAG_ADD, left, right);
Toy_private_emitAstGroup(&bucket, &ast, addition);
Toy_private_emitAstBinary(&bucket, &ast, TOY_AST_FLAG_ADD, right);
Toy_private_emitAstGroup(&bucket, &ast);
//check if it worked
if (
@@ -164,13 +160,11 @@ int test_type_emission() {
for (int i = 0; i < 5; i++) {
//build the AST
Toy_Ast* ast = NULL;
Toy_Ast* addition = NULL;
Toy_Ast* left = NULL;
Toy_Ast* right = NULL;
Toy_private_emitAstValue(&bucket, &left, TOY_VALUE_TO_INTEGER(42));
Toy_private_emitAstValue(&bucket, &ast, TOY_VALUE_TO_INTEGER(42));
Toy_private_emitAstValue(&bucket, &right, TOY_VALUE_TO_INTEGER(69));
Toy_private_emitAstBinary(&bucket, &addition, TOY_AST_FLAG_ADD, left, right);
Toy_private_emitAstGroup(&bucket, &ast, addition);
Toy_private_emitAstBinary(&bucket, &ast, TOY_AST_FLAG_ADD, right);
Toy_private_emitAstGroup(&bucket, &ast);
Toy_private_appendAstBlock(&bucket, &block, ast);
}

View File

@@ -0,0 +1,9 @@
#include "toy_parser.h"
#include "toy_console_colors.h"
#include <stdio.h>
int main() {
fprintf(stderr, TOY_CC_WARN "WARNING: Test suite for Toy_Parser is not yet implemented\n" TOY_CC_RESET);
return 0;
}