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

69 lines
1.5 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 *pVarName) {
node_info *newNode = malloc(sizeof(node_info));
newNode->opperation = 6;
newNode->name = pVarName;
return newNode;
}
/**
*
* @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;//this needs to not be a magic number lol
a.value = value;
a.opperation = 1;
n->printExpression = a;
return n;
break;
//else we are printing a string
case 2:
n->opperation = 3;
a.string = string;
a.opperation = 2;
n->printExpression = a;
return n;
break;
case 3:
n->opperation = 3;
a.string = string;
a.opperation = 3;
a.value = value;
n->printExpression = a;
return n;
break;
default:
printf("{ERROR} PRINT STATEMENT ERROR IN YACC\n");
}
}