symtable.h 733 B

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef _SYMTABLE_H_
  2. #define _SYMTABLE_H_
  3. /* entry in the symbol table and its data
  4. */
  5. struct entry {
  6. char *lexptr;
  7. int token;
  8. int value;
  9. };
  10. // init
  11. int symtable_init();
  12. // lookup and insert functions
  13. int symtable_lookup(char s[]);
  14. int symtable_insert(char s[], int tok);
  15. /* scope functions
  16. * push: create a new (empty) symtable as a child of the current one
  17. * pop : remove current symtable (including clean) and assign parent as the current one
  18. */
  19. void symtable_push();
  20. void symtable_pop ();
  21. // responsible for cleaning memory
  22. void symtable_clean();
  23. // mostly for debugging, just print the table
  24. void symtable_print();
  25. // from an index to the symtable, get the entry
  26. struct entry *symtable_entryat(int index);
  27. #endif