Esempio n. 1
0
//////////////////////////////////////////////////
// program entry
int main()
{
  printf("Compile starting\n");
 
  // build an expression tree:
  //            +
  //           / \
  //          +   4
  //         / \
  //        2   3
  struct Exp_t *exp = Exp_Sum_new (Exp_Sum_new(Exp_Int_new (2)
                                   , Exp_Int_new (3))
                                   , Exp_Int_new (4));

  // print out this tree:
  printf ("the expression is:\n");
  Exp_print (exp);

  // compile this tree to Stack machine instructions
  compile (exp);

  // print out the generated Stack instructions:
  printf("\n\n");
  List_reverse_print (all);
  
  printf("\nCompile finished\n");
  return 0;
}
Esempio n. 2
0
void parser(){
//	while(operators->top != 0 && pop(operators))
	while(operators->tail != operators->head && dequeue(operators))
		exp = Exp_Sum_new((struct Exp_t *) exp,
			//Exp_Int_new(pop(numbers) - '0'));
			Exp_Int_new(dequeue(numbers) - '0'));
}