175584Sru// -*- C++ -*-
275584Sru/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
375584Sru     Written by James Clark (jjc@jclark.com)
475584Sru
575584SruThis file is part of groff.
675584Sru
775584Srugroff is free software; you can redistribute it and/or modify it under
875584Sruthe terms of the GNU General Public License as published by the Free
975584SruSoftware Foundation; either version 2, or (at your option) any later
1075584Sruversion.
1175584Sru
1275584Srugroff is distributed in the hope that it will be useful, but WITHOUT ANY
1375584SruWARRANTY; without even the implied warranty of MERCHANTABILITY or
1475584SruFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1575584Srufor more details.
1675584Sru
1775584SruYou should have received a copy of the GNU General Public License along
1875584Sruwith groff; see the file COPYING.  If not, write to the Free Software
19151497SruFoundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
2075584Sru
2175584Sruenum token_type {
2275584Sru  TOKEN_OTHER,
2375584Sru  TOKEN_UPPER,
2475584Sru  TOKEN_LOWER,
2575584Sru  TOKEN_ACCENT,
2675584Sru  TOKEN_PUNCT,
2775584Sru  TOKEN_HYPHEN,
2875584Sru  TOKEN_RANGE_SEP
2975584Sru};
3075584Sru
3175584Sruclass token_info {
3275584Sruprivate:
3375584Sru  token_type type;
3475584Sru  const char *sort_key;
3575584Sru  const char *other_case;
3675584Srupublic:
3775584Sru  token_info();
3875584Sru  void set(token_type, const char *sk = 0, const char *oc = 0);
3975584Sru  void lower_case(const char *start, const char *end, string &result) const;
4075584Sru  void upper_case(const char *start, const char *end, string &result) const;
4175584Sru  void sortify(const char *start, const char *end, string &result) const;
4275584Sru  int sortify_non_empty(const char *start, const char *end) const;
4375584Sru  int is_upper() const;
4475584Sru  int is_lower() const;
4575584Sru  int is_accent() const;
4675584Sru  int is_other() const;
4775584Sru  int is_punct() const;
4875584Sru  int is_hyphen() const;
4975584Sru  int is_range_sep() const;
5075584Sru};
5175584Sru
5275584Sruinline int token_info::is_upper() const
5375584Sru{
5475584Sru  return type == TOKEN_UPPER;
5575584Sru}
5675584Sru
5775584Sruinline int token_info::is_lower() const
5875584Sru{
5975584Sru  return type == TOKEN_LOWER;
6075584Sru}
6175584Sru
6275584Sruinline int token_info::is_accent() const
6375584Sru{
6475584Sru  return type == TOKEN_ACCENT;
6575584Sru}
6675584Sru
6775584Sruinline int token_info::is_other() const
6875584Sru{
6975584Sru  return type == TOKEN_OTHER;
7075584Sru}
7175584Sru
7275584Sruinline int token_info::is_punct() const
7375584Sru{
7475584Sru  return type == TOKEN_PUNCT;
7575584Sru}
7675584Sru
7775584Sruinline int token_info::is_hyphen() const
7875584Sru{
7975584Sru  return type == TOKEN_HYPHEN;
8075584Sru}
8175584Sru
8275584Sruinline int token_info::is_range_sep() const
8375584Sru{
8475584Sru  return type == TOKEN_RANGE_SEP;
8575584Sru}
8675584Sru
8775584Sruint get_token(const char **ptr, const char *end);
8875584Sruconst token_info *lookup_token(const char *start, const char *end);
89