BSD 4_4 release
[unix-history] / usr / src / usr.bin / pascal / src / yyid.c
index 3a865e3..24ce429 100644 (file)
@@ -1,13 +1,47 @@
-/* Copyright (c) 1979 Regents of the University of California */
+/*-
+ * Copyright (c) 1980, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
 
 
-static char sccsid[] = "@(#)yyid.c 1.3 %G%";
+#ifndef lint
+static char sccsid[] = "@(#)yyid.c     8.1 (Berkeley) 6/6/93";
+#endif /* not lint */
 
 #include "whoami.h"
 
 #include "whoami.h"
-#include "0.h"
+#include <0.h>
+#include "tree_ty.h"   /* must be included for yy.h */
 #include "yy.h"
 
 #ifdef PI
 #include "yy.h"
 
 #ifdef PI
-extern int *yypv;
+extern union semstack *yypv;
 /*
  * Determine whether the identifier whose name
  * is "cp" can possibly be a kind, which is a
 /*
  * Determine whether the identifier whose name
  * is "cp" can possibly be a kind, which is a
@@ -54,7 +88,7 @@ identis(cp, kind)
 gotit:
        if (p->class == BADUSE && !Recovery) {
                yybadref(p, OY.Yyeline);
 gotit:
        if (p->class == BADUSE && !Recovery) {
                yybadref(p, OY.Yyeline);
-               yypv[0] = NIL;
+               yypv[0].i_entry = NIL;
        }
        return (1);
 }
        }
        return (1);
 }
@@ -64,6 +98,7 @@ gotit:
  * line and use implying the addition of kindmask
  * to the mask of kind information.
  */
  * line and use implying the addition of kindmask
  * to the mask of kind information.
  */
+struct nl *
 yybaduse(cp, line, kindmask)
        register char *cp;
        int line, kindmask;
 yybaduse(cp, line, kindmask)
        register char *cp;
        int line, kindmask;
@@ -77,7 +112,7 @@ yybaduse(cp, line, kindmask)
                        break;
        oldp = p;
        if (p == NIL || p->class != BADUSE)
                        break;
        oldp = p;
        if (p == NIL || p->class != BADUSE)
-               p = enter(defnl(cp, BADUSE, 0, 0));
+               p = enter(defnl(cp, BADUSE, NLNIL, 0));
        p->value[NL_KINDS] |= kindmask;
        yybadref(p, line);
        return (oldp);
        p->value[NL_KINDS] |= kindmask;
        yybadref(p, line);
        return (oldp);
@@ -87,7 +122,7 @@ yybaduse(cp, line, kindmask)
      * ud is initialized so that esavestr will allocate
      * sizeof ( struct udinfo ) bytes for the 'real' struct udinfo
      */
      * ud is initialized so that esavestr will allocate
      * sizeof ( struct udinfo ) bytes for the 'real' struct udinfo
      */
-struct udinfo ud = { ~0 , ~0 , 0};
+struct udinfo ud = { ~0 , (struct udinfo *) ~0 , 0};
 /*
  * Record a reference to an undefined identifier,
  * or one which is improperly used.
 /*
  * Record a reference to an undefined identifier,
  * or one which is improperly used.
@@ -98,12 +133,12 @@ yybadref(p, line)
 {
        register struct udinfo *udp;
 
 {
        register struct udinfo *udp;
 
-       if (p->chain != NIL && p->chain->ud_line == line)
+       if (p->chain != NIL && ((struct udinfo *) p->chain)->ud_line == line)
                return;
                return;
-       udp = esavestr(&ud);
+       udp = (struct udinfo *) esavestr((char *) &ud);
        udp->ud_line = line;
        udp->ud_line = line;
-       udp->ud_next = p->chain;
-       p->chain = udp;
+       udp->ud_next = (struct udinfo *) p->chain;
+       p->chain = (struct nl *) udp;
 }
 
 #define        varkinds        ((1<<CONST)|(1<<VAR)|(1<<REF)|(1<<ARRAY)|(1<<PTR) \
 }
 
 #define        varkinds        ((1<<CONST)|(1<<VAR)|(1<<REF)|(1<<ARRAY)|(1<<PTR) \
@@ -137,9 +172,9 @@ yyidok1(p, kind)
        register struct nl *p;
        int kind;
 {
        register struct nl *p;
        int kind;
 {
-       int i;
 
        switch (kind) {
 
        switch (kind) {
+               default:
                case FUNC:
                        return (   p -> class == FUNC
                                || p -> class == FVAR
                case FUNC:
                        return (   p -> class == FUNC
                                || p -> class == FVAR
@@ -160,9 +195,9 @@ yyidok1(p, kind)
        }
 }
 
        }
 }
 
-yyisvar(p, class)
+yyisvar(p, varclass)
        register struct nl *p;
        register struct nl *p;
-       int class;
+       int varclass;
 {
 
        switch (p->class) {
 {
 
        switch (p->class) {
@@ -176,10 +211,10 @@ yyisvar(p, class)
                 */
                case FUNC:
                case FFUNC:
                 */
                case FUNC:
                case FFUNC:
-                       return (class == NIL || (p->type != NIL && p->type->class == class));
+                       return (varclass == NIL || (p->type != NIL && p->type->class == varclass));
                case PROC:
                case FPROC:
                case PROC:
                case FPROC:
-                       return ( class == NIL );
+                       return ( varclass == NIL );
        }
        return (0);
 }
        }
        return (0);
 }