Wild Life  2.29
 All Data Structures Files Functions Variables Typedefs Macros
parser.c
Go to the documentation of this file.
1 /* Copyright 1991 Digital Equipment Corporation.
2 ** Distributed only by permission.
3 **
4 ** Last modified on Thu Mar 3 14:16:16 MET 1994 by rmeyer
5 ** modified on Mon Sep 27 09:37:03 1993 by Rmeyer
6 ** modified on Tue Jun 9 14:03:14 1992 by vanroy
7 ** modified on Thu Aug 22 18:14:49 1991 by herve
8 *****************************************************************/
9 /* $Id: parser.c,v 1.2 1994/12/08 23:32:03 duchier Exp $ */
10 
11 #include "defs.h"
12 
13 /******** BAD_PSI_TERM(t)
14  This returns true if T is a psi_term which is not allowed to be considered
15  as a constant by the parser.
16 
17  Example: "A=)+6." would otherwise be parsed as: "=(A,+(')',6))", this was
18  going a bit far.
19 */
21 ptr_psi_term t;
22 {
23  char *s,c;
24  long r;
25 
26 
27  if(t->type==final_dot || t->type==final_question) /* RM: Jul 9 1993 */
28  return TRUE;
29 
30  s=t->type->keyword->symbol;
31  c=s[0];
32  r=(s[1]==0 &&
33  (c=='(' ||
34  c==')' ||
35  c=='[' ||
36  c==']' ||
37  c=='{' ||
38  c=='}'
39  /* || c=='.' || c=='?' RM: Jul 7 1993 */
40  )
41  );
42 
43  return r;
44 }
45 
46 
47 
48 /******** SHOW(limit)
49  This prints the parser's stack, for debugging purposes
50  only, LIMIT marks the bottom of the current stack.
51 */
52 void show(limit)
53 long limit;
54 {
55  long i;
56 
57  for (i=1;i<=parser_stack_index;i++) {
58  if (i==limit)
59  printf("-> ");
60  else
61  printf(" ");
62  printf("%3ld: ",i);
63  switch (op_stack[i]) {
64  case fx:
65  printf("FX ");
66  break;
67  case xfx:
68  printf("XFX ");
69  break;
70  case xf:
71  printf("XF ");
72  break;
73  case nop:
74  printf("NOP ");
75  break;
76  default:
77  printf("??? ");
78  }
79  printf(" prec=%4ld ",int_stack[i]);
81  printf("\n");
82  }
83  printf("\n");
84 }
85 
86 
87 
88 /******** PUSH(tok,prec,op)
89  Push psi_term and precedence and operator onto parser stack.
90 */
91 void push(tok,prec,op)
92 psi_term tok;
93 long prec;
94 long op;
95 {
97  perr("*** Parser error ");
99  perr(": stack full.\n");
100  }
101  else {
105  op_stack[parser_stack_index]=op;
106  }
107 }
108 
109 
110 
111 /******** POP(psi_term,op);
112  This function pops PSI_TERM and OP off the parser stack and returns
113  its precedence.
114 */
115 long pop(tok,op)
116 ptr_psi_term tok;
117 long *op;
118 {
119  long r=0;
120 
121  if (parser_stack_index==0) {
122  /*
123  perr("*** Parser error ");
124  psi_term_error();
125  perr(": stack empty.\n");
126  */
127 
128  (*tok)= *error_psi_term;
129  parse_ok=FALSE;
130  }
131  else {
133  (*op)=op_stack[parser_stack_index];
136  }
137 
138  return r;
139 }
140 
141 
142 
143 /******** LOOK()
144  This function returns the precedence of the stack top.
145 */
146 long look()
147 {
149 }
150 
151 
152 
153 /******** PRECEDENCE(tok,typ)
154  This function returns the precedence of
155  TOK if it is an operator of type TYP where TYP is FX XFX XF etc...
156  Note that this allows both a binary and unary minus.
157  The result is NOP if tok is not an operator.
158 */
159 long precedence(tok,typ)
160 psi_term tok;
161 long typ;
162 {
163  long r=NOP;
165 
166  o=tok.type->op_data;
167  while(o && r==NOP) {
168  if(typ==o->type)
169  r=o->precedence;
170  else
171  o=o->next;
172  }
173 
174  return r;
175 }
176 
177 
178 
179 /******** STACK_COPY_PSI_TERM(tok)
180  Return the address of a copy of TOK on the STACK.
181  All psi_terms read in by the parser are read into the stack.
182 */
184 psi_term t;
185 {
186  ptr_psi_term p;
187 
189  (*p)=t;
190 #ifdef TS
191  p->time_stamp=global_time_stamp; /* 9.6 */
192 #endif
193 
194  return p;
195 }
196 
197 
198 
199 /******** HEAP_COPY_PSI_TERM(tok)
200  Return the address of a copy of TOK on the HEAP.
201 */
203 psi_term t;
204 {
205  ptr_psi_term p;
206 
207  p=HEAP_ALLOC(psi_term);
208  (*p)=t;
209 #ifdef TS
210  p->time_stamp=global_time_stamp; /* 9.6 */
211 #endif
212 
213  return p;
214 }
215 
216 
217 
218 
219 /******** FEATURE_INSERT(keystr,tree,psi)
220  Insert the psi_term psi into the attribute tree.
221  If the feature already exists, create a call to the unification
222  function.
223 */
224 
225 void feature_insert(keystr,tree,psi)
226 char *keystr;
227 ptr_node *tree;
228 ptr_psi_term psi;
229 {
230  ptr_node loc;
231  ptr_psi_term stk_psi;
232 
233  // printf("before find in feature_insert feature=%s\n",keystr);
234  if ((loc=find(FEATCMP,keystr,*tree))) {
235  /* Give an error message if there is a duplicate feature: */
236  Syntaxerrorline("duplicate feature %s\n",keystr);
237  }
238  else {
239  /* If the feature does not exist, insert it. */
240  stk_psi=stack_copy_psi_term(*psi); // 19.8 */
241  stack_insert_copystr(keystr,tree,(GENERIC)stk_psi); /* 10.8 */
242  }
243 }
244 
245 
246 
247 
248 /*** RM 9 Dec 1992 START ***/
249 
250 
251 /******** LIST_NIL(type)
252  Returns the atom NIL to mark the end of a list.
253  */
254 
255 psi_term list_nil(type) /* RM: Feb 1 1993 */
256 
257  ptr_definition type;
258 {
259  psi_term nihil;
260 
261  if(type==disjunction) /* RM: Feb 1 1993 */
262  nihil.type=disj_nil;
263  else
264  nihil.type=nil;
265 
266  nihil.status=0;
267  nihil.flags=FALSE; /* 14.9 */
268  nihil.attr_list=NULL;
269  nihil.resid=NULL;
270  nihil.value_3=NULL;
271  nihil.coref=NULL;
272 
273  return nihil;
274 }
275 
276 
277 
278 /******** PARSE_LIST(type,end,separator)
279 
280  This function provides a replacement for the function 'read_list'. It does
281  not create the old (slightly more compact and a lot more complicated) list
282  structure, but instead creates a generic psi-term with 2 features. The list
283  is terminated by the atom 'nil'.
284 
285  Example:
286 
287  [a,b,c|d] -> cons(a,cons(b,cons(c,d))).
288  [] -> nil
289  {a;b;c} -> disj(a,disj(b,disj(c,{}))).
290  {} -> {} = *bottom*
291 
292 
293  Example:
294  TYP=disjunction,
295  END="}",
296  SEPARATOR=";" will read in disjunctions.
297 
298  Example:
299  TYP=list,
300  END="]",
301  SEPARATOR="," will read lists such as [1,2,a,b,c|d]
302  */
303 
305  ptr_definition typ;
306  char e,s;
307 
308 {
309  ptr_psi_term car=NULL;
310  ptr_psi_term cdr=NULL;
311  psi_term result;
312  psi_term t;
313  char a;
314 
315 
316 
317  result=list_nil(typ); /* RM: Feb 1 1993 */
318 
319  if (parse_ok) {
320 
321  /* Character used for building cons pairs */
322  a='|'; /* RM: Jan 11 1993 */
323 
324 
325  read_token(&t);
326 
327  if(!equ_tokc(t,e)) {
328 
329  /* Read the CAR of the list */
330  put_back_token(t);
332 
333  /* Read the CDR of the list */
334  read_token(&t);
335  if(equ_tokch(t,s))
336  cdr=stack_copy_psi_term(parse_list(typ,e,s));
337  else if(equ_tokch(t,e))
338  cdr=stack_copy_psi_term(list_nil(typ));
339  else if(equ_tokch(t,'|')) {
341  read_token(&t);
342  if(!equ_tokch(t,e)) {
344  else {
345  perr("*** Syntax error ");psi_term_error();
346  perr(": bad symbol for end of list '");
347  display_psi_stderr(&t);
348  perr("'.\n");
349  put_back_token(t);
350  }
351  }
352  }
353  else
355  else {
356  perr("*** Syntax error ");psi_term_error();
357  perr(": bad symbol in list '");
358  display_psi_stderr(&t);
359  perr("'.\n");
360  put_back_token(t);
361  }
362 
363  result.type=typ;
364  if(car)
365  (void)stack_insert(FEATCMP,one,&(result.attr_list),(GENERIC)car);
366  if(cdr)
367  (void)stack_insert(FEATCMP,two,&(result.attr_list),(GENERIC)cdr);
368  }
369  }
370 
371  return result;
372 }
373 /*** RM 9 Dec 1992 END ***/
374 
375 
376 
377 
378 /******** READ_PSI_TERM()
379  This reads in a complex object from the input
380  stream, that is, a whole psi-term.
381 
382  Examples:
383 
384  [A,B,C]
385 
386  {0;1;2+A}
387 
388  <a,b,c> death(victim => V,murderer => M)
389 
390  which(x,y,z)
391 
392  A:g(f)
393 
394  I have allowed mixing labelled with unlabelled attributes.
395 
396  Example:
397 
398  f(x=>A,B,y=>K,"hklk",D) is parsed as f(1=>B,2=>"hklk",3=>D,x=>A,y=>K).
399 */
401 {
402  psi_term t,t2,t3;
403  char s[10];
404  long count=0,f=TRUE,f2,v;
405  ptr_psi_term module;
406 
407 
408  if(parse_ok) {
409 
410  read_token(&t);
411 
412  if(equ_tokch(t,'['))
413  t=parse_list(alist,']',','); /*** RICHARD Nov_4 ***/
414  else
415  if(equ_tokch(t,'{'))
416  t=parse_list(disjunction,'}',';'); /*** RICHARD Nov_4 ***/
417 
418  /* The syntax <a,b,c> for conjunctions has been abandoned.
419  else
420  if(equ_tokch(t,'<'))
421  t=parse_list(conjunction,'>',',');
422  */
423 
424  if(parse_ok
425  && t.type!=eof
426  && !bad_psi_term(&t)
427  /* && (precedence(t,fx)==NOP)
428  && (precedence(t,fy)==NOP) */
429  ) {
430  read_token(&t2);
431  if(equ_tokch(t2,'(')) {
432 
433  do {
434 
435  f2=TRUE;
436  read_token(&t2);
437 
438  if(wl_const_3(t2) && !bad_psi_term(&t2)) {
439  read_token(&t3);
440  if(equ_tok(t3,"=>")) {
441  t3=read_life_form(',',')');
442 
443  if(t2.type->keyword->private_feature) /* RM: Mar 11 1993 */
445  /* RM: Jan 13 1993 */
446  &(t.attr_list),
447  &t3);
448  else
450  /* RM: Jan 13 1993 */
451  &(t.attr_list),
452  &t3);
453 
454  f2=FALSE;
455  }
456  else
457  put_back_token(t3);
458  }
459 
460  if(parse_ok && equal_types(t2.type,integer)) {
461  read_token(&t3);
462  if(equ_tok(t3,"=>")) {
463  t3=read_life_form(',',')');
464  v= *(REAL *)t2.value_3;
465  (void)snprintf(s,10,"%ld",v);
466  feature_insert(s,&(t.attr_list),&t3);
467  f2=FALSE;
468  }
469  else
470  put_back_token(t3);
471  }
472 
473  if(f2) {
474  put_back_token(t2);
475  t2=read_life_form(',',')');
476  ++count;
477  (void)snprintf(s,10,"%ld",count);
478  feature_insert(s,&(t.attr_list),&t2);
479  }
480 
481  read_token(&t2);
482 
483  if(equ_tokch(t2,')'))
484  f=FALSE;
485  else
486  if(!equ_tokch(t2,',')) {
488  else {
489  /*
490  perr("*** Syntax error ");psi_term_error();
491  perr(": ',' expected in argument list.\n");
492  */
493 
494  /* RM: Feb 1 1993 */
495  Syntaxerrorline("',' expected in argument list (%E)\n");
496 
497  f=FALSE;
498  }
499  }
500 
501  } while(f && parse_ok);
502  }
503  else
504  put_back_token(t2);
505  }
506  }
507  else
508  t= *error_psi_term;
509 
510  if(t.type==variable && t.attr_list) {
511  t2=t;
512  t.type=apply;
513  t.value_3=NULL;
514  t.coref=NULL;
515  t.resid=NULL;
516  (void)stack_insert(FEATCMP,(char *)functor->keyword->symbol,
517  &(t.attr_list),
519  }
520 
521 
522  /* RM: Mar 12 1993 Nasty hack for Bruno's features in modules */
523  if((t.type==add_module1 || t.type==add_module2 || t.type==add_module3) &&
524  !find(FEATCMP,two,t.attr_list)) {
525 
526  module=stack_psi_term(4);
527  module->type=quoted_string;
529 
530  (void)stack_insert(FEATCMP,two,&(t.attr_list),(GENERIC)module);
531  }
532 
533  return t;
534 }
535 
536 
537 
538 /******** MAKE_LIFE_FORM(tok,arg1,arg2)
539  This routine inserts ARG1 and ARG2 as the first and second attributes of
540  psi_term TOK, thus creating the term TOK(1=>arg1,2=>arg2).
541 
542  If TOK is ':' then a conjunction is created if necessary.
543  Example:
544  a:V:b:5:long => V: <a,b,5,int> (= conjunction list).
545 */
546 psi_term make_life_form(tok,arg1,arg2)
547 ptr_psi_term tok,arg1,arg2;
548 {
549  // ptr_list l;
550  ptr_psi_term a1,a2;
551 
552  deref_ptr(tok);
553  tok->attr_list=NULL;
554  tok->resid=NULL;
555 
556 
557  /* Here beginneth a terrible FIX,
558  I will have to rewrite the tokeniser and the parser to handle
559  POINTERS to psi-terms instead of PSI_TERMS !!!
560  */
561 
562  a1=arg1;
563  a2=arg2;
564 
565  if (a1)
566  deref_ptr(a1);
567  if (a2)
568  deref_ptr(a2);
569 
570  /* End of extremely ugly fix. */
571 
572  if (/* UNI FALSE */ equ_tokch((*tok),':') && arg1 && arg2) {
573 
574  if (a1!=a2) {
575  if (a1->type==top &&
576  !a1->attr_list &&
577  !a1->resid) {
578  if (a1!=arg1)
579  /* push_ptr_value(psi_term_ptr,&(a1->coref)); 9.6 */
580  push_psi_ptr_value(a1,(GENERIC *)&(a1->coref));
581  a1->coref=stack_copy_psi_term(*arg2);
582  tok=arg1;
583  }
584  else
585  if(a2->type==top &&
586  !a2->attr_list &&
587  !a2->resid) {
588  if(a2!=arg2)
589  /* push_ptr_value(psi_term_ptr,&(a2->coref)); 9.6 */
590  push_psi_ptr_value(a2,(GENERIC *)&(a2->coref));
591  a2->coref=stack_copy_psi_term(*arg1);
592  tok=arg2;
593  }
594  else { /* RM: Feb 22 1993 Now reports an error */
595  Syntaxerrorline("':' occurs where '&' required (%E)\n");
596  *tok= *error_psi_term;
597  /* make_unify_pair(tok,arg1,arg2); Old code */
598  }
599  }
600  else
601  tok=arg1;
602  }
603  else {
604 
605  /* RM: Jun 21 1993 */
606  /* And now for another nasty hack: reading negative numbers */
607  if(tok->type==minus_symbol &&
608  a1 &&
609  !a2 &&
610  a1->value_3 &&
611  (a1->type==integer || a1->type==real)) {
612 
613  tok->type=a1->type;
614  tok->value_3=(GENERIC)heap_alloc(sizeof(REAL));
615  *(REAL *)tok->value_3 = - *(REAL *)a1->value_3;
616 
617  return *tok;
618  }
619  /* End of other nasty hack */
620 
621  (void)stack_insert(FEATCMP,one,&(tok->attr_list),(GENERIC)stack_copy_psi_term(*arg1));
622  if (arg2)
623  (void)stack_insert(FEATCMP,two,&(tok->attr_list),(GENERIC)stack_copy_psi_term(*arg2));
624  }
625 
626  return *tok;
627 }
628 
629 
630 
631 /******** CRUNCH(prec,limit)
632  Crunch up = work out the arguments of anything on the stack whose precedence
633  is <= PREC, and replace it with the corresponding psi-term. Do not go any
634  further than LIMIT which is the end of the current expression.
635 */
636 void crunch(prec,limit)
637 long prec;
638 long limit;
639 {
640  psi_term t,t1,t2,t3;
641  long op1,op2,op3;
642 
643  if(parse_ok && prec>=look() && parser_stack_index>limit) {
644 
645  (void)pop(&t1,&op1);
646 
647  switch(op1) {
648 
649  case nop:
650  (void)pop(&t2,&op2);
651  if(op2==fx)
652  t=make_life_form(&t2,&t1,NULL);
653  else
654  if(op2==xfx) {
655  (void)pop(&t3,&op3);
656  if(op3==nop)
657  t=make_life_form(&t2,&t3,&t1);
658  else {
659  printf("*** Parser: ooops, NOP expected.\n");
660  parse_ok=FALSE;
661  t= *error_psi_term;
662  }
663  }
664  break;
665 
666  case xf:
667  (void)pop(&t2,&op2);
668  if(op2==nop)
669  t=make_life_form(&t1,&t2,NULL);
670  else {
671  printf("*** Parser: ugh, NOP expected.\n");
672  t= *error_psi_term;
673  parse_ok=FALSE;
674  }
675  break;
676 
677  default:
678  printf("*** Parser: yuck, weirdo operator.\n");
679  }
680 
681  push(t,look(),nop);
682 
683  crunch(prec,limit);
684  }
685 }
686 
687 
688 
689 /******** READ_LIFE_FORM(str1,str2)
690  This reads in one life-form from the input stream which finishes with
691  the psi_term whose name is STR1 or STR2, typically if we're reading a list
692  [A,4*5,b-4!] then STR1="," and STR2="|" . It would be incorrect if "," were
693  taken as an operator.
694 
695  This routine implements the two state expression parser as described in the
696  implementation guide. It deals with all the various types of operators,
697  precedence is dealt with by the CRUNCH function. Each time an opening
698  parenthesis is encountered a new expression is started.
699 */
701 char ch1,ch2;
702 {
703  psi_term t,t2;
704  long limit,pr_op,pr_1,pr_2,start=0;
705  long fin=FALSE;
706  long state=0;
707  long prec=0;
708 
709  long op;
710 
711  limit=parser_stack_index+1;
712 
713  if (parse_ok)
714  do {
715  if (state)
716  read_token(&t);
717  else
718  t=read_psi_term();
719 
720  if (!start)
721  start=line_count;
722 
723  if (!fin)
724  if (state) {
725  if (equ_tokc(t,ch1) || equ_tokc(t,ch2)) {
726  fin=TRUE;
727  put_back_token(t);
728  }
729  else {
730  pr_op=precedence(t,xf);
731  pr_1=pr_op-1;
732 
733  if(pr_op==NOP) {
734  pr_op=precedence(t,yf);
735  pr_1=pr_op;
736  }
737 
738  if(pr_op==NOP) {
739 
740  pr_op=precedence(t,xfx);
741  pr_1=pr_op-1;
742  pr_2=pr_op-1;
743 
744  if(pr_op==NOP) {
745  pr_op=precedence(t,xfy);
746  pr_1=pr_op-1;
747  pr_2=pr_op;
748  }
749 
750  if(pr_op==NOP) {
751  pr_op=precedence(t,yfx);
752  pr_1=pr_op;
753  pr_2=pr_op-1;
754  }
755 
756  /* if(pr_op==NOP) {
757  pr_op=precedence(t,yfy);
758  pr_1=pr_op;
759  pr_2=pr_op-1;
760  }
761  */
762 
763  if(pr_op==NOP) {
764  fin=TRUE;
765  put_back_token(t);
766  }
767  else
768  {
769  crunch(pr_1,limit);
770  push(t,pr_2,xfx);
771  prec=pr_2;
772  state=0;
773  }
774  }
775  else {
776  crunch(pr_1,limit);
777  push(t,pr_1,xf);
778  prec=pr_1;
779  }
780  }
781  }
782  else {
783 
784  if(t.attr_list)
785  pr_op=NOP;
786  else {
787  pr_op=precedence(t,fx);
788  pr_2=pr_op-1;
789 
790  if(pr_op==NOP) {
791  pr_op=precedence(t,fy);
792  pr_2=pr_op;
793  }
794  }
795 
796  if(pr_op==NOP) {
797  if(equ_tokch(t,'(')) {
798  t2=read_life_form(')',0);
799  if(parse_ok) {
800  push(t2,prec,nop);
801  read_token(&t2);
802  if(!equ_tokch(t2,')')) {
804  else {
805  /*
806  perr("*** Syntax error ");psi_term_error();
807  perr(": ')' missing.\n");
808  */
809 
810  /* RM: Feb 1 1993 */
811  Syntaxerrorline("')' missing (%E)\n");
812 
813  put_back_token(t2);
814  }
815  }
816  state=1;
817  }
818  }
819  else
820  if(bad_psi_term(&t)) {
821  put_back_token(t);
822  /* psi_term_error(); */
823  fin=TRUE;
824  }
825  else {
826  push(t,prec,nop);
827  state=1;
828  }
829  }
830  else {
831  push(t,pr_2,fx);
832  prec=pr_2;
833  }
834 
835  }
836 
837  } while (!fin && parse_ok);
838 
839  if (state)
840  crunch(MAX_PRECEDENCE,limit);
841 
842  if (parse_ok && parser_stack_index!=limit) {
844  else {
845  /*
846  perr("*** Syntax error ");psi_term_error();
847  perr(": bad expression.\n");
848  */
849 
850  /* RM: Feb 1 1993 */
851  Syntaxerrorline("bad expression (%E)\n");
852  }
853  }
854  else
855  (void)pop(&t,&op);
856 
857  if (!parse_ok)
858  t= *error_psi_term;
859 
860  parser_stack_index=limit-1;
861 
862  return t;
863 }
864 
865 
866 
867 /******** PARSE(is_it_a_clause)
868  This returns one clause or query from the input stream.
869  It also indicates the type psi-term read, that is whether it was a clause
870  or a query in the IS_IT_A_CLAUSE variable. This is the top level of the
871  parser.
872 
873  The whole parser is, rather like the psi_termiser, not too well written.
874  It handles psi_terms rather than pointers which causes a lot of messy code
875  and is somewhat slower.
876 */
878 long *q;
879 {
880  psi_term s,t,u;
881  long c;
882 
884  parse_ok=TRUE;
885 
886  /*s=read_life_form('.','?');*/
887  s=read_life_form(0,0);
888 
889  if (parse_ok) {
890  if (s.type!=eof) {
891  read_token(&t);
892 
893  /*
894  if (equ_tokch(t,'?'))
895  *q=QUERY;
896  else if (equ_tokch(t,'.'))
897  *q=FACT;
898  */
899 
900  /* RM: Jul 7 1993 */
901  if (t.type==final_question)
902  {
903  *q=QUERY;
904  }
905  else if (t.type==final_dot)
906  {
907  *q=FACT;
908  }
909  else
910  {
912  else {
913 
914  /*
915  perr("*** Syntax error ");psi_term_error();perr(": ");
916  display_psi_stderr(&t);
917  perr(".\n");
918  */
919 
920  /* RM: Feb 1 1993 */
921  Syntaxerrorline("'%P' (%E)\n",&t);
922 
923  }
924  *q=ERROR;
925  }
926  }
927  }
928 
929 
930  if (!parse_ok) {
931 
932  while (saved_psi_term!=NULL) read_token(&u);
933 
934  prompt="error>";
935  while((c=read_char()) && c!=EOF && c!='.' && c!='?' && c!=EOLN) {}
936 
937  *q=ERROR;
938  }
939  else if (saved_char)
940  do {
941  c=read_char();
942  if (c==EOLN)
943  c=0;
944  else if (c<0 || c>32) {
945  put_back_char(c);
946  c=0;
947  }
948  } while(c && c!=EOF);
949 
950  /* Make sure arguments of nonstrict terms are marked quoted. */
951  if (parse_ok) mark_nonstrict(&s); /* 25.8 */
952 
953  /* mark_eval(&s); 24.8 XXX */
954 
955  /* Mark all the psi-terms corresponding to variables in the var_tree as */
956  /* quoted. This is needed for correct parsing of inputs; otherwise vars */
957  /* that occur in an increment of a query are marked to be evaluated again! */
958  /* mark_quote_tree(var_tree); 24.8 XXX */
959 
960 
961  return s;
962 }
ptr_psi_term heap_copy_psi_term(psi_term t)
Definition: parser.c:202
void psi_term_error()
Definition: token.c:661
ptr_residuation resid
Definition: def_struct.h:173
#define yfx
Definition: def_const.h:268
#define FEATCMP
Definition: def_const.h:257
void perr(char *str)
Definition: error.c:659
#define equ_tokc(A, B)
Definition: def_macro.h:71
#define PARSER_STACK_SIZE
Definition: def_const.h:100
void put_back_char(long c)
Definition: token.c:633
void read_token(ptr_psi_term tok)
Definition: token.c:1063
char * combined_name
Definition: def_struct.h:92
#define xfx
Definition: def_const.h:265
ptr_module current_module
Definition: def_glob.h:161
char * two
Definition: def_glob.h:251
void show(long limit)
Definition: parser.c:52
ptr_operator_data next
Definition: def_struct.h:49
void push_psi_ptr_value(ptr_psi_term q, GENERIC *p)
Definition: login.c:443
#define fx
Definition: def_const.h:262
#define NOP
Definition: def_const.h:332
long look()
Definition: parser.c:146
#define FACT
Definition: def_const.h:151
void push(psi_term tok, long prec, long op)
Definition: parser.c:91
void mark_nonstrict(ptr_psi_term t)
Definition: copy.c:462
ptr_keyword keyword
Definition: def_struct.h:124
void display_psi_stdout(ptr_psi_term t)
Definition: print.c:1427
long precedence(psi_term tok, long typ)
Definition: parser.c:159
ptr_definition top
Definition: def_glob.h:106
#define NULL
Definition: def_const.h:203
#define xfy
Definition: def_const.h:267
psi_term parse_list(ptr_definition typ, char e, char s)
Definition: parser.c:304
char * symbol
Definition: def_struct.h:91
long saved_char
Definition: def_glob.h:192
#define nop
Definition: def_const.h:260
ptr_definition apply
Definition: def_glob.h:72
void display_psi_stderr(ptr_psi_term t)
Definition: print.c:1438
#define QUERY
Definition: def_const.h:152
#define ERROR
Definition: def_const.h:153
void put_back_token(psi_term t)
Definition: token.c:647
#define REAL
Definition: def_const.h:72
ptr_definition minus_symbol
Definition: def_glob.h:96
ptr_definition add_module3
Definition: def_glob.h:69
long line_count
Definition: def_glob.h:39
char * heap_copy_string(char *s)
Definition: trees.c:147
psi_term read_life_form(char ch1, char ch2)
Definition: parser.c:700
ptr_definition disj_nil
Definition: def_glob.h:85
#define EOLN
Definition: def_const.h:140
void feature_insert(char *keystr, ptr_node *tree, ptr_psi_term psi)
Definition: parser.c:225
#define wl_const_3(S)
Definition: def_macro.h:104
ptr_definition real
Definition: def_glob.h:102
ptr_node stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
Definition: trees.c:291
#define deref_ptr(P)
Definition: def_macro.h:95
ptr_definition alist
Definition: def_glob.h:94
ptr_definition functor
Definition: def_glob.h:91
ptr_definition eof
Definition: def_glob.h:86
void Syntaxerrorline(char *format,...)
Definition: error.c:498
#define TRUE
Definition: def_const.h:127
long pop(ptr_psi_term tok, long *op)
Definition: parser.c:115
void crunch(long prec, long limit)
Definition: parser.c:636
psi_term parse(long *q)
Definition: parser.c:877
ptr_psi_term error_psi_term
Definition: def_glob.h:23
ptr_definition integer
Definition: def_glob.h:93
ptr_definition final_dot
Definition: def_glob.h:137
int bad_psi_term(ptr_psi_term t)
Definition: parser.c:20
#define FALSE
Definition: def_const.h:128
ptr_definition quoted_string
Definition: def_glob.h:101
ptr_psi_term stack_psi_term(long stat)
Definition: lefun.c:15
GENERIC value_3
Definition: def_struct.h:170
ptr_psi_term stack_copy_psi_term(psi_term t)
Definition: parser.c:183
char * module_name
Definition: def_struct.h:75
ptr_definition disjunction
Definition: def_glob.h:84
ptr_psi_term coref
Definition: def_struct.h:172
char * one
Definition: def_glob.h:250
#define equal_types(A, B)
Definition: def_macro.h:106
#define STACK_ALLOC(A)
Definition: def_macro.h:16
#define xf
Definition: def_const.h:261
ptr_definition add_module2
Definition: def_glob.h:68
ptr_node find(long comp, char *keystr, ptr_node tree)
Definition: trees.c:341
#define yf
Definition: def_const.h:263
ptr_definition final_question
Definition: def_glob.h:138
ptr_psi_term saved_psi_term
Definition: def_glob.h:194
#define MAX_PRECEDENCE
Definition: def_const.h:103
psi_term list_nil(ptr_definition type)
Definition: parser.c:255
ptr_definition add_module1
Definition: def_glob.h:67
psi_term make_life_form(ptr_psi_term tok, ptr_psi_term arg1, ptr_psi_term arg2)
Definition: parser.c:546
char * prompt
Definition: def_glob.h:42
long read_char()
Definition: token.c:587
unsigned long global_time_stamp
Definition: login.c:19
int private_feature
Definition: def_struct.h:95
ptr_definition nil
Definition: def_glob.h:97
long parser_stack_index
Definition: def_glob.h:24
#define equ_tok(A, B)
Definition: def_macro.h:62
long stringparse
Definition: def_glob.h:202
long parse_ok
Definition: def_glob.h:171
ptr_definition type
Definition: def_struct.h:165
unsigned long * GENERIC
Definition: def_struct.h:17
psi_term read_psi_term()
Definition: parser.c:400
#define HEAP_ALLOC(A)
Definition: def_macro.h:15
ptr_definition variable
Definition: def_glob.h:111
ptr_node attr_list
Definition: def_struct.h:171
GENERIC heap_alloc(long s)
Definition: memory.c:1518
void stack_insert_copystr(char *keystr, ptr_node *tree, GENERIC info)
Definition: trees.c:260
long int_stack[PARSER_STACK_SIZE]
Definition: def_glob.h:318
psi_term psi_term_stack[PARSER_STACK_SIZE]
Definition: def_glob.h:317
#define fy
Definition: def_const.h:264
#define equ_tokch(A, B)
Definition: def_macro.h:66