F diff --git a/src/frontend/parse/parse_expression.c b/src/frontend/parse/parse_expression.c
--- a/src/frontend/parse/parse_expression.c
+++ b/src/frontend/parse/parse_expression.c
}
/*TODO make it iterative*/
- switch(((struct token*)translation_data->tokens->first->data)->type)
+ switch(kw_get(translation_data))
{
case KW_PLUSPLUS:
chomp(translation_data); hold_expression=parse_unary_expression(translation_data,scope);
F diff --git a/src/program/program.c b/src/program/program.c
--- a/src/program/program.c
+++ b/src/program/program.c
struct Source_File *base_file;
struct Program *program;
struct Translation_Data *hold_translation_data;
- char *this_directory[]={"./",NULL};
+ char *this_directory[]={"./","",NULL};
assert(base_source_names!=NULL);
F diff --git a/src/semantics/ast.c b/src/semantics/ast.c
--- a/src/semantics/ast.c
+++ b/src/semantics/ast.c
struct AST_Binary_Expression* get_relation_expression_tree(struct AST_Expression *left,struct AST_Expression *right,enum AST_Type operation,struct Translation_Data *translation_data)
{
- return NULL;
+ if(constraint_check_relational_operation(left,right,operation,translation_data))
+ {
+ return get_binary_expression_tree(left,right,get_expression_value_rvalue(get_temp_object((struct Type*)get_type_insecure(TS_INT,TSIGN_SIGNED,TC_NONE,INT_SIZE,translation_data))),operation);
+ }else
+ {
+ delete_ast((struct AST*)left), delete_ast((struct AST*)right);
+ return NULL;
+ }
}
struct AST_Binary_Expression* get_equality_expression_tree(struct AST_Expression *left,struct AST_Expression *right,enum AST_Type operation,struct Translation_Data *translation_data)
{
- if(constraint_check_equality_expression(left,right,operation,translation_data))
+ if(constraint_check_equality_expression(left,right,translation_data))
{
return get_binary_expression_tree(left,right,get_expression_value_rvalue(get_temp_object((struct Type*)get_type_insecure(TS_INT,TSIGN_SIGNED,TC_NONE,INT_SIZE,translation_data))),operation);
}else
struct AST_Unary_Expression* get_postfix_inc_dec_tree(struct AST_Expression *operand,enum AST_Type operation,struct Translation_Data *translation_data)
{
- return NULL;
+ struct Type *operand_type;
+ operand_type=extract_expresion_value_type(operand->value,translation_data);
+ if(constraint_check_postfix_inc_dec_expression(operand,operation,translation_data))
+ {
+ return get_unary_expression_tree(operand,get_expression_value_rvalue(get_temp_object(operand_type)),operation); /*TODO return expression value rvaluesness is under question*/
+ }else
+ {
+ delete_ast((struct AST*)operand);
+ return NULL;
+ }
}
struct AST_Unary_Expression* get_prefix_inc_dec_tree(struct AST_Expression *operand,enum AST_Type operation,struct Translation_Data *translation_data)
{
- return NULL;
+ struct Type *operand_type;
+ operand_type=extract_expresion_value_type(operand->value,translation_data);
+ if(constraint_check_prefix_inc_dec_expression(operand,operation,translation_data))
+ {
+ return get_unary_expression_tree(operand,get_expression_value_rvalue(get_temp_object(operand_type)),operation); /*TODO return expression value rvaluesness is under question*/
+ }else
+ {
+ delete_ast((struct AST*)operand);
+ return NULL;
+ }
+
}
struct AST_Unary_Expression* get_unary_sizeof_tree(struct AST_Expression *operand,struct Translation_Data *translation_data)
{
F diff --git a/src/semantics/value/constraints.c b/src/semantics/value/constraints.c
--- a/src/semantics/value/constraints.c
+++ b/src/semantics/value/constraints.c
{
return 1;
}
+ /*
+ * One of the following shall hold:
+ * both operands have real type
+ * both operands are pointers to qualified or unqualified versions of compatible object types
+ * both operands are pointers to qualified or unqualified versions of compatible incomplete type
+ *
+ * */
+ char constraint_check_relational_operation(struct AST_Expression *left,struct AST_Expression *right,enum AST_Type operation,struct Translation_Data *translation_data)
+ {
+ return 1;
+ }
/* One of the following shall hold:
* both operands have arithmetic type
* both operands are pointers to qualified or unqualified versions of compatible types
* one operand is a pointer to object or incomplete type and the other is a pointer to a qualified or unqualified version of void
* one operand is a pointer and the other is a null pointer constant*/
- char constraint_check_equality_expression(struct AST_Expression *left,struct AST_Expression *right,enum AST_Type operation,struct Translation_Data *translation_data)
+ char constraint_check_equality_expression(struct AST_Expression *left,struct AST_Expression *right,struct Translation_Data *translation_data)
{
struct Type *left_type;
struct Type *right_type;
switch(operation)
{
- OP_ADD_ASSIGN:
- OP_SUBTRACT_ASSIGN:
+ case OP_ADD_ASSIGN:
+ case OP_SUBTRACT_ASSIGN:
left_type=extract_expresion_value_type(left->value,translation_data);
right_type=extract_expresion_value_type(right->value,translation_data);
return 0;
}
assert(0);
- OP_MULTIPLY_ASSIGN:
- OP_DIV_ASSIGN:
- OP_REMAINDER_ASSIGN:
+ case OP_MULTIPLY_ASSIGN:
+ case OP_DIV_ASSIGN:
+ case OP_REMAINDER_ASSIGN:
return constraint_check_multiplicative_expression(left,right,operation,translation_data);
- OP_SHIFT_RIGHT_ASSIGN:
- OP_SHIFT_LEFT_ASSIGN:
+ case OP_SHIFT_RIGHT_ASSIGN:
+ case OP_SHIFT_LEFT_ASSIGN:
return constraint_check_shift_expression(left,right,operation,translation_data);
- OP_AND_ASSIGN:
- OP_XOR_ASSIGN:
- OP_PIPE_ASSIGN:
+ case OP_AND_ASSIGN:
+ case OP_XOR_ASSIGN:
+ case OP_PIPE_ASSIGN:
return constraint_check_bitwise_expression(left,right,operation,translation_data);
default:
assert(0);
{
return 1;
}
+ char constraint_check_sizeof_expression(struct AST_Expression *expression,struct Translation_Data *translation_data)
+ {
+ return 1;
+ }
char constraint_check_unary_arithmetic_expression(struct AST_Expression *operand,enum AST_Type operation,struct Translation_Data *translation_data)
{
return 1;
}
- char constraint_check_postfix_inc_dec_tree(struct AST_Expression *operand,enum AST_Type operation,struct Translation_Data *translation_data)
+ char constraint_check_postfix_inc_dec_expression(struct AST_Expression *operand,enum AST_Type operation,struct Translation_Data *translation_data)
+ {
+ return 1;
+ }
+ char constraint_check_prefix_inc_dec_expression(struct AST_Expression *operand,enum AST_Type operation,struct Translation_Data *translation_data)
+ {
+ return 1;
+ }
+ char constraint_check_cast_expression(struct Type *type,struct AST_Expression *expression,struct Translation_Data *translation_data)
{
return 1;
}
-
#endif
F diff --git a/src/semantics/value/constraints.h b/src/semantics/value/constraints.h
--- a/src/semantics/value/constraints.h
+++ b/src/semantics/value/constraints.h
char constraint_check_additive_expression(struct AST_Expression *left,struct AST_Expression *right,enum AST_Type operation,struct Translation_Data *translation_data);
char constraint_check_shift_expression(struct AST_Expression *left,struct AST_Expression *right,enum AST_Type operation,struct Translation_Data *translation_data);
char constraint_check_bitwise_expression(struct AST_Expression *left,struct AST_Expression *right,enum AST_Type operation,struct Translation_Data *translation_data);
- char constraint_check_equality_expression(struct AST_Expression *left,struct AST_Expression *right,enum AST_Type operation,struct Translation_Data *translation_data);
+ char constraint_check_relational_operation(struct AST_Expression *left,struct AST_Expression *right,enum AST_Type operation,struct Translation_Data *translation_data);
+ char constraint_check_equality_expression(struct AST_Expression *left,struct AST_Expression *right,struct Translation_Data *translation_data);
char constraint_check_logical_expression(struct AST_Expression *left,struct AST_Expression *right,enum AST_Type operation,struct Translation_Data *translation_data);
char constraint_check_simple_assignment_expression(struct AST_Expression *left,struct AST_Expression *right,struct Translation_Data *translation_data);
char constraint_check_compound_assignment_expression(struct AST_Expression *left,struct AST_Expression *right,enum AST_Type operation,struct Translation_Data *translation_data);
char constraint_check_address_expression(struct AST_Expression *operand,struct Translation_Data *translation_data);
char constraint_check_sizeof_by_type(struct Type *type);
char constraint_check_unary_arithmetic_expression(struct AST_Expression *operand,enum AST_Type operation,struct Translation_Data *translation_data);
- char constraint_check_postfix_inc_dec_tree(struct AST_Expression *operand,enum AST_Type operation,struct Translation_Data *translation_data);
- char constraing_check_sizeof(struct AST_Expression *expression,struct Translation_Data *translation_data);
+ char constraint_check_postfix_inc_dec_expression(struct AST_Expression *operand,enum AST_Type operation,struct Translation_Data *translation_data);
+ char constraint_check_prefix_inc_dec_expression(struct AST_Expression *operand,enum AST_Type operation,struct Translation_Data *translation_data);
+ char constraint_check_sizeof_expression(struct AST_Expression *expression,struct Translation_Data *translation_data);
+ char constraint_check_cast_expression(struct Type *type,struct AST_Expression *expression,struct Translation_Data *translation_data);
#endif