reader.h 688 B

1234567891011121314151617181920212223242526272829303132333435
  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. Cell* read_string_cell(Cell* in);
  28. #endif