Skip to content

Instantly share code, notes, and snippets.

#include <string.h>
#define TOTAL 50
int yyerror(char const *s);
typedef struct tnode{
int flag; //indicate whether the node is a leaf(0: number; 1: variable) or internal node(2: operator)
// char *varname; //name of the variable
// int val; //value of the expression tree
struct variable *var;
typedef struct tnode{
int flag; //indicate whether the node is a leaf(0: number; 1: variable) or internal node(2: operator)
char *varname; //name of the variable
int val; //value of the expression tree
char *op; //operator branch
struct tnode *left, *right; //left and right node
}tnode;