reader.h 654 B

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef READER_H
  2. #define READER_H
  3. #include "minilisp.h"
  4. #define PST_ATOM 0
  5. #define PST_NUM 2
  6. #define PST_SYM 3
  7. #define PST_STR 4
  8. #define PST_BIGNUM 5
  9. #define PST_NUM_NEG 6
  10. #define PST_BYTES 7
  11. #define PST_COMMENT 9
  12. #define PST_ERR_UNEXP_CLOSING_BRACE 10
  13. #define PST_ERR_UNEXP_JUNK_IN_NUMBER 11
  14. #define PST_ERR_UNEXP_JUNK_IN_BYTES 12
  15. #define VST_DEFAULT 0
  16. #define VST_HEX 1
  17. typedef struct ReaderState {
  18. unsigned int state;
  19. Cell* cell;
  20. unsigned int sym_len;
  21. unsigned int valuestate; // i.e. dec/hex/char
  22. Cell** stack;
  23. unsigned int level;
  24. } ReaderState;
  25. ReaderState* read_char(char c, ReaderState* rs);
  26. Cell* read_string(char* in);
  27. #endif