aboutsummaryrefslogtreecommitdiffstats
path: root/src/backend/targets/print
diff options
context:
space:
mode:
authorGalin Simeonov <gts@volconst.com>2021-06-04 13:04:36 +0300
committerGalin Simeonov <gts@volconst.com>2021-07-15 18:04:02 +0300
commitb845e4754be86d2216733d9bea75cb301f38739d (patch)
tree5ba6355d1cb36b1bfaadf82781796b1c42b9202b /src/backend/targets/print
parent76fc38b3cdfded2911b464baa7b182b5102318d1 (diff)
downloadMEGATRON-b845e4754be86d2216733d9bea75cb301f38739d.tar.gz
added expressions and the if statement
Diffstat (limited to 'src/backend/targets/print')
-rw-r--r--src/backend/targets/print/print.c97
-rw-r--r--src/backend/targets/print/print.h4
2 files changed, 97 insertions, 4 deletions
diff --git a/src/backend/targets/print/print.c b/src/backend/targets/print/print.c
index 8eae3dd..7649b91 100644
--- a/src/backend/targets/print/print.c
+++ b/src/backend/targets/print/print.c
@@ -36,6 +36,12 @@ void print_keyword_enum(enum Keyword code)
case KW_CLOSE_SQUARE:
printf("KW_CLOSE_SQUARE");
break;
+ case KW_OPEN_NORMAL:
+ printf("KW_OPEN_NORMAL");
+ break;
+ case KW_CLOSE_NORMAL:
+ printf("KW_CLOSE_NORMAL");
+ break;
case KW_PIPE:
printf("KW_PIPE");
break;
@@ -54,15 +60,27 @@ void print_keyword_enum(enum Keyword code)
case KW_EVENT:
printf("KW_EVENT");
break;
- case KW_TRANSITIONS:
- printf("KW__TRANSITIONS");
- break;
case KW_EXECUTE:
printf("KW_EXECUTE");
break;
+ case KW_TRANSITIONS:
+ printf("KW_TRANSITIONS");
+ break;
case KW_COMMA:
printf("KW_COMMA");
break;
+ case KW_DOT:
+ printf("KW_DOT");
+ break;
+ case KW_AND:
+ printf("KW_AND");
+ break;
+ case KW_OR:
+ printf("KW_OR");
+ break;
+ case KW_NOT:
+ printf("KW_NOT");
+ break;
default:
printf("LEXERROR");
}
@@ -95,6 +113,9 @@ void print_ast_enum(enum AST_Type type)
{
switch(type)
{
+ case AST_TYPE_TRANSLATION_UNIT:
+ printf("AST_TYPE_TRANSLATION_UNIT");
+ break;
case AST_TYPE_MACHINE:
printf("AST_TYPE_MACHINE");
break;
@@ -122,6 +143,21 @@ void print_ast_enum(enum AST_Type type)
case AST_TYPE_PIPELINE:
printf("AST_TYPE_PIPELINE");
break;
+ case AST_TYPE_OP_AND:
+ printf("AST_TYPE_OP_AND");
+ break;
+ case AST_TYPE_OP_OR:
+ printf("AST_TYPE_OP_OR");
+ break;
+ case AST_TYPE_OP_NOT:
+ printf("AST_TYPE_OP_NOT");
+ break;
+ case AST_TYPE_OP_SELECTOR:
+ printf("AST_TYPE_OP_SELECTOR");
+ break;
+ case AST_TYPE_UNFINISHED_STATE:
+ printf("AST_TYPE_UNFINISHED_STATE");
+ break;
default:
printf("AST_NOP");
}
@@ -160,6 +196,20 @@ void print_ast(struct AST *tree)
case AST_TYPE_PIPELINE:
print_ast_pipeline((struct AST_Pipeline*)tree);
break;
+ case AST_TYPE_TRANSLATION_UNIT:
+ print_ast_translation_unit((struct AST_Translation_Unit*)tree);
+ break;
+ case AST_TYPE_OP_AND:
+ case AST_TYPE_OP_OR:
+ case AST_TYPE_OP_SELECTOR:
+ print_ast_binary_expression((struct AST_Binary_Expression*)tree);
+ break;
+ case AST_TYPE_OP_NOT:
+ print_ast_unary_expression((struct AST_Unary_Expression*)tree);
+ break;
+ case AST_TYPE_UNFINISHED_STATE:
+ print_ast_unchecked_state((struct AST_Unchecked_State*)tree);
+ break;
default:
printf("noast");
}
@@ -212,7 +262,7 @@ void print_ast_transition(struct AST_Transition* tree)
assert(tree);
printf("TRANSITION [\nFROM");
- print_ast_state(tree->from);
+ print_ast(tree->from);
printf(" TO ");
print_ast_state(tree->to);
printf(" COMMAND {");
@@ -292,4 +342,43 @@ void print_errors(struct Translation_Data *translation_data)
print_error(it->data);
}
}
+void print_ast_translation_unit(struct AST_Translation_Unit *tree)
+{
+ size_t i;
+ printf("TRANSLATION UNIT\n[\n");
+ for(i=0;i<tree->number_of_machines;++i)
+ print_ast_machine(tree->machines[i]);
+ printf("\n] TRANSLATION UNIT END \n");
+}
+void print_ast_binary_expression(struct AST_Binary_Expression *tree)
+{
+ printf(" (");
+ print_ast(tree->left);
+ switch(tree->type)
+ {
+ case AST_TYPE_OP_AND:
+ printf("&&");
+ break;
+ case AST_TYPE_OP_OR:
+ printf("||");
+ break;
+ case AST_TYPE_OP_SELECTOR:
+ printf(".");
+ break;
+ default:
+ printf("?!!?!?!?");
+ }
+ print_ast(tree->right);
+ printf(")");
+}
+void print_ast_unary_expression(struct AST_Unary_Expression *tree)
+{
+ printf("(!");
+ print_ast(tree->operand);
+ printf(")");
+}
+void print_ast_unchecked_state(struct AST_Unchecked_State *tree)
+{
+ print_token(tree->name);
+}
#endif
diff --git a/src/backend/targets/print/print.h b/src/backend/targets/print/print.h
index 54d47ce..d318792 100644
--- a/src/backend/targets/print/print.h
+++ b/src/backend/targets/print/print.h
@@ -21,6 +21,10 @@ void print_ast_command(struct AST_Command* tree);
void print_ast_pipeline(struct AST_Pipeline* tree);
void print_ast_machine(struct AST_Machine* tree);
void print_ast_transitions(struct AST_Transitions* tree);
+void print_ast_translation_unit(struct AST_Translation_Unit *tree);
+void print_ast_binary_expression(struct AST_Binary_Expression *tree);
+void print_ast_unary_expression(struct AST_Unary_Expression *tree);
+void print_ast_unchecked_state(struct AST_Unchecked_State *tree);
void print_error(struct Error *error);
void print_errors(struct Translation_Data *translation_data);