From eccce505e56e7a182389fab3a1a249379b1a0279 Mon Sep 17 00:00:00 2001 From: Ur Mom Date: Sun, 12 May 2024 22:54:58 +0200 Subject: [PATCH 01/11] -added Type-Cast -added Reinterpret-Cast --- src/yacc/parser.y | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/yacc/parser.y b/src/yacc/parser.y index ddcae10..654e0a8 100644 --- a/src/yacc/parser.y +++ b/src/yacc/parser.y @@ -96,6 +96,10 @@ IOqualifyier: KeyIn | KeyOut KeyIn | ; +typecast: expr KeyAs type { DEBUG("Type-Cast"); }; + +reinterpretcast: '(' type ')' expr { DEBUG("Reinterpret-Cast"); }; + paramdecl: type ':' Ident { DEBUG("Param-Declaration"); }; funcall: Ident argumentlist { DEBUG("Function call"); }; @@ -131,7 +135,9 @@ identlist: Ident ',' identlist decl: type ':' identlist; -definition: decl '=' expr { DEBUG("Definition"); }; +definition: decl '=' expr { DEBUG("Definition"); } + | decl '=' typecast { DEBUG("Definition"); }; + | decl '=' reinterpretcast { DEBUG("Definition"); }; assign: Ident '=' expr { DEBUG("Assignment"); }; From 9eba9d1437dda4710e51bece656b7ee981a9a4a9 Mon Sep 17 00:00:00 2001 From: Ur Mom Date: Mon, 13 May 2024 13:45:22 +0200 Subject: [PATCH 02/11] fixed shift-reduce conflict --- src/yacc/parser.y | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/yacc/parser.y b/src/yacc/parser.y index 78c2948..c9cd81f 100644 --- a/src/yacc/parser.y +++ b/src/yacc/parser.y @@ -62,6 +62,7 @@ %left OpEquals OpNot '<' '>' %left OpAnd OpOr OpXor %left OpBitand OpBitor OpBitxor OpBitnot +%nonassoc KeyAs '(' ')' %% program: program programbody @@ -74,8 +75,6 @@ programbody: moduleimport | decl | typedef; - - expr: ValFloat | ValInt | ValMultistr @@ -83,7 +82,9 @@ expr: ValFloat | Ident | operation | boxaccess - | boxselfaccess; + | boxselfaccess + | typecast + | reinterpretcast; exprlist: expr ',' exprlist | expr; @@ -166,10 +167,7 @@ identlist: Ident ',' identlist decl: type ':' identlist | storagequalifier type ':' identlist - -definition: decl '=' expr { DEBUG("Definition"); } - | decl '=' typecast { DEBUG("Definition"); }; - | decl '=' reinterpretcast { DEBUG("Definition"); }; +definition: decl '=' expr { DEBUG("Definition"); }; storagequalifier: KeyGlobal | KeyStatic From 7da3c9151d669a830a67c91227cfa516412ec635 Mon Sep 17 00:00:00 2001 From: Ur Mom Date: Wed, 15 May 2024 15:50:26 +0200 Subject: [PATCH 03/11] fixed shift reduce conflicts in typecast --- src/yacc/parser.y | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/yacc/parser.y b/src/yacc/parser.y index c9cd81f..f02fad7 100644 --- a/src/yacc/parser.y +++ b/src/yacc/parser.y @@ -58,11 +58,18 @@ /* Operator associativity */ %right '=' -%left '+' '-' '*' '/' -%left OpEquals OpNot '<' '>' -%left OpAnd OpOr OpXor -%left OpBitand OpBitor OpBitxor OpBitnot -%nonassoc KeyAs '(' ')' +%left OpOr +%left OpXor +%left OpAnd +%left OpBitor +%left OpBitxor +%left OpBitand +%left OpEquals '<' '>' +%left '+' '-' +%left '*' '/' +%left OpNot OpBitnot +%left KeyAs +%left '(' ')' %% program: program programbody @@ -109,7 +116,7 @@ IOqualifyier: KeyIn | KeyOut KeyIn | ; -typecast: expr KeyAs type { DEBUG("Type-Cast"); }; +typecast: expr KeyAs type %prec KeyAs { DEBUG("Type-Cast"); }; reinterpretcast: '(' type ')' expr { DEBUG("Reinterpret-Cast"); }; From 2757132cf21c916ddbd2980e590b1f9abb909056 Mon Sep 17 00:00:00 2001 From: Ur Mom Date: Thu, 16 May 2024 10:27:44 +0200 Subject: [PATCH 04/11] Fixed Typo --- src/yacc/parser.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yacc/parser.y b/src/yacc/parser.y index 471948f..3a5c92c 100644 --- a/src/yacc/parser.y +++ b/src/yacc/parser.y @@ -283,7 +283,7 @@ boxcall: boxaccess argumentlist {AST_NODE_PTR boxcall = AST_new_node(AST_Call, N $$ = boxcall;}; -typecast: expr KeyAs type %prec KeyAs {{AST_NODE_PTR reinterpretcast = AST_new_node(AST_reinterpretcast, NULL); +typecast: expr KeyAs type %prec KeyAs {AST_NODE_PTR reinterpretcast = AST_new_node(AST_reinterpretcast, NULL); $$ = typecast; DEBUG("Type-Cast"); }; From e57682d717704c807545c2064152636fefe55d8c Mon Sep 17 00:00:00 2001 From: Ur Mom Date: Thu, 16 May 2024 11:34:51 +0200 Subject: [PATCH 05/11] changed node-name according to ast.h --- src/yacc/parser.y | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/yacc/parser.y b/src/yacc/parser.y index 3a5c92c..ece2282 100644 --- a/src/yacc/parser.y +++ b/src/yacc/parser.y @@ -283,12 +283,10 @@ boxcall: boxaccess argumentlist {AST_NODE_PTR boxcall = AST_new_node(AST_Call, N $$ = boxcall;}; -typecast: expr KeyAs type %prec KeyAs {AST_NODE_PTR reinterpretcast = AST_new_node(AST_reinterpretcast, NULL); - $$ = typecast; +typecast: expr KeyAs type %prec KeyAs {$$ = AST_new_node(AST_Typecast, $1); DEBUG("Type-Cast"); }; -reinterpretcast: '(' type ')' expr {AST_NODE_PTR reinterpretcast = AST_new_node(AST_reinterpretcast, NULL); - $$ = reinterpretcast; +reinterpretcast: '(' type ')' expr {$$ = AST_new_node(AST_Transmute, $4); DEBUG("Reinterpret-Cast"); }; From 8d7c6a4a2b41969423c6e7408fab5666ec1b1a62 Mon Sep 17 00:00:00 2001 From: Ur Mom Date: Thu, 16 May 2024 18:04:02 +0200 Subject: [PATCH 06/11] changed ast implementation for cast --- CMakeLists.txt | 2 +- src/yacc/parser.y | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 213143c..ced5f45 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,7 +62,7 @@ set(YACC_GENERATED_SOURCE_FILE ${PROJECT_SOURCE_DIR}/src/yacc/parser.tab.c) add_custom_command(OUTPUT ${YACC_GENERATED_SOURCE_FILE} - COMMAND bison + COMMAND yacc ARGS -Wno-yacc -Wcounterexamples -d -o ${YACC_GENERATED_SOURCE_FILE} ${YACC_SOURCE_FILE} COMMENT "generate C source file for parser" diff --git a/src/yacc/parser.y b/src/yacc/parser.y index ece2282..753c7bc 100644 --- a/src/yacc/parser.y +++ b/src/yacc/parser.y @@ -283,10 +283,16 @@ boxcall: boxaccess argumentlist {AST_NODE_PTR boxcall = AST_new_node(AST_Call, N $$ = boxcall;}; -typecast: expr KeyAs type %prec KeyAs {$$ = AST_new_node(AST_Typecast, $1); +typecast: expr KeyAs type %prec KeyAs {AST_NODE_PTR cast = AST_new_node(AST_Typecast, NULL); + AST_push_node(cast, $1); + AST_push_node(cast, $3); + $$ = cast; DEBUG("Type-Cast"); }; -reinterpretcast: '(' type ')' expr {$$ = AST_new_node(AST_Transmute, $4); +reinterpretcast: '(' type ')' expr { AST_NODE_PTR cast = AST_new_node(AST_Transmute, NULL); + AST_push_node(cast, $4); + AST_push_node(cast, $2); + $$ = cast; DEBUG("Reinterpret-Cast"); }; From 58f7170df63ec42b4f1dedc3628b1117da3ba362 Mon Sep 17 00:00:00 2001 From: SirTalksalot75 <132705706+SirTalksalot75@users.noreply.github.com> Date: Tue, 21 May 2024 12:20:45 +0200 Subject: [PATCH 07/11] changed lookuptable for casts in ast.c --- src/ast/ast.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ast/ast.c b/src/ast/ast.c index e503e1e..892af1f 100644 --- a/src/ast/ast.c +++ b/src/ast/ast.c @@ -70,8 +70,8 @@ void AST_init() { lookup_table[AST_Fun] = "fun"; lookup_table[AST_Call] = "funcall"; - lookup_table[AST_Typecast] = "cast"; - lookup_table[AST_Transmute] = "as"; + lookup_table[AST_Typecast] = "typecast"; + lookup_table[AST_Transmute] = "transmute"; lookup_table[AST_Condition] = "condition"; lookup_table[AST_List] = "list"; lookup_table[AST_ExprList] = "expr list"; From 0e098db7261fea530cdb7b33d5d538294dbb2f0d Mon Sep 17 00:00:00 2001 From: SirTalksalot75 <132705706+SirTalksalot75@users.noreply.github.com> Date: Tue, 21 May 2024 12:21:54 +0200 Subject: [PATCH 08/11] Update test_ast.py --- tests/ast/test_ast.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ast/test_ast.py b/tests/ast/test_ast.py index 28407f9..e3e5d48 100644 --- a/tests/ast/test_ast.py +++ b/tests/ast/test_ast.py @@ -58,8 +58,8 @@ def run_check_print_node(): 27 == 28 > 29 < -30 cast -31 as +30 typecast +31 transmute 32 funcall 33 value 34 typedef From 1d7fb31da56d6784a9de4d950c6a429d8338acfd Mon Sep 17 00:00:00 2001 From: SirTalksalot75 <132705706+SirTalksalot75@users.noreply.github.com> Date: Tue, 21 May 2024 14:20:15 +0200 Subject: [PATCH 09/11] Update CMakeLists.txt changed yacc ->bison --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ced5f45..213143c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,7 +62,7 @@ set(YACC_GENERATED_SOURCE_FILE ${PROJECT_SOURCE_DIR}/src/yacc/parser.tab.c) add_custom_command(OUTPUT ${YACC_GENERATED_SOURCE_FILE} - COMMAND yacc + COMMAND bison ARGS -Wno-yacc -Wcounterexamples -d -o ${YACC_GENERATED_SOURCE_FILE} ${YACC_SOURCE_FILE} COMMENT "generate C source file for parser" From 7705aea2388a459ed7e7af7c2fa387bed96b9275 Mon Sep 17 00:00:00 2001 From: servostar Date: Thu, 23 May 2024 21:54:37 +0200 Subject: [PATCH 10/11] added header for semantic tree types --- src/set/types.h | 472 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 472 insertions(+) create mode 100644 src/set/types.h diff --git a/src/set/types.h b/src/set/types.h new file mode 100644 index 0000000..c58dd67 --- /dev/null +++ b/src/set/types.h @@ -0,0 +1,472 @@ + +#ifndef SET_TYPES_H_ +#define SET_TYPES_H_ + +#include +#include + +/** + * @brief Primitive types form the basis of all other types. + * + */ +typedef enum PrimitiveType_t { + // 4 byte signed integer in two's complement + Int, + // 4 byte IEEE-754 single precision + Float +} PrimitiveType; + +/** + * @brief Represents the sign of a composite type. + * + */ +typedef enum Sign_t { + // type has a sign bit + Signed, + // type has no sign bit + Unsigned +} Sign; + +/** + * @brief Represents the scale of composite type which is multiplied + * with the base size in order to retrieve the the composites size. + * @attention Valid value are: { 1/8, 1/4, 1/2, 1, 2, 4, 8 } + * + */ +typedef double Scale; + +/** + * @brief A composite type is an extended definiton of a primitive type. + * + */ +typedef struct CompositeType_t { + // sign of composite + Sign sign; + Scale scale; + PrimitiveType primitive; +} CompositeType; + +/** + * @brief Specifies the specific type of the generic type struct. + * + */ +typedef enum TypeKind_t { + TypeKindPrimitive, + TypeKindComposite, + TypeKindBox, + TypeKindReference +} TypeKind; + +typedef struct Type_t Type; + +/** + * @brief Reference points to a type. + * @attention Can be nested. A reference can point to another reference: REF -> REF -> REF -> Primitive + * + */ +typedef Type* ReferenceType; + +typedef struct BoxType_t BoxType; + +typedef struct BoxMember_t { + const char* name; + Type* type; + BoxType* box; +} BoxMember; + +/** + * @brief Essentially a glorified struct + * + */ +typedef struct BoxType_t { + // hashtable of members. + // Associates the memebers name (const char*) with its type (BoxMember) + GHashTable* member; +} BoxType; + +typedef struct Variable_t Variable; + +typedef struct BoxAccess_t { + // list of recursive box accesses + // contains a list of BoxMembers (each specifying their own type, name and box type) + GArray* member; +} BoxAccess; + +typedef struct Type_t { + // specifiy the kind of this type + // used to determine which implementation to choose + TypeKind kind; + // actual implementation of the type + union TypeImplementation_t { + PrimitiveType primitive; + CompositeType composite; + BoxType box; + ReferenceType reference; + } impl; +} Type; + +typedef struct Typedefine_t { + const char* name; + Type type; +} Typedefine; + +const Type ShortShortUnsingedIntType = { + .kind = TypeKindComposite, + .impl = { + .composite = { + .sign = Unsigned, + .scale = 0.25, + .primitive = Int + } + } +}; + +const Type StringLiteralType = { + .kind = TypeKindReference, + .impl = { + .reference = (ReferenceType) &ShortShortUnsingedIntType, + } +}; + +/** + * @brief Reprents the value of type. Can be used to definitons, initialization and for expressions contants. + * + */ +typedef struct TypeValue_t { + // the type + Type type; + // UTF-8 representation of the type's value + const char* value; +} TypeValue; + +// .------------------------------------------------. +// | Functions | +// '------------------------------------------------' + +/** + * @brief Specifies a parameters I/O properties + * + */ +typedef enum IO_Qualifier_t { + // Can be read from but not written to. + // Function local only. + In, + // Can be written to but not read from. + // Passed back to the functions callee. + Out, + // Can be read from and written to. + // Passed back to the functions callee. + InOut, +} IO_Qualifier; + +/** + * @brief A functions parameter declaration. + * + */ +typedef struct ParameterDeclaration_t { + Type type; + IO_Qualifier qualifier; +} ParameterDeclaration; + +/** + * @brief A functions parameter. + * + */ +typedef struct ParameterDefinition_t { + ParameterDeclaration declaration; + // value to initalize the declaration with + // NOTE: type of initializer and declaration MUST be equal + TypeValue initializer; +} ParameterDefinition; + +typedef enum ParameterKind_t { + ParameterDeclarationKind, + ParameterDefinitionKind +} ParameterKind; + +/** + * @brief A parameter can either be a declaration or a definiton + * + */ +typedef struct Parameter_t { + const char* name; + ParameterKind kind; + union ParameterImplementation { + ParameterDeclaration declaration; + ParameterDefinition definiton; + } impl; +} Paramer; + +typedef struct FunctionDefinition_t { + // hashtable of parameters + // associates a parameters name (const char*) with its parameter declaration (ParameterDeclaration) + GArray* parameter; +} FunctionDefinition; + +// .------------------------------------------------. +// | Variables | +// '------------------------------------------------' + +typedef enum StorageQualifier_t { + Local, + Static, + Global +} StorageQualifier; + +typedef struct VariableDeclaration_t { + StorageQualifier qualifier; + Type type; +} VariableDeclaration; + +/** + * @brief Definiton of a variable + * + * @attention NOTE: The types of the initializer and the declaration must be equal + * + */ +typedef struct VariableDefiniton_t { + VariableDeclaration declaration; + TypeValue initializer; +} VariableDefiniton; + +typedef enum VariableKind_t { + VariableKindDeclaration, + VariableKindDefinition, + VariableKindBoxMember +} VariableKind; + +typedef struct Variable_t { + VariableKind kind; + const char* name; + union VariableImplementation { + VariableDeclaration declaration; + VariableDefiniton definiton; + BoxMember member; + } impl; +} Variable; + +// .------------------------------------------------. +// | Casts | +// '------------------------------------------------' + +/** + * @brief Perform a type cast, converting a value to different type whilest preserving as much of the original + * values information. + * + * @attention NOTE: Must check wether the given value's type can be parsed into + * the target type without loss. + * Lossy mean possibly loosing information such when casting a float into an int (no fraction anymore). + * + */ +typedef struct TypeCast_t { + Type targetType; +} TypeCast; + +/** + * @brief Perform a reinterpret cast. + * + * @attention NOTE: The given value's type must have the size in bytes as the target type. + * Transmuting a short int into a float should yield an error. + * + */ +typedef struct Transmute_t { + Type targetType; +} Transmute; + +// .------------------------------------------------. +// | Arithmetic | +// '------------------------------------------------' + +/** + * @brief Represents the arithmetic operator. + * + */ +typedef enum ArithmeticOperator_t { + Add, + Sub, + Mul, + Div +} ArithmeticOperator; + +// .------------------------------------------------. +// | Relational | +// '------------------------------------------------' + +/** + * @brief Represents the relational operator. + * + */ +typedef enum RelationalOperator_t { + Equal, + Greater, + Less +} RelationalOperator; + +// .------------------------------------------------. +// | Boolean | +// '------------------------------------------------' + +typedef enum BooleanOperator_t { + BooleanAnd, + BooleanOr, + BooleanNot, + BooleanXor, +} BooleanOperator; + +// .------------------------------------------------. +// | Logical | +// '------------------------------------------------' + +typedef enum LogicalOperator_t { + LogicalAnd, + LogicalOr, + LogicalNot, + LogicalXor, +} LogicalOperator; + +// .------------------------------------------------. +// | Logical | +// '------------------------------------------------' + +typedef enum BitwiseOperator_t { + BitwiseAnd, + BitwiseOr, + BitwiseNot, + BitwiseXor, +} BitwiseOperator; + +// .------------------------------------------------. +// | Operations | +// '------------------------------------------------' + +typedef enum OperationKind_t { + Arithmetic, + Relational, + Boolean, + Logical, + Bitwise +} OperationKind; + +typedef struct Operation_t { + // mode of operation + OperationKind kind; + // specific implementation + union OperationImplementation { + ArithmeticOperator arithmetic; + RelationalOperator relational; + BooleanOperator boolean; + LogicalOperator logical; + BitwiseOperator bitwise; + } impl; +} Operation; + +// .------------------------------------------------. +// | Expression | +// '------------------------------------------------' + +typedef enum ExpressionKind_t { + ExpressionKindOperation, + ExpressionKindTypeCast, + ExpressionKindTransmute, + ExpressionKindConstant +} ExpressionKind; + +typedef struct Expression_t { + ExpressionKind kind; + union ExpressionImplementation_t { + Operation operation; + TypeCast typecast; + Transmute transmute; + TypeValue constant; + Variable variable; + } impl; +} Expression; + +// .------------------------------------------------. +// | Function call | +// '------------------------------------------------' + +typedef struct FunctionCall_t { + // function to call + FunctionDefinition* function; + // list of expression arguments + GArray* expressions; +} FunctionCall; + +typedef struct FunctionBoxCall_t { + // function to call + FunctionDefinition* function; + // list of expression arguments + GArray* expressions; + // box which has the function defined for it + // NOTE: must be of TypeKind: Box + Variable selfArgument; +} FunctionBoxCall; + +typedef struct Block_t { + // array of statements + GArray* statemnts; +} Block; + +// .------------------------------------------------. +// | While | +// '------------------------------------------------' + +typedef struct While_t { + Expression conditon; + Block block; +} While; + +// .------------------------------------------------. +// | If/Else | +// '------------------------------------------------' + +typedef struct If_t { + Expression conditon; + Block block; +} If; + +typedef struct ElseIf_t { + Expression conditon; + Block block; +} ElseIf; + +typedef struct Else_t { + Block block; +} Else; + +typedef struct Branch_t { + If ifBranch; + // list of else-ifs (can be empty/NULL) + GArray* elseIfBranches; + Else elseBranch; +} Branch; + +// .------------------------------------------------. +// | Statements | +// '------------------------------------------------' + +typedef struct Assignment_t { + Variable* variable; + Expression value; +} Assignment; + +typedef enum StatementKind_t { + StatementKindFunctionCall, + StatementKindFunctionBoxCall, + StatementKindWhile, + StatementKindBranch, + StatementKindAssignment +} StatementKind; + +typedef struct Statement_t { + union StatementImplementation { + FunctionCall call; + FunctionBoxCall boxCall; + While whileLoop; + Branch branch; + Assignment assignment; + } impl; +} Statement; + +#endif // SET_TYPES_H_ From b7c7fd040ad24cc84f1922fe8c12be19658e1670 Mon Sep 17 00:00:00 2001 From: Filleo Date: Sun, 26 May 2024 16:42:12 +0200 Subject: [PATCH 11/11] added ast pointer to all structs removed StringLiteralType because of multiple definitions if used --- src/set/types.h | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/src/set/types.h b/src/set/types.h index c58dd67..621fe7f 100644 --- a/src/set/types.h +++ b/src/set/types.h @@ -44,6 +44,7 @@ typedef struct CompositeType_t { Sign sign; Scale scale; PrimitiveType primitive; + AST_NODE_PTR nodePtr; } CompositeType; /** @@ -72,6 +73,7 @@ typedef struct BoxMember_t { const char* name; Type* type; BoxType* box; + AST_NODE_PTR nodePtr; } BoxMember; /** @@ -82,6 +84,7 @@ typedef struct BoxType_t { // hashtable of members. // Associates the memebers name (const char*) with its type (BoxMember) GHashTable* member; + AST_NODE_PTR nodePtr; } BoxType; typedef struct Variable_t Variable; @@ -90,6 +93,7 @@ typedef struct BoxAccess_t { // list of recursive box accesses // contains a list of BoxMembers (each specifying their own type, name and box type) GArray* member; + AST_NODE_PTR nodePtr; } BoxAccess; typedef struct Type_t { @@ -103,30 +107,16 @@ typedef struct Type_t { BoxType box; ReferenceType reference; } impl; + AST_NODE_PTR nodePtr; } Type; typedef struct Typedefine_t { const char* name; Type type; + AST_NODE_PTR nodePtr; } Typedefine; -const Type ShortShortUnsingedIntType = { - .kind = TypeKindComposite, - .impl = { - .composite = { - .sign = Unsigned, - .scale = 0.25, - .primitive = Int - } - } -}; -const Type StringLiteralType = { - .kind = TypeKindReference, - .impl = { - .reference = (ReferenceType) &ShortShortUnsingedIntType, - } -}; /** * @brief Reprents the value of type. Can be used to definitons, initialization and for expressions contants. @@ -137,6 +127,7 @@ typedef struct TypeValue_t { Type type; // UTF-8 representation of the type's value const char* value; + AST_NODE_PTR nodePtr; } TypeValue; // .------------------------------------------------. @@ -166,6 +157,7 @@ typedef enum IO_Qualifier_t { typedef struct ParameterDeclaration_t { Type type; IO_Qualifier qualifier; + AST_NODE_PTR nodePtr; } ParameterDeclaration; /** @@ -177,6 +169,7 @@ typedef struct ParameterDefinition_t { // value to initalize the declaration with // NOTE: type of initializer and declaration MUST be equal TypeValue initializer; + AST_NODE_PTR nodePtr; } ParameterDefinition; typedef enum ParameterKind_t { @@ -195,12 +188,14 @@ typedef struct Parameter_t { ParameterDeclaration declaration; ParameterDefinition definiton; } impl; + AST_NODE_PTR nodePtr; } Paramer; typedef struct FunctionDefinition_t { // hashtable of parameters // associates a parameters name (const char*) with its parameter declaration (ParameterDeclaration) GArray* parameter; + AST_NODE_PTR nodePtr; } FunctionDefinition; // .------------------------------------------------. @@ -216,6 +211,7 @@ typedef enum StorageQualifier_t { typedef struct VariableDeclaration_t { StorageQualifier qualifier; Type type; + AST_NODE_PTR nodePtr; } VariableDeclaration; /** @@ -227,6 +223,7 @@ typedef struct VariableDeclaration_t { typedef struct VariableDefiniton_t { VariableDeclaration declaration; TypeValue initializer; + AST_NODE_PTR nodePtr; } VariableDefiniton; typedef enum VariableKind_t { @@ -243,6 +240,7 @@ typedef struct Variable_t { VariableDefiniton definiton; BoxMember member; } impl; + AST_NODE_PTR nodePtr; } Variable; // .------------------------------------------------. @@ -260,6 +258,7 @@ typedef struct Variable_t { */ typedef struct TypeCast_t { Type targetType; + AST_NODE_PTR nodePtr; } TypeCast; /** @@ -271,6 +270,7 @@ typedef struct TypeCast_t { */ typedef struct Transmute_t { Type targetType; + AST_NODE_PTR nodePtr; } Transmute; // .------------------------------------------------. @@ -358,6 +358,7 @@ typedef struct Operation_t { LogicalOperator logical; BitwiseOperator bitwise; } impl; + AST_NODE_PTR nodePtr; } Operation; // .------------------------------------------------. @@ -380,6 +381,7 @@ typedef struct Expression_t { TypeValue constant; Variable variable; } impl; + AST_NODE_PTR nodePtr; } Expression; // .------------------------------------------------. @@ -391,6 +393,7 @@ typedef struct FunctionCall_t { FunctionDefinition* function; // list of expression arguments GArray* expressions; + AST_NODE_PTR nodePtr; } FunctionCall; typedef struct FunctionBoxCall_t { @@ -401,11 +404,13 @@ typedef struct FunctionBoxCall_t { // box which has the function defined for it // NOTE: must be of TypeKind: Box Variable selfArgument; + AST_NODE_PTR nodePtr; } FunctionBoxCall; typedef struct Block_t { // array of statements GArray* statemnts; + AST_NODE_PTR nodePtr; } Block; // .------------------------------------------------. @@ -415,6 +420,7 @@ typedef struct Block_t { typedef struct While_t { Expression conditon; Block block; + AST_NODE_PTR nodePtr; } While; // .------------------------------------------------. @@ -424,15 +430,18 @@ typedef struct While_t { typedef struct If_t { Expression conditon; Block block; + AST_NODE_PTR nodePtr; } If; typedef struct ElseIf_t { Expression conditon; Block block; + AST_NODE_PTR nodePtr; } ElseIf; typedef struct Else_t { Block block; + AST_NODE_PTR nodePtr; } Else; typedef struct Branch_t { @@ -440,6 +449,7 @@ typedef struct Branch_t { // list of else-ifs (can be empty/NULL) GArray* elseIfBranches; Else elseBranch; + AST_NODE_PTR nodePtr; } Branch; // .------------------------------------------------. @@ -449,6 +459,7 @@ typedef struct Branch_t { typedef struct Assignment_t { Variable* variable; Expression value; + AST_NODE_PTR nodePtr; } Assignment; typedef enum StatementKind_t { @@ -467,6 +478,7 @@ typedef struct Statement_t { Branch branch; Assignment assignment; } impl; + AST_NODE_PTR nodePtr; } Statement; #endif // SET_TYPES_H_