/contrib/groff/src/preproc/refer/token.h

https://bitbucket.org/freebsd/freebsd-head/ · C++ Header · 88 lines · 59 code · 10 blank · 19 comment · 7 complexity · 8dad61e19ab82275ff6e255aa7fcd9a7 MD5 · raw file

  1. // -*- C++ -*-
  2. /* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
  3. Written by James Clark (jjc@jclark.com)
  4. This file is part of groff.
  5. groff is free software; you can redistribute it and/or modify it under
  6. the terms of the GNU General Public License as published by the Free
  7. Software Foundation; either version 2, or (at your option) any later
  8. version.
  9. groff is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. for more details.
  13. You should have received a copy of the GNU General Public License along
  14. with groff; see the file COPYING. If not, write to the Free Software
  15. Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
  16. enum token_type {
  17. TOKEN_OTHER,
  18. TOKEN_UPPER,
  19. TOKEN_LOWER,
  20. TOKEN_ACCENT,
  21. TOKEN_PUNCT,
  22. TOKEN_HYPHEN,
  23. TOKEN_RANGE_SEP
  24. };
  25. class token_info {
  26. private:
  27. token_type type;
  28. const char *sort_key;
  29. const char *other_case;
  30. public:
  31. token_info();
  32. void set(token_type, const char *sk = 0, const char *oc = 0);
  33. void lower_case(const char *start, const char *end, string &result) const;
  34. void upper_case(const char *start, const char *end, string &result) const;
  35. void sortify(const char *start, const char *end, string &result) const;
  36. int sortify_non_empty(const char *start, const char *end) const;
  37. int is_upper() const;
  38. int is_lower() const;
  39. int is_accent() const;
  40. int is_other() const;
  41. int is_punct() const;
  42. int is_hyphen() const;
  43. int is_range_sep() const;
  44. };
  45. inline int token_info::is_upper() const
  46. {
  47. return type == TOKEN_UPPER;
  48. }
  49. inline int token_info::is_lower() const
  50. {
  51. return type == TOKEN_LOWER;
  52. }
  53. inline int token_info::is_accent() const
  54. {
  55. return type == TOKEN_ACCENT;
  56. }
  57. inline int token_info::is_other() const
  58. {
  59. return type == TOKEN_OTHER;
  60. }
  61. inline int token_info::is_punct() const
  62. {
  63. return type == TOKEN_PUNCT;
  64. }
  65. inline int token_info::is_hyphen() const
  66. {
  67. return type == TOKEN_HYPHEN;
  68. }
  69. inline int token_info::is_range_sep() const
  70. {
  71. return type == TOKEN_RANGE_SEP;
  72. }
  73. int get_token(const char **ptr, const char *end);
  74. const token_info *lookup_token(const char *start, const char *end);