Merge pull request #103 from Servostar/89-implement-structs-for-parser
added ast pointer to all structs
This commit is contained in:
commit
966bb3b189
|
@ -44,6 +44,7 @@ typedef struct CompositeType_t {
|
||||||
Sign sign;
|
Sign sign;
|
||||||
Scale scale;
|
Scale scale;
|
||||||
PrimitiveType primitive;
|
PrimitiveType primitive;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} CompositeType;
|
} CompositeType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -72,6 +73,7 @@ typedef struct BoxMember_t {
|
||||||
const char* name;
|
const char* name;
|
||||||
Type* type;
|
Type* type;
|
||||||
BoxType* box;
|
BoxType* box;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} BoxMember;
|
} BoxMember;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,6 +84,7 @@ typedef struct BoxType_t {
|
||||||
// hashtable of members.
|
// hashtable of members.
|
||||||
// Associates the memebers name (const char*) with its type (BoxMember)
|
// Associates the memebers name (const char*) with its type (BoxMember)
|
||||||
GHashTable* member;
|
GHashTable* member;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} BoxType;
|
} BoxType;
|
||||||
|
|
||||||
typedef struct Variable_t Variable;
|
typedef struct Variable_t Variable;
|
||||||
|
@ -90,6 +93,7 @@ typedef struct BoxAccess_t {
|
||||||
// list of recursive box accesses
|
// list of recursive box accesses
|
||||||
// contains a list of BoxMembers (each specifying their own type, name and box type)
|
// contains a list of BoxMembers (each specifying their own type, name and box type)
|
||||||
GArray* member;
|
GArray* member;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} BoxAccess;
|
} BoxAccess;
|
||||||
|
|
||||||
typedef struct Type_t {
|
typedef struct Type_t {
|
||||||
|
@ -103,30 +107,16 @@ typedef struct Type_t {
|
||||||
BoxType box;
|
BoxType box;
|
||||||
ReferenceType reference;
|
ReferenceType reference;
|
||||||
} impl;
|
} impl;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} Type;
|
} Type;
|
||||||
|
|
||||||
typedef struct Typedefine_t {
|
typedef struct Typedefine_t {
|
||||||
const char* name;
|
const char* name;
|
||||||
Type type;
|
Type type;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} Typedefine;
|
} 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.
|
* @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;
|
Type type;
|
||||||
// UTF-8 representation of the type's value
|
// UTF-8 representation of the type's value
|
||||||
const char* value;
|
const char* value;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} TypeValue;
|
} TypeValue;
|
||||||
|
|
||||||
// .------------------------------------------------.
|
// .------------------------------------------------.
|
||||||
|
@ -166,6 +157,7 @@ typedef enum IO_Qualifier_t {
|
||||||
typedef struct ParameterDeclaration_t {
|
typedef struct ParameterDeclaration_t {
|
||||||
Type type;
|
Type type;
|
||||||
IO_Qualifier qualifier;
|
IO_Qualifier qualifier;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} ParameterDeclaration;
|
} ParameterDeclaration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -177,6 +169,7 @@ typedef struct ParameterDefinition_t {
|
||||||
// value to initalize the declaration with
|
// value to initalize the declaration with
|
||||||
// NOTE: type of initializer and declaration MUST be equal
|
// NOTE: type of initializer and declaration MUST be equal
|
||||||
TypeValue initializer;
|
TypeValue initializer;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} ParameterDefinition;
|
} ParameterDefinition;
|
||||||
|
|
||||||
typedef enum ParameterKind_t {
|
typedef enum ParameterKind_t {
|
||||||
|
@ -195,12 +188,14 @@ typedef struct Parameter_t {
|
||||||
ParameterDeclaration declaration;
|
ParameterDeclaration declaration;
|
||||||
ParameterDefinition definiton;
|
ParameterDefinition definiton;
|
||||||
} impl;
|
} impl;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} Paramer;
|
} Paramer;
|
||||||
|
|
||||||
typedef struct FunctionDefinition_t {
|
typedef struct FunctionDefinition_t {
|
||||||
// hashtable of parameters
|
// hashtable of parameters
|
||||||
// associates a parameters name (const char*) with its parameter declaration (ParameterDeclaration)
|
// associates a parameters name (const char*) with its parameter declaration (ParameterDeclaration)
|
||||||
GArray* parameter;
|
GArray* parameter;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} FunctionDefinition;
|
} FunctionDefinition;
|
||||||
|
|
||||||
// .------------------------------------------------.
|
// .------------------------------------------------.
|
||||||
|
@ -216,6 +211,7 @@ typedef enum StorageQualifier_t {
|
||||||
typedef struct VariableDeclaration_t {
|
typedef struct VariableDeclaration_t {
|
||||||
StorageQualifier qualifier;
|
StorageQualifier qualifier;
|
||||||
Type type;
|
Type type;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} VariableDeclaration;
|
} VariableDeclaration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -227,6 +223,7 @@ typedef struct VariableDeclaration_t {
|
||||||
typedef struct VariableDefiniton_t {
|
typedef struct VariableDefiniton_t {
|
||||||
VariableDeclaration declaration;
|
VariableDeclaration declaration;
|
||||||
TypeValue initializer;
|
TypeValue initializer;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} VariableDefiniton;
|
} VariableDefiniton;
|
||||||
|
|
||||||
typedef enum VariableKind_t {
|
typedef enum VariableKind_t {
|
||||||
|
@ -243,6 +240,7 @@ typedef struct Variable_t {
|
||||||
VariableDefiniton definiton;
|
VariableDefiniton definiton;
|
||||||
BoxMember member;
|
BoxMember member;
|
||||||
} impl;
|
} impl;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} Variable;
|
} Variable;
|
||||||
|
|
||||||
// .------------------------------------------------.
|
// .------------------------------------------------.
|
||||||
|
@ -260,6 +258,7 @@ typedef struct Variable_t {
|
||||||
*/
|
*/
|
||||||
typedef struct TypeCast_t {
|
typedef struct TypeCast_t {
|
||||||
Type targetType;
|
Type targetType;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} TypeCast;
|
} TypeCast;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -271,6 +270,7 @@ typedef struct TypeCast_t {
|
||||||
*/
|
*/
|
||||||
typedef struct Transmute_t {
|
typedef struct Transmute_t {
|
||||||
Type targetType;
|
Type targetType;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} Transmute;
|
} Transmute;
|
||||||
|
|
||||||
// .------------------------------------------------.
|
// .------------------------------------------------.
|
||||||
|
@ -358,6 +358,7 @@ typedef struct Operation_t {
|
||||||
LogicalOperator logical;
|
LogicalOperator logical;
|
||||||
BitwiseOperator bitwise;
|
BitwiseOperator bitwise;
|
||||||
} impl;
|
} impl;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} Operation;
|
} Operation;
|
||||||
|
|
||||||
// .------------------------------------------------.
|
// .------------------------------------------------.
|
||||||
|
@ -380,6 +381,7 @@ typedef struct Expression_t {
|
||||||
TypeValue constant;
|
TypeValue constant;
|
||||||
Variable variable;
|
Variable variable;
|
||||||
} impl;
|
} impl;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} Expression;
|
} Expression;
|
||||||
|
|
||||||
// .------------------------------------------------.
|
// .------------------------------------------------.
|
||||||
|
@ -391,6 +393,7 @@ typedef struct FunctionCall_t {
|
||||||
FunctionDefinition* function;
|
FunctionDefinition* function;
|
||||||
// list of expression arguments
|
// list of expression arguments
|
||||||
GArray* expressions;
|
GArray* expressions;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} FunctionCall;
|
} FunctionCall;
|
||||||
|
|
||||||
typedef struct FunctionBoxCall_t {
|
typedef struct FunctionBoxCall_t {
|
||||||
|
@ -401,11 +404,13 @@ typedef struct FunctionBoxCall_t {
|
||||||
// box which has the function defined for it
|
// box which has the function defined for it
|
||||||
// NOTE: must be of TypeKind: Box
|
// NOTE: must be of TypeKind: Box
|
||||||
Variable selfArgument;
|
Variable selfArgument;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} FunctionBoxCall;
|
} FunctionBoxCall;
|
||||||
|
|
||||||
typedef struct Block_t {
|
typedef struct Block_t {
|
||||||
// array of statements
|
// array of statements
|
||||||
GArray* statemnts;
|
GArray* statemnts;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} Block;
|
} Block;
|
||||||
|
|
||||||
// .------------------------------------------------.
|
// .------------------------------------------------.
|
||||||
|
@ -415,6 +420,7 @@ typedef struct Block_t {
|
||||||
typedef struct While_t {
|
typedef struct While_t {
|
||||||
Expression conditon;
|
Expression conditon;
|
||||||
Block block;
|
Block block;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} While;
|
} While;
|
||||||
|
|
||||||
// .------------------------------------------------.
|
// .------------------------------------------------.
|
||||||
|
@ -424,15 +430,18 @@ typedef struct While_t {
|
||||||
typedef struct If_t {
|
typedef struct If_t {
|
||||||
Expression conditon;
|
Expression conditon;
|
||||||
Block block;
|
Block block;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} If;
|
} If;
|
||||||
|
|
||||||
typedef struct ElseIf_t {
|
typedef struct ElseIf_t {
|
||||||
Expression conditon;
|
Expression conditon;
|
||||||
Block block;
|
Block block;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} ElseIf;
|
} ElseIf;
|
||||||
|
|
||||||
typedef struct Else_t {
|
typedef struct Else_t {
|
||||||
Block block;
|
Block block;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} Else;
|
} Else;
|
||||||
|
|
||||||
typedef struct Branch_t {
|
typedef struct Branch_t {
|
||||||
|
@ -440,6 +449,7 @@ typedef struct Branch_t {
|
||||||
// list of else-ifs (can be empty/NULL)
|
// list of else-ifs (can be empty/NULL)
|
||||||
GArray* elseIfBranches;
|
GArray* elseIfBranches;
|
||||||
Else elseBranch;
|
Else elseBranch;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} Branch;
|
} Branch;
|
||||||
|
|
||||||
// .------------------------------------------------.
|
// .------------------------------------------------.
|
||||||
|
@ -449,6 +459,7 @@ typedef struct Branch_t {
|
||||||
typedef struct Assignment_t {
|
typedef struct Assignment_t {
|
||||||
Variable* variable;
|
Variable* variable;
|
||||||
Expression value;
|
Expression value;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} Assignment;
|
} Assignment;
|
||||||
|
|
||||||
typedef enum StatementKind_t {
|
typedef enum StatementKind_t {
|
||||||
|
@ -467,6 +478,7 @@ typedef struct Statement_t {
|
||||||
Branch branch;
|
Branch branch;
|
||||||
Assignment assignment;
|
Assignment assignment;
|
||||||
} impl;
|
} impl;
|
||||||
|
AST_NODE_PTR nodePtr;
|
||||||
} Statement;
|
} Statement;
|
||||||
|
|
||||||
#endif // SET_TYPES_H_
|
#endif // SET_TYPES_H_
|
||||||
|
|
Loading…
Reference in New Issue