Copyright 2017
[s-roff.git] / src / pre-refer / token.h
blobdddcd733fce3a09bfed977b2b3147eb308ff8e79
1 /*@
2 * Copyright (c) 2014 - 2017 Steffen (Daode) Nurpmeso <steffen@sdaoden.eu>.
4 * Copyright (C) 1989 - 1992 Free Software Foundation, Inc.
5 * Written by James Clark (jjc@jclark.com)
7 * This is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 2, or (at your option) any later
10 * version.
12 * This is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with groff; see the file COPYING. If not, write to the Free Software
19 * Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef _TOKEN_H
22 #define _TOKEN_H
24 #include "config.h"
25 #include "refer-config.h"
27 enum token_type {
28 TOKEN_OTHER,
29 TOKEN_UPPER,
30 TOKEN_LOWER,
31 TOKEN_ACCENT,
32 TOKEN_PUNCT,
33 TOKEN_HYPHEN,
34 TOKEN_RANGE_SEP
37 class token_info
39 token_type type;
40 const char *sort_key;
41 const char *other_case;
43 public:
44 token_info();
45 void set(token_type, const char *sk = 0, const char *oc = 0);
46 void lower_case(const char *start, const char *end, string &result) const;
47 void upper_case(const char *start, const char *end, string &result) const;
48 void sortify(const char *start, const char *end, string &result) const;
49 int sortify_non_empty(const char *start, const char *end) const;
50 int is_upper() const;
51 int is_lower() const;
52 int is_accent() const;
53 int is_other() const;
54 int is_punct() const;
55 int is_hyphen() const;
56 int is_range_sep() const;
59 inline int token_info::is_upper() const
61 return type == TOKEN_UPPER;
64 inline int token_info::is_lower() const
66 return type == TOKEN_LOWER;
69 inline int token_info::is_accent() const
71 return type == TOKEN_ACCENT;
74 inline int token_info::is_other() const
76 return type == TOKEN_OTHER;
79 inline int token_info::is_punct() const
81 return type == TOKEN_PUNCT;
84 inline int token_info::is_hyphen() const
86 return type == TOKEN_HYPHEN;
89 inline int token_info::is_range_sep() const
91 return type == TOKEN_RANGE_SEP;
94 int get_token(const char **ptr, const char *end);
95 const token_info *lookup_token(const char *start, const char *end);
97 #endif // _TOKEN_H
98 // s-it2-mode