A03/match_braces.c
// Push a new node to a stack (implemented as a linked list). 
// The new node should store the given symbol, line number, and column number
// Param sym: a character symbol, '{' for this program
// Param line: the line number of the symbol
// Param line: the column number of the symbol
// Param top: the top node of the stack (NULL if empty)
// Returns the new top of the stack
Push a new node to a stack (implemented as a linked list).
The new node should store the given symbol, line number, and column number
Param sym: a character symbol, '{' for this program
Param line: the line number of the symbol
Param line: the column number of the symbol
Param top: the top node of the stack (NULL if empty)
Returns the new top of the stack
Push a new node to a stack ( implemented as a linked list ) . The new node should store the given symbol line number and column number Param sym : a character symbol ' { ' for this program Param line : the line number of the symbol Param line : the column number of the symbol Param top : the top node of the stack ( NULL if empty ) Returns the new top of the stack
struct node* push(char sym, int line, int col, struct node* top) {
	struct node* new_top = (struct node *) malloc(sizeof(struct node));
	if (new_top == NULL) {
		printf("Error with malloc");
		return NULL;
	}
	if (top == NULL) {
		new_top->sym = sym;
		new_top->linenum = line;
		new_top->colnum = col;
		new_top->next = NULL;
		return new_top;
	}
	new_top->sym = sym;
	new_top->linenum = line;
	new_top->colnum = col;
	new_top->next = top;
	return new_top;
}
struct node * push ( char sym , int line , int col , struct node * top ) { struct node * new_top = ( struct node * ) malloc ( sizeof ( struct node ) ) ; if ( new_top == NULL ) { printf ( " " ) ; return NULL ; } if ( top == NULL ) { new_top -> sym = sym ; new_top -> linenum = line ; new_top -> colnum = col ; new_top -> next = NULL ; return new_top ; } new_top -> sym = sym ; new_top -> linenum = line ; new_top -> colnum = col ; new_top -> next = top ; return new_top ; }
Push a new node to a stack (implemented as a linked list).
Push a new node to a stack ( implemented as a linked list ) .
//struct node* placer = top; //while (placer->next != NULL)  { //	placer = placer->next; //} //if(top != NULL) { //	placer->next = new_top;	 //}