Example #1
0
int main (int argc, char **argv) {
   if (argc != 1) {
      fprintf (stderr, "Usage: %s\n", basename (argv[0]));
      fflush (NULL);
      exit (EXIT_FAILURE);
   }
   stack the_stack;
   the_stack.top = EMPTY;
   char buffer[1024];
   for (;;) {
      int scanrc = scanf ("%1023s", buffer);
      if (scanrc == EOF) break;
      assert (scanrc == 1);
      if (buffer[0] == '#') {
         scanrc = scanf ("%1023[^\n]", buffer);
         continue;
      }
      char *endptr;
      double number = strtod (buffer, &endptr);
      if (*endptr == '\0') {
         push (&the_stack, number);
      }else if (buffer[1] != '\0') {
         bad_operator (buffer);
      }else {
         do_operator (&the_stack, buffer);
      }
   }
   return exit_status;
}
static int class_le_event (lua_State* L)
{
	return do_operator(L,".le");
}
static int class_div_event (lua_State* L)
{
	return do_operator(L,".div");
}
static int class_mul_event (lua_State* L)
{
	return do_operator(L,".mul");
}
static int class_sub_event (lua_State* L)
{
	return do_operator(L,".sub");
}
static int class_add_event (lua_State* L)
{
	return do_operator(L,".add");
}
Example #7
0
static int class_eq_event (lua_State* L)
{
	return do_operator(L,".eq");
}