1 /*
2 Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
7 met:
8 
9     - Redistributions of source code must retain the above copyright
10       notice, this list of conditions and the following disclaimer.
11 
12     - Redistributions in binary form must reproduce the above copyright
13       notice, this list of conditions and the following disclaimer in
14       the documentation and/or other materials provided with the
15       distribution.
16 
17     - Neither the name of The Numerical ALgorithms Group Ltd. nor the
18       names of its contributors may be used to endorse or promote products
19       derived from this software without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
22 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
25 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33 
34 #ifndef _TOKEN_H_
35 #define _TOKEN_H_ 1
36 
37 /*
38  Here are a couple of flags added for whitespace stuff. They tell
39       punctuation if there was space in front of it or not
40 */
41 
42 #define FRONTSPACE 0001
43 #define BACKSPACE  0002
44 
45 /* HyperDoc parser tokens */
46 
47 typedef struct toke {
48   int type;             /* token type.  One of those listed below */
49   char *id;             /* string value if type == Identifier */
50 } Token;
51 
52 /*
53     User tokens. ie, these can be found on a page
54 */
55 
56 #define Word                  1
57 #define Page                  2
58 #define Lispcommandquit       3
59 #define BoldFace              4
60 #define Link                  5
61 #define Downlink              6
62 #define Beginscroll           7
63 #define Spadcommand           8
64 #define NoLines               9
65 #define Env                  10
66 #define Par                  11
67 #define Center               12
68 #define Begin                13
69 #define Beginitems           14
70 #define Item                 15
71 #define Table                16
72 #define Box                  17
73 #define Tab                  18
74 #define Space                19
75 #define Indent               20
76 #define Horizontalline       21
77 #define Newline              22
78 #define Enditems             23
79 #define Returnbutton         24
80 #define Memolink             25
81 #define Upbutton             26
82 #define Endscroll            27
83 #define Thispage             28
84 #define Returnto             29
85 #define Free                 30
86 #define Bound                31
87 #define Lisplink             32
88 #define Unixlink             33
89 #define Mbox                 34
90 #define Inputstring          35
91 #define StringValue          36
92 #define Spadlink             37
93 #define Inputbitmap          38
94 #define Inputpixmap          39
95 #define Unixcommand          40
96 #define Emphasize            41
97 #define Lispcommand          42
98 #define LispMemoLink         43
99 #define LispDownLink         44
100 #define Spadcall             45
101 #define Spadcallquit         46
102 #define Spaddownlink         47
103 #define Spadmemolink         48
104 #define Qspadcall            49
105 #define Qspadcallquit        50
106 #define SimpleBox            51
107 #define Radioboxes           52
108 #define BoxValue             53
109 #define VSpace               54
110 #define HSpace               55
111 #define NewCommand           56
112 #define WindowId             57
113 #define Beep                 58
114 #define Quitbutton           59
115 #define Begintitems          60
116 #define Titem                61
117 #define End                  62
118 #define It                   63
119 #define Sl                   64
120 #define Tt                   65
121 #define Rm                   66
122 #define Ifcond               67
123 #define Else                 68
124 #define Fi                   69
125 #define Newcond              70
126 #define Setcond              71
127 #define Button               72
128 #define Windowlink           73
129 #define Haslisp              74
130 #define Hasup                75
131 #define Hasreturn            76
132 #define Hasreturnto          77
133 #define Lastwindow           78
134 #define Endtitems            79
135 #define Lispwindowlink       80
136 #define Beginpile            81
137 #define Endpile              82
138 #define Nextline             83
139 #define Pastebutton          84
140 #define Color                85
141 #define Helppage             86
142 #define Patch                87
143 #define Radiobox             88
144 #define ifrecond             89
145 #define Math                 90
146 #define Mitem                91
147 #define Pagename             92
148 #define Examplenumber        93
149 #define Replacepage          94
150 #define Inputimage           95
151 #define Spadgraph            96
152 #define Indentrel            97
153 #define Controlbitmap        98
154 
155 #define NumberUserTokens     98
156 
157 
158 extern char *token_table[];
159 
160 #ifdef PARSER
161 char *token_table[] = {
162   "",           /* Dummy token name */
163   "word",
164   "page",
165   "lispcommandquit",
166   "bf",
167   "link",
168   "downlink",
169   "beginscroll",
170   "spadcommand",
171   "nolines",
172   "env",
173   "par",
174   "centerline",
175   "begin",
176   "beginitems",
177   "item",
178   "table",
179   "fbox",
180   "tab",
181   "space",
182   "indent",
183   "horizontalline",
184   "newline",
185   "enditems",
186   "returnbutton",
187   "memolink",
188   "upbutton",
189   "endscroll",
190   "thispage",
191   "returnto",
192   "free",
193   "bound",
194   "lisplink",
195   "unixlink",
196   "mbox",
197   "inputstring",
198   "stringvalue",
199   "spadlink",
200   "inputbitmap",
201   "inputpixmap",
202   "unixcommand",
203   "em",
204   "lispcommand",
205   "lispmemolink",
206   "lispdownlink",
207   "spadcall",
208   "spadcallquit",
209   "spaddownlink",
210   "spadmemolink",
211   "qspadcall",
212   "qspadcallquit",
213   "inputbox",
214   "radioboxes",
215   "boxvalue",
216   "vspace",
217   "hspace",
218   "newcommand",
219   "windowid",
220   "beep",
221   "quitbutton",
222   "begintitems",
223   "titem",
224   "end",
225   "it",
226   "sl",
227   "tt",
228   "rm",
229   "ifcond",
230   "else",
231   "fi",
232   "newcond",
233   "setcond" ,
234   "button",
235   "windowlink",
236   "haslisp",
237   "hasup",
238   "hasreturn",
239   "hasreturnto",
240   "lastwindow",
241   "endtitems",
242   "lispwindowlink",
243   "beginpile",
244   "endpile",
245   "nextline",
246   "pastebutton",
247   "color",
248   "helppage",
249   "patch",
250   "radiobox",
251   "ifrecond",
252   "math",
253   "mitem",
254   "pagename",
255   "examplenumber",
256   "replacepage",
257   "inputimage",
258   "spadgraph",
259   "indentrel",
260   "controlbitmap"
261   };
262 #endif
263 
264 
265 /* places from which input may be read */
266 #define FromFile        1
267 #define FromString      2
268 #define FromSpadSocket  3
269 #define FromUnixFD      4
270 
271 extern FILE *unixfd;
272 
273 /*
274  * Here are the system tokens. These are used internally to help
275  * with parsing and displaying of text
276  */
277 
278 #define SystemTokens   1001
279 #define Lbrace         1001
280 #define Rbrace         1002
281 #define Macro          1003
282 #define Group          1004
283 #define Scrollbar      1005
284 #define Pound          1006
285 #define Lsquarebrace   1007
286 #define Rsquarebrace   1008
287 #define Punctuation    1009
288 #define Dash           1010
289 #define Tableitem      1011
290 #define Scrollingnode  1012
291 #define Headernode     1013
292 #define Footernode     1014
293 #define Verbatim       1015
294 #define Scroll         1016
295 #define Dollar         1017
296 #define Percent        1018
297 #define Carrot         1019
298 #define Underscore     1020
299 #define Tilde          1021
300 #define Cond           1022
301 #define Noop           1023
302 #define Description    1024
303 #define Icorrection    1025
304 #define Boxcond        1026
305 #define Unkeyword      1027
306 #define Titlenode      1028
307 #define Paste          1029
308 #define Spadsrc        1030
309 #define Helpbutton     1031
310 #define Spadsrctxt     1032
311 
312 
313 /*
314  * Here are the tokens used to mark the end to some sort of group of
315  * tokens. ie, the tokens found in a centerline command
316  */
317 
318 #define Endtokens      2000
319 #define End1           2001
320 #define End2           2002
321 #define Endbutton      2003
322 #define Endlink        2004
323 #define Endheader      2005
324 #define Endfooter      2006
325 #define Endscrolling   2007
326 #define Endgroup       2008
327 #define Endarg         2009
328 #define Endbox         2010
329 #define Endmbox        2011
330 #define Endspadcommand 2012
331 #define Endpix         2013
332 #define Endmacro       2014
333 #define Endparameter   2015
334 #define Endtable       2016
335 #define Endtableitem   2017
336 #define End3           2018
337 #define Endif          2019
338 #define Enddescription 2020
339 #define Endinputbox    2021
340 #define Endtitle       2022
341 #define Endpastebutton 2023
342 
343 #define Endtypes       3000
344 #define Endpage        3002
345 #define EndScroll      3007        /* had to use a S because Endscroll is
346                                        already a keyword      */
347 
348 #define Endcenter      3012
349 #define EndItems       3014        /* Same thing here as EndScroll except
350                                           with the i          */
351 #define EndTitems      3060        /* Ibid for the T          */
352 #define Endpatch       3087
353 #define Endverbatim    4015
354 #define Endmath        4016
355 #define Endpaste       4029
356 #define Endspadsrc     4030
357 
358 #endif
359