class.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. /* U S E O F C H A R A C T E R C L A S S E S */
  2. /* As a starter, chars are divided into classes, according to which
  3. token they can be the start of.
  4. At present such a class number is supposed to fit in 4 bits.
  5. */
  6. #define class(ch) (tkclass[ch])
  7. /* Being the start of a token is, fortunately, a mutual exclusive
  8. property, so, as there are less than 16 classes they can be
  9. packed in 4 bits.
  10. */
  11. #define STSKIP 0 /* spaces and so on: skipped characters */
  12. #define STNL 1 /* newline character(s): update linenumber etc. */
  13. #define STGARB 2 /* garbage ascii character: not allowed */
  14. #define STSIMP 3 /* this character can occur as token */
  15. #define STCOMP 4 /* this one can start a compound token */
  16. #define STIDF 5 /* being the initial character of an identifier */
  17. #define STCHAR 6 /* the starter of a character constant */
  18. #define STSTR 7 /* the starter of a string */
  19. #define STNUM 8 /* the starter of a numeric constant */
  20. #define STEOI 9 /* End-Of-Information mark */
  21. /* But occurring inside a token is not, so we need 1 bit for each
  22. class. This is implemented as a collection of tables to speed up
  23. the decision whether a character has a special meaning.
  24. */
  25. #define in_idf(ch) ((unsigned)ch < 0177 && inidf[ch])
  26. #define is_dig(ch) ((unsigned)ch < 0177 && isdig[ch])
  27. extern char tkclass[];
  28. extern char inidf[], isdig[];