]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/groff/troff/token.h
This commit was generated by cvs2svn to compensate for changes in r53910,
[FreeBSD/FreeBSD.git] / contrib / groff / troff / token.h
1 // -*- C++ -*-
2 /* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
3      Written by James Clark (jjc@jclark.com)
4
5 This file is part of groff.
6
7 groff 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.
11
12 groff 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.
16
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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20
21
22 struct charinfo;
23 struct node;
24 struct vunits;
25
26 class token {
27   symbol nm;
28   node *nd;
29   unsigned char c;
30   int val;
31   units dim;
32   enum token_type {
33     TOKEN_BACKSPACE,
34     TOKEN_BEGIN_TRAP,
35     TOKEN_CHAR,                 // a normal printing character
36     TOKEN_DUMMY,
37     TOKEN_EMPTY,                // this is the initial value
38     TOKEN_END_TRAP,
39     TOKEN_ESCAPE,               // \e
40     TOKEN_HYPHEN_INDICATOR,
41     TOKEN_INTERRUPT,            // \c
42     TOKEN_ITALIC_CORRECTION,    // \/
43     TOKEN_LEADER,               // ^A
44     TOKEN_LEFT_BRACE,
45     TOKEN_MARK_INPUT,           // \k -- `nm' is the name of the register
46     TOKEN_NEWLINE,              // newline
47     TOKEN_NODE,
48     TOKEN_NUMBERED_CHAR,
49     TOKEN_PAGE_EJECTOR,
50     TOKEN_REQUEST,
51     TOKEN_RIGHT_BRACE,
52     TOKEN_SPACE,                // ` ' -- ordinary space
53     TOKEN_SPECIAL,              // a special character -- \' \` \- \(xx
54     TOKEN_SPREAD,               // \p -- break and spread output line 
55     TOKEN_TAB,                  // tab
56     TOKEN_TRANSPARENT,          // \!
57     TOKEN_EOF                   // end of file
58     } type;
59 public:
60   token();
61   ~token();
62   token(const token &);
63   void operator=(const token &);
64   void next();
65   void process();
66   void skip();
67   int eof();
68   int nspaces();                // 1 if space, 2 if double space, 0 otherwise
69   int space();                  // is it a space or double space?
70   int white_space();            // is the current token space or tab?
71   int newline();                // is the current token a newline?
72   int tab();                    // is the current token a tab?
73   int leader();
74   int backspace();
75   int delimiter(int warn = 0);  // is it suitable for use as a delimiter?
76   int dummy();
77   int transparent();
78   int left_brace();
79   int right_brace();
80   int page_ejector();
81   int hyphen_indicator();
82   int operator==(const token &); // need this for delimiters, and for conditions
83   int operator!=(const token &); // ditto
84   unsigned char ch();
85   charinfo *get_char(int required = 0);
86   int add_to_node_list(node **);
87   int title();
88   void make_space();
89   void make_newline();
90   const char *description();
91
92   friend void process_input_stack();
93 };
94
95 extern token tok;               // the current token
96
97 extern symbol get_name(int required = 0);
98 extern symbol get_long_name(int required = 0);
99 extern charinfo *get_optional_char();
100 extern void check_missing_character();
101 extern void skip_line();
102 extern void handle_initial_title();
103
104 struct hunits;
105 extern void read_title_parts(node **part, hunits *part_width);
106
107 extern int get_number(units *result, unsigned char si);
108 extern int get_integer(int *result);
109
110 extern int get_number(units *result, unsigned char si, units prev_value);
111 extern int get_integer(int *result, int prev_value);
112
113 void interpolate_number_reg(symbol, int);
114
115 const char *asciify(int c);
116
117 inline int token::newline()
118
119   return type == TOKEN_NEWLINE; 
120 }
121
122 inline int token::space()
123
124   return type == TOKEN_SPACE;
125 }
126
127 inline int token::nspaces()
128 {
129   if (type == TOKEN_SPACE)
130     return 1;
131   else
132     return 0;
133 }
134
135 inline int token::white_space()
136 {
137   return type == TOKEN_SPACE || type == TOKEN_TAB;
138 }
139
140 inline int token::transparent()
141 {
142   return type == TOKEN_TRANSPARENT;
143 }
144
145 inline int token::page_ejector()
146 {
147   return type == TOKEN_PAGE_EJECTOR;
148 }
149
150 inline unsigned char token::ch()
151 {
152   return type == TOKEN_CHAR ? c : 0;
153
154
155 inline int token::eof()
156 {
157   return type == TOKEN_EOF;
158 }
159
160 inline int token::dummy()
161 {
162   return type == TOKEN_DUMMY;
163 }
164
165 inline int token::left_brace()
166 {
167   return type == TOKEN_LEFT_BRACE;
168 }
169
170 inline int token::right_brace()
171 {
172   return type == TOKEN_RIGHT_BRACE;
173 }
174
175 inline int token::tab()
176 {
177   return type == TOKEN_TAB;
178 }
179
180 inline int token::leader()
181 {
182   return type == TOKEN_LEADER;
183 }
184
185 inline int token::backspace()
186 {
187   return type == TOKEN_BACKSPACE;
188 }
189
190 inline int token::hyphen_indicator()
191 {
192   return type == TOKEN_HYPHEN_INDICATOR;
193 }
194
195 int has_arg();