Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. #define MZ_PRECISE_GC
  2.  
  3. #include "scheme.h"
  4. #include "base.c"
  5.  
  6. #include <stdio.h>
  7. #include <readline/readline.h>
  8. #include <readline/history.h>
  9.  
  10. static int run(Scheme_Env *e, int argc, char *argv[])
  11. {
  12. mz_jmp_buf * volatile save = NULL, fresh;
  13. Scheme_Config *config = NULL;
  14. Scheme_Object * f, *r, * curout, *a[2] = {NULL, NULL}, *v;
  15. Scheme_Thread * volatile sct = scheme_get_current_thread();
  16.  
  17. MZ_GC_DECL_REG(6);
  18. MZ_GC_VAR_IN_REG(0, curout);
  19. MZ_GC_VAR_IN_REG(1, save);
  20. MZ_GC_VAR_IN_REG(2, config);
  21. MZ_GC_VAR_IN_REG(3, r);
  22. MZ_GC_VAR_IN_REG(4, v);
  23. MZ_GC_VAR_IN_REG(5, e);
  24.  
  25. MZ_GC_REG();
  26.  
  27. declare_modules(e);
  28. v = scheme_intern_symbol("racket/base");
  29. scheme_namespace_require(v);
  30.  
  31. save = sct->error_buf;
  32. sct->error_buf = &fresh;
  33.  
  34. if (scheme_setjmp(fresh)) {
  35. printf("Error\n");
  36. } else {
  37. config = scheme_current_config();
  38. curout = scheme_get_param(config, MZCONFIG_OUTPUT_PORT);
  39. r = scheme_eval_string_all(readline("=> "), e, 1);
  40. if(!SCHEME_VOIDP(r))
  41. scheme_display(r, curout);
  42. scheme_display(scheme_make_char('\n'), curout);
  43. }
  44. sct->error_buf = save;
  45. MZ_GC_UNREG();
  46.  
  47. return 0;
  48. }
  49.  
  50. int main(int argc, char *argv[])
  51. {
  52. return scheme_main_setup(1, run, argc, argv);
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement