1 /*
2    Copyright (c) 2000 Petter Reinholdtsen
3 
4    Permission is hereby granted, free of charge, to any person
5    obtaining a copy of this software and associated documentation
6    files (the "Software"), to deal in the Software without
7    restriction, including without limitation the rights to use, copy,
8    modify, merge, publish, distribute, sublicense, and/or sell copies
9    of the Software, and to permit persons to whom the Software is
10    furnished to do so, subject to the following conditions:
11 
12    The above copyright notice and this permission notice shall be
13    included in all copies or substantial portions of the Software.
14 
15    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19    BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20    ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21    CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22    SOFTWARE.
23 */
24 /*======================================================================
25  * interp-priv.h - Internal header file for report generator interpreter
26  * Copyright(c) 2000 by Petter Reinholdtsen; all rights reserved
27  *====================================================================*/
28 
29 #ifndef _INTERP_PRIV_H
30 #define _INTERP_PRIV_H
31 
32 #include "pvalue.h"
33 #include "interp.h"
34 
35 #define LIFELINES_REPORTS_VERSION "1.3"
36 
37 /************************************************************************/
38 /* Parser Structures and Functions                                      */
39 /************************************************************************/
40 
41 /* parse global context */
42 struct tag_pactx {
43 	FILE *Pinfp;     /* file to read program from */
44 	STRING Pinstr;   /* string to read program from */
45 	TABLE filetab;   /* table of files called by current report (incl. itself) */
46 	                 /* a filetab entry holds optional table of string properties */
47 	STRING ifile;    /* user's requested program path (current report) */
48 	STRING fullpath; /* actual path of current program */
49 	INT lineno;      /* current line number (0-based) */
50 	INT charpos;     /* current offset on line (0-based) */
51 };
52 typedef struct tag_pactx *PACTX;
53 
54 typedef struct tag_pathinfo {
55 	STRING fname;    /* filename as user specified */
56 	STRING fullpath; /* fully qualified path */
57 } *PATHINFO;
58 
59 struct tag_rptinfo {
60 	struct tag_vtable *vtable; /* generic object */
61 	INT refcnt; /* ref-countable object */
62 	STRING fullpath; /* fully qualified path to file */
63 	ZSTR localpath;  /* directory file is in */
64 	ZSTR localepath; /* directory for message catalogs */
65 	ZSTR textdomain; /* domain for message catalog for this report */
66 	TABLE proctab;   /* all procs in this file */
67 	TABLE functab;   /* all funcs in this file */
68 	STRING codeset;  /* codeset of report */
69 };
70 typedef struct tag_rptinfo *RPTINFO;
71 
72 /************************************************************************/
73 /* Symbol Table Structures and Prototypes                               */
74 /************************************************************************/
75 
76 
77 /* symbol table data is just table data */
78 typedef struct tag_symtab *SYMTAB;
79 struct tag_symtab {
80 	TABLE tab;
81 	SYMTAB parent;
82 	char title[128];
83 };
84 
85 SYMTAB create_symtab_global(void);
86 SYMTAB create_symtab_proc(CNSTRING procname, SYMTAB parstab);
87 void delete_symtab_element(SYMTAB stab, STRING iden);
88 BOOLEAN in_symtab(SYMTAB stab, CNSTRING key);
89 void insert_symtab(SYMTAB stab, CNSTRING iden, PVALUE val);
90 void remove_symtab(SYMTAB stab);
91 void symbol_tables_end(void);
92 PVALUE symtab_valueofbool(SYMTAB stab, CNSTRING key, BOOLEAN *there);
93 
94 
95 /* symbol table iteration */
96 typedef struct tag_symtab_iter *SYMTAB_ITER;
97 SYMTAB_ITER begin_symtab_iter(SYMTAB stab);
98 BOOLEAN next_symtab_entry(SYMTAB_ITER tabit, CNSTRING *pkey, PVALUE *ppval);
99 void end_symtab_iter(SYMTAB_ITER * psymtabit);
100 
101 /************************************************************************/
102 /* Interpreter Structures and Functions                                 */
103 /************************************************************************/
104 
105 typedef struct tag_pnode *PNODE;
106 
107 typedef struct tag_ipcall_data {
108 	CNSTRING fname;
109 	PNODE fargs;
110 } IPCALL_DATA;
111 
112 struct tag_pnode {
113 	char     i_type;       /* type of node */
114 	PNODE    i_prnt;       /* parent of this node */
115 	INT      i_line;       /* line where text of this node begins */
116 	RPTINFO  i_rptinfo;    /* information about this report file */
117 	INT      i_flags;
118 	PNODE    i_next;       /* next node */
119 	VPTR     i_word1;      /* variable data associated with node type */
120 	VPTR     i_word2;      /* ... */
121 	VPTR     i_word3;
122 	VPTR     i_word4;
123 	VPTR     i_word5;
124 	union {
125 		struct {
126 			PVALUE value;
127 		} iicons;
128 		struct {
129 			PVALUE value;
130 		} ifcons;
131 		struct {
132 			PVALUE value;
133 		} iscons;
134 		struct {
135 			CNSTRING name;
136 		} iident;
137 		struct {
138 			PNODE icond;
139 			PNODE ithen;
140 			PNODE ielse;
141 		} iif;
142 		struct {
143 			PNODE icond;
144 			PNODE ibody;
145 		} iwhile;
146 		struct {
147 			CNSTRING fname;
148 			PNODE fargs;
149 			PNODE func;
150 		} ifcall;
151 		struct {
152 			CNSTRING fname;
153 			PNODE fargs;
154 		} ipcall;
155 	} vars;
156 };
157 
158 /* pnode types */
159 #define IICONS       1   /* integer constant */
160 #define IFCONS       2   /* floating constant */
161 #define ISCONS       4   /* string constant */
162 #define IIDENT       5   /* identifier */
163 #define IIF          6   /* if statement */
164 #define IWHILE       7   /* while loop */
165 #define IBREAK       8   /* break statement */
166 #define ICONTINUE    9   /* continue statement */
167 #define IRETURN     10   /* return statement */
168 #define IPDEFN      11   /* user-defined procedure defn */
169 #define IPCALL      12   /* user-defined procudure call */
170 #define IFDEFN      13   /* user-defined function defn */
171 #define IFCALL      14   /* user-defined function call */
172 #define IBCALL      15   /* built-in function call */
173 #define ITRAV       16   /* traverse loop */
174 #define INODES      17   /* fornodes loop */
175 #define IFAMILIES   18   /* families loop */
176 #define ISPOUSES    19   /* spouses loop */
177 #define ICHILDREN   20   /* children loop */
178 #define IINDI       21   /* person loop */
179 #define IFAM        22   /* family loop */
180 #define ISOUR       23   /* source loop */
181 #define IEVEN       24   /* event loop */
182 #define IOTHR       25   /* other loop */
183 #define ILIST       26   /* list loop */
184 #define ISET        27   /* set loop */
185 #define IFATHS      28   /* fathers loop */
186 #define IMOTHS      29   /* mothers loop */
187 #define IFAMCS      30   /* parents loop */
188 #define INOTES      31   /* notes loop */
189 #define IFAMILYSPOUSES 32   /* family spouses loop */
190 #define IFREED      99   /* returned to free list */
191 
192 /* pnode flags */
193 enum {
194 	 PN_INAME_HSTR = 0x2 /* iname is a heap string */
195 	, PN_ICHILD_HPTR = 0x4 /* ichild is a heap string */
196 	, PN_INUM_HPTR = 0x8 /* inum is a heap string */
197 	, PN_ISPOUSE_HPTR = 0x10 /* ispouse is a heap string */
198 	, PN_IFAMILY_HPTR = 0x20 /* ifamily is a heap string */
199 	, PN_IELEMENT_HPTR = 0x40 /* ielement is a heap string */
200 	, PN_IPARENT_HPTR = 0x80 /* iiparent is a heap string */
201 	, PN_IVALVAR_HPTR = 0x100 /* ivalvar is a heap string */
202 };
203 
204 #define itype(i)     ((i)->i_type)  /* node type - all nodes */
205 #define iprnt(i)     ((i)->i_prnt)  /* parent node - all nodes */
206 #define inext(i)     ((i)->i_next)  /* next node - all nodes */
207 #define iline(i)     ((i)->i_line)  /* program line - all nodes */
208 #define irptinfo(i)  ((i)->i_rptinfo)  /* program name - all nodes */
209 
210 CNSTRING iident_name(PNODE node);
211 #define iargs(i)     ((i)->i_word2)     /* param and arg lists */
212 PNODE builtin_args(PNODE node);
213 PNODE ipdefn_args(PNODE node);
214 PNODE ipcall_args(PNODE node);
215 PNODE ifdefn_args(PNODE node);
216 PNODE ifcall_args(PNODE node);
217 
218 #define ifunc(i)     ((i)->i_word3)     /* func and builtin reference */
219 #define ichild(i)    ((i)->i_word2)     /* var in children loop */
220 #define ispouse(i)   ((i)->i_word2)     /* var in families and spouses loop */
221 #define ifamily(i)   ((i)->i_word3)     /* var in all families type loops */
222 #define iiparent(i)  ((i)->i_word2)     /* var in some families type loops */
223 #define ivalvar(i)   ((i)->i_word3)     /* var in indiset loop */
224 #define iname(i)     ((i)->i_word1)     /* proc, func and builtin names */
225 #define ilev(i)      ((i)->i_word3)     /* var traverse loop */
226 
227 #define iloopexp(i)  ((i)->i_word1)     /* top loop expression */
228 #define ielement(i)  ((i)->i_word2)     /* loop element */
229 #define ibody(i)     ((i)->i_word5)     /* body of proc, func, loops */
230 #define inum(i)      ((i)->i_word4)     /* counter used by many loops */
231 
232 typedef PVALUE (*PFUNC)(PNODE, SYMTAB, BOOLEAN *);
233 
234 #define pitype(i)	ptype(ivalue(i))
235 #define pivalue(i)	pvalue(ivalue(i))
236 
237 typedef struct {
238 	char *ft_name;
239 	INT ft_nparms_min;
240 	INT ft_nparms_max;
241 	PVALUE (*ft_eval)(PNODE, SYMTAB, BOOLEAN *);
242 } BUILTINS;
243 
244 #define INTERPTYPE INT
245 #define INTERROR    0
246 #define INTOKAY     1
247 #define INTBREAK    2
248 #define INTCONTINUE 3
249 #define INTRETURN   4
250 
251 void initinterp(void);
252 void initrassa(void);
253 void finishinterp(void);
254 void finishrassa(void);
255 
256 INTERPTYPE interpret(PNODE, SYMTAB, PVALUE*);
257 INTERPTYPE interp_children(PNODE, SYMTAB, PVALUE*);
258 INTERPTYPE interp_spouses(PNODE, SYMTAB, PVALUE*);
259 INTERPTYPE interp_families(PNODE, SYMTAB, PVALUE*);
260 INTERPTYPE interp_fathers(PNODE, SYMTAB, PVALUE*);
261 INTERPTYPE interp_mothers(PNODE, SYMTAB, PVALUE*);
262 INTERPTYPE interp_parents(PNODE, SYMTAB, PVALUE*);
263 INTERPTYPE interp_familyspouses(PNODE, SYMTAB, PVALUE*);
264 INTERPTYPE interp_fornotes(PNODE, SYMTAB, PVALUE*);
265 INTERPTYPE interp_fornodes(PNODE, SYMTAB, PVALUE*);
266 INTERPTYPE interp_forindi(PNODE, SYMTAB, PVALUE*);
267 INTERPTYPE interp_forsour(PNODE, SYMTAB, PVALUE*);
268 INTERPTYPE interp_foreven(PNODE, SYMTAB, PVALUE*);
269 INTERPTYPE interp_forothr(PNODE, SYMTAB, PVALUE*);
270 INTERPTYPE interp_forfam(PNODE, SYMTAB, PVALUE*);
271 INTERPTYPE interp_indisetloop(PNODE, SYMTAB, PVALUE*);
272 INTERPTYPE interp_forlist(PNODE, SYMTAB, PVALUE*);
273 INTERPTYPE interp_if(PNODE, SYMTAB, PVALUE*);
274 INTERPTYPE interp_while(PNODE, SYMTAB, PVALUE*);
275 INTERPTYPE interp_call(PNODE, SYMTAB, PVALUE*);
276 INTERPTYPE interp_traverse(PNODE, SYMTAB, PVALUE*);
277 
278 /************************************************************************/
279 /* Language Keyword Implementations                                     */
280 /************************************************************************/
281 
282 PVALUE llrpt_alpha(PNODE, SYMTAB, BOOLEAN *);
283 PVALUE llrpt_add(PNODE, SYMTAB, BOOLEAN *);
284 PVALUE llrpt_addnode(PNODE, SYMTAB, BOOLEAN *);
285 PVALUE llrpt_addtoset(PNODE, SYMTAB, BOOLEAN *);
286 PVALUE llrpt_ancestorset(PNODE, SYMTAB, BOOLEAN *);
287 PVALUE llrpt_and(PNODE, SYMTAB, BOOLEAN *);
288 PVALUE llrpt_arccos(PNODE, SYMTAB, BOOLEAN *);
289 PVALUE llrpt_arcsin(PNODE, SYMTAB, BOOLEAN *);
290 PVALUE llrpt_arctan(PNODE, SYMTAB, BOOLEAN *);
291 PVALUE llrpt_bapt(PNODE, SYMTAB, BOOLEAN *);
292 PVALUE llrpt_birt(PNODE, SYMTAB, BOOLEAN *);
293 PVALUE llrpt_buri(PNODE, SYMTAB, BOOLEAN *);
294 PVALUE llrpt_bytecode(PNODE, SYMTAB, BOOLEAN *);
295 PVALUE llrpt_capitalize(PNODE, SYMTAB, BOOLEAN *);
296 PVALUE llrpt_card(PNODE, SYMTAB, BOOLEAN *);
297 PVALUE llrpt_child(PNODE, SYMTAB, BOOLEAN *);
298 PVALUE llrpt_childset(PNODE, SYMTAB, BOOLEAN *);
299 PVALUE llrpt_choosechild(PNODE, SYMTAB, BOOLEAN *);
300 PVALUE llrpt_choosefam(PNODE, SYMTAB, BOOLEAN *);
301 PVALUE llrpt_chooseindi(PNODE, SYMTAB, BOOLEAN *);
302 PVALUE llrpt_choosespouse(PNODE, SYMTAB, BOOLEAN *);
303 PVALUE llrpt_choosesubset(PNODE, SYMTAB, BOOLEAN *);
304 PVALUE llrpt_clear(PNODE, SYMTAB, BOOLEAN *);
305 PVALUE llrpt_col(PNODE, SYMTAB, BOOLEAN *);
306 PVALUE llrpt_cos(PNODE, SYMTAB, BOOLEAN *);
307 PVALUE llrpt_complexdate(PNODE, SYMTAB, BOOLEAN *);
308 PVALUE llrpt_complexformat(PNODE, SYMTAB, BOOLEAN *);
309 PVALUE llrpt_complexpic(PNODE, SYMTAB, BOOLEAN *);
310 PVALUE llrpt_concat(PNODE, SYMTAB, BOOLEAN *);
311 PVALUE llrpt_convertcode(PNODE, SYMTAB, BOOLEAN *);
312 PVALUE llrpt_copyfile(PNODE, SYMTAB, BOOLEAN *);
313 PVALUE llrpt_createnode(PNODE, SYMTAB, BOOLEAN *);
314 PVALUE llrpt_d(PNODE, SYMTAB, BOOLEAN *);
315 PVALUE llrpt_database(PNODE, SYMTAB, BOOLEAN *);
316 PVALUE llrpt_date(PNODE, SYMTAB, BOOLEAN *);
317 PVALUE llrpt_date2jd(PNODE, SYMTAB, BOOLEAN *);
318 PVALUE llrpt_dateformat(PNODE, SYMTAB, BOOLEAN *);
319 PVALUE llrpt_datepic(PNODE, SYMTAB, BOOLEAN *);
320 PVALUE llrpt_dayformat(PNODE, SYMTAB, BOOLEAN *);
321 PVALUE llrpt_dayofweek(PNODE, SYMTAB, BOOLEAN *);
322 PVALUE llrpt_deat(PNODE, SYMTAB, BOOLEAN *);
323 PVALUE llrpt_debug(PNODE, SYMTAB, BOOLEAN *);
324 PVALUE llrpt_decr(PNODE, SYMTAB, BOOLEAN *);
325 PVALUE llrpt_deg2dms(PNODE, SYMTAB, BOOLEAN *);
326 PVALUE llrpt_deletefromset(PNODE, SYMTAB, BOOLEAN *);
327 PVALUE llrpt_dequeue(PNODE, SYMTAB, BOOLEAN *);
328 PVALUE llrpt_descendentset(PNODE, SYMTAB, BOOLEAN *);
329 PVALUE llrpt_detachnode(PNODE, SYMTAB, BOOLEAN *);
330 PVALUE llrpt_difference(PNODE, SYMTAB, BOOLEAN *);
331 PVALUE llrpt_div(PNODE, SYMTAB, BOOLEAN *);
332 PVALUE llrpt_dms2deg(PNODE, SYMTAB, BOOLEAN *);
333 PVALUE llrpt_dup(PNODE, SYMTAB, BOOLEAN *);
334 PVALUE llrpt_empty(PNODE, SYMTAB, BOOLEAN *);
335 PVALUE llrpt_enqueue(PNODE, SYMTAB, BOOLEAN *);
336 PVALUE llrpt_eq(PNODE, SYMTAB, BOOLEAN *);
337 PVALUE llrpt_eqstr(PNODE, SYMTAB, BOOLEAN *);
338 PVALUE llrpt_exp(PNODE, SYMTAB, BOOLEAN *);
339 PVALUE llrpt_extractdate(PNODE, SYMTAB, BOOLEAN *);
340 PVALUE llrpt_extractdatestr(PNODE, SYMTAB, BOOLEAN *);
341 PVALUE llrpt_extractnames(PNODE, SYMTAB, BOOLEAN *);
342 PVALUE llrpt_extractplaces(PNODE, SYMTAB, BOOLEAN *);
343 PVALUE llrpt_extracttokens(PNODE, SYMTAB, BOOLEAN *);
344 PVALUE llrpt_f(PNODE, SYMTAB, BOOLEAN *);
345 PVALUE llrpt_fam(PNODE, SYMTAB, BOOLEAN *);
346 PVALUE llrpt_fath(PNODE, SYMTAB, BOOLEAN *);
347 PVALUE llrpt_female(PNODE, SYMTAB, BOOLEAN *);
348 PVALUE llrpt_firstchild(PNODE, SYMTAB, BOOLEAN *);
349 PVALUE llrpt_firstfam(PNODE, SYMTAB, BOOLEAN *);
350 PVALUE llrpt_firstindi(PNODE, SYMTAB, BOOLEAN *);
351 PVALUE llrpt_float(PNODE, SYMTAB, BOOLEAN *);
352 PVALUE llrpt_fnode(PNODE, SYMTAB, BOOLEAN *);
353 PVALUE llrpt_free(PNODE, SYMTAB, BOOLEAN *);
354 PVALUE llrpt_free(PNODE, SYMTAB, BOOLEAN *);
355 PVALUE llrpt_fullname(PNODE, SYMTAB, BOOLEAN *);
356 PVALUE llrpt_ge(PNODE, SYMTAB, BOOLEAN *);
357 PVALUE llrpt_gengedcom(PNODE, SYMTAB, BOOLEAN *);
358 PVALUE llrpt_gengedcomweak(PNODE, SYMTAB, BOOLEAN *);
359 PVALUE llrpt_gengedcomstrong(PNODE, SYMTAB, BOOLEAN *);
360 PVALUE llrpt_genindiset(PNODE, SYMTAB, BOOLEAN *);
361 PVALUE llrpt_getcol(PNODE, SYMTAB, BOOLEAN *);
362 PVALUE llrpt_getel(PNODE, SYMTAB, BOOLEAN *);
363 PVALUE llrpt_getfam(PNODE, SYMTAB, BOOLEAN *);
364 PVALUE llrpt_getindi(PNODE, SYMTAB, BOOLEAN *);
365 PVALUE llrpt_getindiset(PNODE, SYMTAB, BOOLEAN *);
366 PVALUE llrpt_getint(PNODE, SYMTAB, BOOLEAN *);
367 PVALUE llrpt_getproperty(PNODE, SYMTAB, BOOLEAN *);
368 PVALUE llrpt_dereference(PNODE, SYMTAB, BOOLEAN *);
369 PVALUE llrpt_getstr(PNODE, SYMTAB, BOOLEAN *);
370 PVALUE llrpt_gettext(PNODE, SYMTAB, BOOLEAN *);
371 PVALUE llrpt_gettoday(PNODE, SYMTAB, BOOLEAN *);
372 PVALUE llrpt_givens(PNODE, SYMTAB, BOOLEAN *);
373 PVALUE llrpt_gt(PNODE, SYMTAB, BOOLEAN *);
374 PVALUE llrpt_heapused(PNODE, SYMTAB, BOOLEAN *);
375 PVALUE llrpt_husband(PNODE, SYMTAB, BOOLEAN *);
376 PVALUE llrpt_incr(PNODE, SYMTAB, BOOLEAN *);
377 PVALUE llrpt_index(PNODE, SYMTAB, BOOLEAN *);
378 PVALUE llrpt_indi(PNODE, SYMTAB, BOOLEAN *);
379 PVALUE llrpt_indiset(PNODE, SYMTAB, BOOLEAN *);
380 PVALUE llrpt_inlist(PNODE, SYMTAB, BOOLEAN *);
381 PVALUE llrpt_inlist(PNODE, SYMTAB, BOOLEAN *);
382 PVALUE llrpt_inode(PNODE, SYMTAB, BOOLEAN *);
383 PVALUE llrpt_insert(PNODE, SYMTAB, BOOLEAN *);
384 PVALUE llrpt_inset(PNODE, SYMTAB, BOOLEAN *);
385 PVALUE llrpt_int(PNODE, SYMTAB, BOOLEAN *);
386 PVALUE llrpt_intersect(PNODE, SYMTAB, BOOLEAN *);
387 PVALUE llrpt_jd2date(PNODE, SYMTAB, BOOLEAN *);
388 PVALUE llrpt_key(PNODE, SYMTAB, BOOLEAN *);
389 PVALUE llrpt_keysort(PNODE, SYMTAB, BOOLEAN *);
390 PVALUE llrpt_lastchild(PNODE, SYMTAB, BOOLEAN *);
391 PVALUE llrpt_lastfam(PNODE, SYMTAB, BOOLEAN *);
392 PVALUE llrpt_lastindi(PNODE, SYMTAB, BOOLEAN *);
393 PVALUE llrpt_le(PNODE, SYMTAB, BOOLEAN *);
394 PVALUE llrpt_length(PNODE, SYMTAB, BOOLEAN *);
395 PVALUE llrpt_lengthset(PNODE, SYMTAB, BOOLEAN *);
396 PVALUE llrpt_level(PNODE, SYMTAB, BOOLEAN *);
397 PVALUE llrpt_linemode(PNODE, SYMTAB, BOOLEAN *);
398 PVALUE llrpt_list(PNODE, SYMTAB, BOOLEAN *);
399 PVALUE llrpt_lock(PNODE, SYMTAB, BOOLEAN *);
400 PVALUE llrpt_long(PNODE, SYMTAB, BOOLEAN *);
401 PVALUE llrpt_lookup(PNODE, SYMTAB, BOOLEAN *);
402 PVALUE llrpt_lower(PNODE, SYMTAB, BOOLEAN *);
403 PVALUE llrpt_lt(PNODE, SYMTAB, BOOLEAN *);
404 PVALUE llrpt_male(PNODE, SYMTAB, BOOLEAN *);
405 PVALUE llrpt_marr(PNODE, SYMTAB, BOOLEAN *);
406 PVALUE llrpt_menuchoose(PNODE, SYMTAB, BOOLEAN *);
407 PVALUE llrpt_mod(PNODE, SYMTAB, BOOLEAN *);
408 PVALUE llrpt_monthformat(PNODE, SYMTAB, BOOLEAN *);
409 PVALUE llrpt_moth(PNODE, SYMTAB, BOOLEAN *);
410 PVALUE llrpt_mul(PNODE, SYMTAB, BOOLEAN *);
411 PVALUE llrpt_name(PNODE, SYMTAB, BOOLEAN *);
412 PVALUE llrpt_namesort(PNODE, SYMTAB, BOOLEAN *);
413 PVALUE llrpt_nchildren(PNODE, SYMTAB, BOOLEAN *);
414 PVALUE llrpt_ne(PNODE, SYMTAB, BOOLEAN *);
415 PVALUE llrpt_neg(PNODE, SYMTAB, BOOLEAN *);
416 PVALUE llrpt_nestr(PNODE, SYMTAB, BOOLEAN *);
417 PVALUE llrpt_newfile(PNODE, SYMTAB, BOOLEAN *);
418 PVALUE llrpt_nextfam(PNODE, SYMTAB, BOOLEAN *);
419 PVALUE llrpt_nextindi(PNODE, SYMTAB, BOOLEAN *);
420 PVALUE llrpt_nextsib(PNODE, SYMTAB, BOOLEAN *);
421 PVALUE llrpt_nfamilies(PNODE, SYMTAB, BOOLEAN *);
422 PVALUE llrpt_nl(PNODE, SYMTAB, BOOLEAN *);
423 PVALUE llrpt_not(PNODE, SYMTAB, BOOLEAN *);
424 PVALUE llrpt_nspouses(PNODE, SYMTAB, BOOLEAN *);
425 PVALUE llrpt_or(PNODE, SYMTAB, BOOLEAN *);
426 PVALUE llrpt_ord(PNODE, SYMTAB, BOOLEAN *);
427 PVALUE llrpt_eraformat(PNODE, SYMTAB, BOOLEAN *);
428 PVALUE llrpt_outfile(PNODE, SYMTAB, BOOLEAN *);
429 PVALUE llrpt_pagemode(PNODE, SYMTAB, BOOLEAN *);
430 PVALUE llrpt_pageout(PNODE, SYMTAB, BOOLEAN *);
431 PVALUE llrpt_parent(PNODE, SYMTAB, BOOLEAN *);
432 PVALUE llrpt_parents(PNODE, SYMTAB, BOOLEAN *);
433 PVALUE llrpt_parentset(PNODE, SYMTAB, BOOLEAN *);
434 PVALUE llrpt_place(PNODE, SYMTAB, BOOLEAN *);
435 PVALUE llrpt_pn(PNODE, SYMTAB, BOOLEAN *);
436 PVALUE llrpt_pop(PNODE, SYMTAB, BOOLEAN *);
437 PVALUE llrpt_pos(PNODE, SYMTAB, BOOLEAN *);
438 PVALUE llrpt_prevfam(PNODE, SYMTAB, BOOLEAN *);
439 PVALUE llrpt_previndi(PNODE, SYMTAB, BOOLEAN *);
440 PVALUE llrpt_prevsib(PNODE, SYMTAB, BOOLEAN *);
441 PVALUE llrpt_print(PNODE, SYMTAB, BOOLEAN *);
442 PVALUE llrpt_program(PNODE, SYMTAB, BOOLEAN *);
443 PVALUE llrpt_push(PNODE, SYMTAB, BOOLEAN *);
444 PVALUE llrpt_pvalue(PNODE, SYMTAB, BOOLEAN *);
445 PVALUE llrpt_qt(PNODE, SYMTAB, BOOLEAN *);
446 PVALUE llrpt_reference(PNODE, SYMTAB, BOOLEAN *);
447 PVALUE llrpt_requeue(PNODE, SYMTAB, BOOLEAN *);
448 PVALUE llrpt_rjustify(PNODE, SYMTAB, BOOLEAN *);
449 PVALUE llrpt_roman(PNODE, SYMTAB, BOOLEAN *);
450 PVALUE llrpt_rot(PNODE, SYMTAB, BOOLEAN *);
451 PVALUE llrpt_row(PNODE, SYMTAB, BOOLEAN *);
452 PVALUE llrpt_rsort(PNODE, SYMTAB, BOOLEAN *);
453 PVALUE llrpt_save(PNODE, SYMTAB, BOOLEAN *);
454 PVALUE llrpt_savenode(PNODE, SYMTAB, BOOLEAN *);
455 PVALUE llrpt_set(PNODE, SYMTAB, BOOLEAN *);
456 PVALUE llrpt_setdate(PNODE, SYMTAB, BOOLEAN *);
457 PVALUE llrpt_setel(PNODE, SYMTAB, BOOLEAN *);
458 PVALUE llrpt_setlocale(PNODE, SYMTAB, BOOLEAN *);
459 PVALUE llrpt_sex(PNODE, SYMTAB, BOOLEAN *);
460 PVALUE llrpt_short(PNODE, SYMTAB, BOOLEAN *);
461 PVALUE llrpt_sibling(PNODE, SYMTAB, BOOLEAN *);
462 PVALUE llrpt_siblingset(PNODE, SYMTAB, BOOLEAN *);
463 PVALUE llrpt_sin(PNODE, SYMTAB, BOOLEAN *);
464 PVALUE llrpt_sort(PNODE, SYMTAB, BOOLEAN *);
465 PVALUE llrpt_soundex(PNODE, SYMTAB, BOOLEAN *);
466 PVALUE llrpt_space(PNODE, SYMTAB, BOOLEAN *);
467 PVALUE llrpt_spdist(PNODE, SYMTAB, BOOLEAN *);
468 PVALUE llrpt_spouseset(PNODE, SYMTAB, BOOLEAN *);
469 PVALUE llrpt_stddate(PNODE, SYMTAB, BOOLEAN *);
470 PVALUE llrpt_strcmp(PNODE, SYMTAB, BOOLEAN *);
471 PVALUE llrpt_strlen(PNODE, SYMTAB, BOOLEAN *);
472 PVALUE llrpt_strsoundex(PNODE, SYMTAB, BOOLEAN *);
473 PVALUE llrpt_strtoint(PNODE, SYMTAB, BOOLEAN *);
474 PVALUE llrpt_sub(PNODE, SYMTAB, BOOLEAN *);
475 PVALUE llrpt_substring(PNODE, SYMTAB, BOOLEAN *);
476 PVALUE llrpt_surname(PNODE, SYMTAB, BOOLEAN *);
477 PVALUE llrpt_runsystem(PNODE, SYMTAB, BOOLEAN *);
478 PVALUE llrpt_table(PNODE, SYMTAB, BOOLEAN *);
479 PVALUE llrpt_tag(PNODE, SYMTAB, BOOLEAN *);
480 PVALUE llrpt_tan(PNODE, SYMTAB, BOOLEAN *);
481 PVALUE llrpt_test(PNODE, SYMTAB, BOOLEAN *);
482 PVALUE llrpt_titl(PNODE, SYMTAB, BOOLEAN *);
483 PVALUE llrpt_titlcase(PNODE, SYMTAB, BOOLEAN *);
484 PVALUE llrpt_trim(PNODE, SYMTAB, BOOLEAN *);
485 PVALUE llrpt_trimname(PNODE, SYMTAB, BOOLEAN *);
486 PVALUE llrpt_union(PNODE, SYMTAB, BOOLEAN *);
487 PVALUE llrpt_uniqueset(PNODE, SYMTAB, BOOLEAN *);
488 PVALUE llrpt_unlock(PNODE, SYMTAB, BOOLEAN *);
489 PVALUE llrpt_upper(PNODE, SYMTAB, BOOLEAN *);
490 PVALUE llrpt_value(PNODE, SYMTAB, BOOLEAN *);
491 PVALUE llrpt_valuesort(PNODE, SYMTAB, BOOLEAN *);
492 PVALUE llrpt_version(PNODE, SYMTAB, BOOLEAN *);
493 PVALUE llrpt_wife(PNODE, SYMTAB, BOOLEAN *);
494 PVALUE llrpt_writefam(PNODE, SYMTAB, BOOLEAN *);
495 PVALUE llrpt_writeindi(PNODE, SYMTAB, BOOLEAN *);
496 PVALUE llrpt_xref(PNODE, SYMTAB, BOOLEAN *);
497 PVALUE llrpt_year(PNODE, SYMTAB, BOOLEAN *);
498 PVALUE llrpt_yearformat(PNODE, SYMTAB, BOOLEAN *);
499 
500 /* **************************************************************** */
501 
502 extern BUILTINS builtins[];
503 extern INT nobuiltins;
504 extern BOOLEAN prog_trace;
505 
506 extern TABLE gfunctab;
507 extern SYMTAB globtab;
508 extern TABLE gproctab;
509 
510 extern FILE *Poutfp;
511 extern INT _rows;
512 extern INT _cols;
513 extern INT Perrors;
514 extern INT nobuiltins;
515 
516 /* standard argument error messages (populated in alloc.c) */
517 extern STRING nonint1, nonintx, nonboo1, nonboox;
518 extern STRING nonflo1, nonflox, nonstr1, nonstrx;
519 extern STRING nullarg1, nonfname1;
520 extern STRING nonnodstr1;
521 extern STRING nonind1, nonindx, nonfam1, nonfamx, nonif1, nonrecx;
522 extern STRING nonnod1, nonnodx;
523 extern STRING nonvar1, nonvarx;
524 extern STRING nonlst1, nonlstx;
525 extern STRING nontabx;
526 extern STRING nonset1,nonsetx;
527 extern STRING nonlstarrx;
528 extern STRING badtrig;
529 extern STRING badarg1, badargs, badargx;
530 
531 /* Input and output modes */
532 
533 #define FILEMODE   0	/* input from a file */
534 #define STRINGMODE 1	/* input or output from or to a string */
535 #define UNBUFFERED 2	/* output unbuffered to a file */
536 #define BUFFERED   3	/* output buffered to a file */
537 #define PAGEMODE   4	/* output page buffered to a file */
538 
539 #define TYPE_CHECK(t, v) \
540 	if (ptype(v) != t) {\
541 		*eflg = TRUE;\
542 		return NULL;\
543 	}
544 
545 void dolock_node_in_cache(NODE, BOOLEAN lock);
546 
547 /* Prototypes */
548 void assign_iden(SYMTAB stab, CNSTRING id, PVALUE value);
549 PNODE break_node(PACTX pactx);
550 PNODE children_node(PACTX pactx, PNODE, STRING, STRING, PNODE);
551 void clear_rptinfos(void);
552 PNODE continue_node(PACTX pactx);
553 PNODE create_call_node(PACTX pactx, STRING, PNODE);
554 PNODE create_fcons_node(PACTX pactx, FLOAT);
555 PNODE create_icons_node(PACTX pactx, INT ival);
556 PNODE create_iden_node(PACTX pactx, STRING);
557 PNODE create_proc_node(PACTX pactx, CNSTRING, PNODE, PNODE);
558 void describe_pnode (PNODE node, ZSTR zstr, INT max);
559 void debug_show_one_pnode(PNODE);
560 CNSTRING get_pvalue_type_name(INT ptype);
561 PVALUE evaluate(PNODE, SYMTAB, BOOLEAN*);
562 BOOLEAN evaluate_cond(PNODE, SYMTAB, BOOLEAN*);
563 PVALUE evaluate_func(PNODE, SYMTAB, BOOLEAN*);
564 PVALUE evaluate_iden(PNODE, SYMTAB, BOOLEAN*);
565 PVALUE evaluate_ufunc(PNODE, SYMTAB, BOOLEAN*);
566 PVALUE eval_and_coerce(INT, PNODE, SYMTAB, BOOLEAN*);
567 NODE eval_indi(PNODE, SYMTAB, BOOLEAN*, CACHEEL*);
568 NODE eval_indi2(PNODE expr, SYMTAB stab, BOOLEAN *eflg, CACHEEL *pcel, PVALUE *pval);
569 NODE eval_fam(PNODE, SYMTAB, BOOLEAN*, CACHEEL*);
570 PVALUE eval_without_coerce(PNODE node, SYMTAB stab, BOOLEAN *eflg);
571 PNODE families_node(PACTX pactx, PNODE, STRING, STRING, STRING, PNODE);
572 PNODE fathers_node(PACTX pactx, PNODE, STRING, STRING, STRING, PNODE);
573 PNODE fdef_node(PACTX pactx, CNSTRING, PNODE, PNODE);
574 PNODE foreven_node(PACTX pactx, STRING, STRING, PNODE);
575 PNODE forfam_node(PACTX pactx, STRING, STRING, PNODE);
576 PNODE forindi_node(PACTX pactx, STRING, STRING, PNODE);
577 PNODE forindiset_node(PACTX pactx, PNODE, STRING, STRING, STRING, PNODE);
578 PNODE forlist_node(PACTX pactx, PNODE, STRING, STRING, PNODE);
579 PNODE fornodes_node(PACTX pactx, PNODE, STRING, PNODE);
580 PNODE fornotes_node(PACTX pactx, PNODE, STRING, PNODE);
581 PNODE forothr_node(PACTX pactx, STRING, STRING, PNODE);
582 PNODE forsour_node(PACTX pactx, STRING, STRING, PNODE);
583 void free_iden(void *iden);
584 void free_all_pnodes(void);
585 void free_pnode_tree(PNODE);
586 PNODE func_node(PACTX pactx, STRING, PNODE);
587 CNSTRING get_internal_string_node_value(PNODE node);
588 PNODE get_proc_node(CNSTRING procname, TABLE loctab, TABLE gtab, INT * count);
589 RPTINFO get_rptinfo(CNSTRING fullpath);
590 PNODE if_node(PACTX pactx, PNODE, PNODE, PNODE);
591 BOOLEAN iistype(PNODE, INT);
592 void init_debugger(void);
593 void interp_load_lang(void);
594 PNODE make_internal_string_node(PACTX pactx, STRING);
595 PNODE mothers_node(PACTX pactx, PNODE, STRING, STRING, STRING, PNODE);
596 INT num_params(PNODE);
597 void pa_handle_char_encoding(PACTX pactx, PNODE node);
598 void pa_handle_include(PACTX pactx, PNODE node);
599 void pa_handle_func(PACTX pactx, CNSTRING funcname, PNODE nd_args, PNODE nd_body);
600 void pa_handle_global(STRING iden);
601 void pa_handle_option(CNSTRING optname);
602 void pa_handle_proc(PACTX pactx, CNSTRING procname, PNODE nd_args, PNODE nd_body);
603 void pa_handle_require(PACTX pactx, PNODE node);
604 PNODE familyspouses_node(PACTX pactx, PNODE, STRING, STRING, PNODE);
605 PNODE parents_node(PACTX pactx, PNODE, STRING, STRING, PNODE);
606 void prog_error(PNODE, STRING, ...);
607 void prog_var_error(PNODE node, SYMTAB stab, PNODE arg, PVALUE val, STRING fmt, ...);
608 STRING prot(STRING str);
609 BOOLEAN record_to_node(PVALUE val);
610 PNODE return_node(PACTX pactx, PNODE);
611 void set_rptfile_prop(PACTX pactx, STRING fname, STRING key, STRING value);
612 void show_pnode(PNODE);
613 void show_pnodes(PNODE);
614 PNODE spouses_node(PACTX pactx, PNODE, STRING, STRING, STRING, PNODE);
615 BOOLEAN start_output_file (STRING outfname);
616 PNODE create_string_node(PACTX pactx, STRING);
617 void trace_endl(void);
618 void trace_out(STRING fmt, ...);
619 void trace_outl(STRING fmt, ...);
620 void trace_pnode(PNODE node);
621 void trace_pvalue(PVALUE val);
622 PNODE traverse_node(PACTX pactx, PNODE, STRING, STRING, PNODE);
623 PVALUE valueof_iden(PNODE node, SYMTAB stab, CNSTRING iden, BOOLEAN *eflg);
624 PNODE while_node(PACTX pactx, PNODE, PNODE);
625 
626 #endif /* _INTERP_PRIV_H */
627