mes.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* -*-comment-start: "//";comment-end:""-*-
  2. * GNU Mes --- Maxwell Equations of Software
  3. * Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  4. * Copyright © 2019 Jeremiah Orians
  5. *
  6. * This file is part of GNU Mes.
  7. *
  8. * GNU Mes is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or (at
  11. * your option) any later version.
  12. *
  13. * GNU Mes is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #include "gcc_req.h"
  22. //CONSTANT FREE 0
  23. #define FREE 0
  24. //CONSTANT MARKED 1
  25. #define MARKED 1
  26. //CONSTANT INT 2
  27. #define INT 2
  28. //CONSTANT SYM 4
  29. #define SYM 4
  30. //CONSTANT CONS 6
  31. #define CONS 6
  32. //CONSTANT LAMBDA 8
  33. #define LAMBDA 8
  34. //CONSTANT PRIMOP 10
  35. #define PRIMOP 10
  36. //CONSTANT CHAR 12
  37. #define CHAR 12
  38. //CONSTANT STRING 14
  39. #define STRING 14
  40. //CONSTANT VECTOR 16
  41. #define VECTOR 16
  42. //CONSTANT FILE_PORT 18
  43. #define FILE_PORT 18
  44. //CONSTANT RECORD 20
  45. #define RECORD 20
  46. //CONSTANT RECORD_TYPE 22
  47. #define RECORD_TYPE 22
  48. //CONSTANT MACRO 1000
  49. #define MACRO 1000
  50. //CONSTANT EOF_object 1024
  51. #define EOF_object 1024
  52. // CONSTANT FALSE 0
  53. #define FALSE 0
  54. // CONSTANT TRUE 1
  55. #define TRUE 1
  56. struct cell
  57. {
  58. int type;
  59. union
  60. {
  61. struct cell* car;
  62. int value;
  63. char* string;
  64. FUNCTION* function;
  65. };
  66. struct cell* cdr;
  67. union
  68. {
  69. struct cell* env;
  70. FILE* file;
  71. };
  72. };
  73. /* Common functions */
  74. struct cell* make_cons(struct cell* a, struct cell* b);
  75. int numerate_string(char *a);
  76. char* numerate_number(int a);
  77. int match(char* a, char* b);
  78. void file_print(char* s, FILE* f);
  79. void require(int bool, char* error);
  80. /* Global objects */
  81. struct cell* all_symbols;
  82. struct cell* top_env;
  83. struct cell* nil;
  84. struct cell* cell_unspecified;
  85. struct cell* cell_t;
  86. struct cell* cell_f;
  87. struct cell* cell_dot;
  88. struct cell* quote;
  89. struct cell* quasiquote;
  90. struct cell* unquote;
  91. struct cell* unquote_splicing;
  92. struct cell* s_if;
  93. struct cell* s_lambda;
  94. struct cell* s_define;
  95. struct cell* s_setb;
  96. struct cell* s_cond;
  97. struct cell* s_begin;
  98. struct cell* s_let;
  99. struct cell* s_while;
  100. struct cell* s_macro;
  101. struct cell* s_define_macro;
  102. /* IO */
  103. struct cell* __stdin;
  104. struct cell* __stdout;
  105. struct cell* __stderr;
  106. /* Garbage Collection */
  107. int left_to_take;
  108. char* memory_block;
  109. /* Lisp Macine */
  110. struct cell** g_stack;
  111. struct cell* R0;
  112. struct cell* R1;
  113. struct cell* g_env;
  114. struct cell* primitive_env;
  115. unsigned stack_pointer;
  116. char** __envp;
  117. char** __argv;
  118. int __argc;