Implemented assert keyword, read more

The assert keyword works, but I want to add a cmd option to suppress or
disable the errors.

The tests need some serious TLC. I know that, but I'm kicking it down
the road for now.
This commit is contained in:
2024-11-09 17:41:29 +11:00
parent 1925d41940
commit 1608a13b43
9 changed files with 189 additions and 71 deletions

View File

@@ -17,6 +17,7 @@ typedef enum Toy_AstType {
TOY_AST_GROUP,
TOY_AST_COMPOUND,
TOY_AST_ASSERT,
TOY_AST_PRINT,
TOY_AST_VAR_DECLARE,
@@ -116,6 +117,12 @@ typedef struct Toy_AstCompound {
Toy_Ast* right;
} Toy_AstCompound;
typedef struct Toy_AstAssert {
Toy_AstType type;
Toy_Ast* child;
Toy_Ast* message;
} Toy_AstAssert;
typedef struct Toy_AstPrint {
Toy_AstType type;
Toy_Ast* child;
@@ -160,6 +167,7 @@ union Toy_Ast { //32 | 64 BITNESS
Toy_AstCompare compare; //16 | 24
Toy_AstGroup group; //8 | 16
Toy_AstCompound compound; //16 | 24
Toy_AstAssert assert; //16 | 24
Toy_AstPrint print; //8 | 16
Toy_AstVarDeclare varDeclare; //16 | 24
Toy_AstVarAssign varAssign; //16 | 24
@@ -179,6 +187,7 @@ void Toy_private_emitAstCompare(Toy_Bucket** bucketHandle, Toy_Ast** astHandle,T
void Toy_private_emitAstGroup(Toy_Bucket** bucketHandle, Toy_Ast** astHandle);
void Toy_private_emitAstCompound(Toy_Bucket** bucketHandle, Toy_Ast** astHandle,Toy_AstFlag flag, Toy_Ast* right);
void Toy_private_emitAstAssert(Toy_Bucket** bucketHandle, Toy_Ast** astHandle, Toy_Ast* child, Toy_Ast* msg);
void Toy_private_emitAstPrint(Toy_Bucket** bucketHandle, Toy_Ast** astHandle);
void Toy_private_emitAstVariableDeclaration(Toy_Bucket** bucketHandle, Toy_Ast** astHandle, Toy_String* name, Toy_Ast* expr);