lisp.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* Copyright (C) 2016 Jeremiah Orians
  2. * This file is part of stage0.
  3. *
  4. * stage0 is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * stage0 is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with stage0. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include "gcc_req.h"
  18. //CONSTANT FREE 1
  19. #define FREE 1
  20. //CONSTANT MARKED 2
  21. #define MARKED 2
  22. //CONSTANT INT 4
  23. #define INT 4
  24. //CONSTANT SYM 8
  25. #define SYM 8
  26. //CONSTANT CONS 16
  27. #define CONS 16
  28. //CONSTANT PROC 32
  29. #define PROC 32
  30. //CONSTANT PRIMOP 64
  31. #define PRIMOP 64
  32. //CONSTANT CHAR 128
  33. #define CHAR 128
  34. //CONSTANT STRING 256
  35. #define STRING 256
  36. // CONSTANT FALSE 0
  37. #define FALSE 0
  38. // CONSTANT TRUE 1
  39. #define TRUE 1
  40. struct cell
  41. {
  42. int type;
  43. union
  44. {
  45. struct cell* car;
  46. int value;
  47. char* string;
  48. FUNCTION* function;
  49. };
  50. struct cell* cdr;
  51. struct cell* env;
  52. };
  53. // CONSTANT MAX_STRING 4096
  54. #define MAX_STRING 4096
  55. /* Common functions */
  56. struct cell* make_cons(struct cell* a, struct cell* b);
  57. int strtoint(char *a);
  58. char* int2str(int x, int base, int signed_p);
  59. int match(char* a, char* b);
  60. /* Global objects */
  61. struct cell *all_symbols;
  62. struct cell *top_env;
  63. struct cell *nil;
  64. struct cell *tee;
  65. struct cell *quote;
  66. struct cell *s_if;
  67. struct cell *s_lambda;
  68. struct cell *s_define;
  69. struct cell *s_setb;
  70. struct cell *s_cond;
  71. struct cell *s_begin;
  72. struct cell *s_let;
  73. struct cell *s_while;
  74. struct cell *current;
  75. FILE* input;
  76. FILE* file_output;
  77. FILE* console_output;
  78. int echo;
  79. int left_to_take;