You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
eon/print/print.c

54 lines
1.2 KiB

#include "../includes/include.h"
/**
* Creates a print node
*
* @param pVarName name of variable to print
* @return node_info print statement
*/
node_info *create_print_var_node(char *p_var_name)
{
node_info *new_node = malloc(sizeof(node_info));
new_node->opperation = 6;
new_node->name = p_var_name;
return new_node;
}
/**
*
* @params opperation value, see print struct for info
* @params int value to be printed
* @params string to be printed
*
*/
node_info *create_print_statement(int opperation, int value, char *string)
{
node_info *n = malloc(sizeof(node_info));
print a;
switch(opperation)
{
case 1:
n->opperation = 3;
a.value = value;
a.opperation = 1;
n->printExpression = a;
return n;
case 2:
n->opperation = 3;
a.string = string;
a.opperation = 2;
n->printExpression = a;
return n;
case 3:
n->opperation = 3;
a.string = string;
a.opperation = 3;
a.value = value;
n->printExpression = a;
return n;
default:
printf("{ERROR} PRINT STATEMENT ERROR IN YACC\n");
}
}