convert "assert" from being a reserved word to being a non-standard procedure
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Fri, 27 Aug 1982 15:35:00 +0000 (07:35 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Fri, 27 Aug 1982 15:35:00 +0000 (07:35 -0800)
SCCS-vsn: usr.bin/pascal/src/hash.c 1.3
SCCS-vsn: usr.bin/pascal/src/tree.h 1.2
SCCS-vsn: usr.bin/pascal/src/yycosts.c 1.3
SCCS-vsn: usr.bin/pascal/src/nl.c 1.8
SCCS-vsn: usr.bin/pascal/src/stat.c 1.7
SCCS-vsn: usr.bin/pascal/src/pas.y 1.6
SCCS-vsn: usr.bin/pascal/src/proc.c 1.11
SCCS-vsn: usr.bin/pascal/src/pcproc.c 1.9

usr/src/usr.bin/pascal/src/hash.c
usr/src/usr.bin/pascal/src/nl.c
usr/src/usr.bin/pascal/src/pas.y
usr/src/usr.bin/pascal/src/pcproc.c
usr/src/usr.bin/pascal/src/proc.c
usr/src/usr.bin/pascal/src/stat.c
usr/src/usr.bin/pascal/src/tree.h
usr/src/usr.bin/pascal/src/yycosts.c

index c391ecc..ba725ef 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-static char sccsid[] = "@(#)hash.c 1.2 %G%";
+static char sccsid[] = "@(#)hash.c 1.3 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -23,7 +23,6 @@ struct ht {
 struct kwtab yykey[] = {
        "and",          YAND,
        "array",        YARRAY,
 struct kwtab yykey[] = {
        "and",          YAND,
        "array",        YARRAY,
-       "assert",       YASSERT,
        "begin",        YBEGIN,
        "case",         YCASE,
        "const",        YCONST,
        "begin",        YBEGIN,
        "case",         YCASE,
        "const",        YCONST,
index 8621551..9e42d6c 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-static char sccsid[] = "@(#)nl.c 1.7 %G%";
+static char sccsid[] = "@(#)nl.c 1.8 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -139,6 +139,7 @@ char *in_funcs[] =
         */
 char *in_procs[] =
     {
         */
 char *in_procs[] =
     {
+       "assert",
        "date" ,
        "dispose" ,
        "flush" ,
        "date" ,
        "dispose" ,
        "flush" ,
@@ -213,6 +214,7 @@ int in_fops[] =
      */
 int in_pops[] =
     {
      */
 int in_pops[] =
     {
+       O_ASRT|NSTAND,
        O_DATE|NSTAND,
        O_DISPOSE,
        O_FLUSH|NSTAND,
        O_DATE|NSTAND,
        O_DISPOSE,
        O_FLUSH|NSTAND,
index 5dccb18..992a270 100644 (file)
@@ -64,8 +64,7 @@
        YSET            YSTRING         YTHEN           YDOWNTO
        YTYPE           YUNTIL          YVAR            YWHILE
        YWITH           YBINT           YOCT            YHEX
        YSET            YSTRING         YTHEN           YDOWNTO
        YTYPE           YUNTIL          YVAR            YWHILE
        YWITH           YBINT           YOCT            YHEX
-       YASSERT         YCASELAB        YILLCH          YEXTERN
-       YLAST
+       YCASELAB        YILLCH          YEXTERN         YLAST
 
 /*
  * PRECEDENCE DECLARATIONS
 
 /*
  * PRECEDENCE DECLARATIONS
@@ -89,7 +88,7 @@
 
 /* Copyright (c) 1979 Regents of the University of California */
 
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-/* static      char sccsid[] = "@(#)pas.y 1.5 %G%"; */
+/* static      char sccsid[] = "@(#)pas.y 1.6 %G%"; */
 
 /*
  * The following line marks the end of the yacc
 
 /*
  * The following line marks the end of the yacc
@@ -99,7 +98,7 @@
 ##
 /* Copyright (c) 1979 Regents of the University of California */
 
 ##
 /* Copyright (c) 1979 Regents of the University of California */
 
-static char sccsid[] = "@(#)pas.y 1.5 %G%";
+static char sccsid[] = "@(#)pas.y 1.6 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -604,9 +603,6 @@ stat:
        YIF expr YTHEN stat YELSE stat
                = $$ = tree5(T_IFEL, lineof($1), $2, $4, $6);
                |
        YIF expr YTHEN stat YELSE stat
                = $$ = tree5(T_IFEL, lineof($1), $2, $4, $6);
                |
-       YASSERT '(' expr ')'
-               = $$ = tree3(T_ASRT, lineof($1), $3);
-               |
        error
                = {
 NSerror:
        error
                = {
 NSerror:
index 0dab969..6b4626c 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-static char sccsid[] = "@(#)pcproc.c 1.8 %G%";
+static char sccsid[] = "@(#)pcproc.c 1.9 %G%";
 
 #include "whoami.h"
 #ifdef PC
 
 #include "whoami.h"
 #ifdef PC
@@ -1391,6 +1391,41 @@ pcproc(r)
                putdot( filename , line );
                return;
 
                putdot( filename , line );
                return;
 
+       case O_ASRT:
+               if (!opt('t'))
+                       return;
+               if (argc == 0 || argc > 2) {
+                       error("Assert expects one or two arguments");
+                       return;
+               }
+               putleaf( P2ICON , 0 , 0
+                   , ADDTYPE( P2FTN | P2INT , P2PTR ) , "_ASRT" );
+               ap = stkrval(argv[1], NIL , RREQ );
+               if (ap == NIL)
+                       return;
+               if (isnta(ap, "b"))
+                       error("Assert expression must be Boolean, not %ss", nameof(ap));
+               if (argc == 2) {
+                       /*
+                        * Optional second argument is a string specifying
+                        * why the assertion failed.
+                        */
+                       al = argv[2];
+                       al = stkrval(al[1], NIL , RREQ );
+                       if (al == NIL)
+                               return;
+                       if (classify(al) != TSTR) {
+                               error("Second argument to assert must be a string, not %s", nameof(al));
+                               return;
+                       }
+               } else {
+                       putleaf( P2ICON , 0 , 0 , P2INT , 0 );
+               }
+               putop( P2LISTOP , P2INT );
+               putop( P2CALL , P2INT );
+               putdot( filename , line );
+               return;
+
        case O_PACK:
                if (argc != 3) {
                        error("pack expects three arguments");
        case O_PACK:
                if (argc != 3) {
                        error("pack expects three arguments");
@@ -1477,7 +1512,7 @@ packunp:
                putdot( filename , line );
                return;
        case 0:
                putdot( filename , line );
                return;
        case 0:
-               error("%s is an unimplemented 6400 extension", p->symbol);
+               error("%s is an unimplemented extension", p->symbol);
                return;
 
        default:
                return;
 
        default:
index ae1fb3d..b82c6db 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-static char sccsid[] = "@(#)proc.c 1.10 %G%";
+static char sccsid[] = "@(#)proc.c 1.11 %G%";
 
 #include "whoami.h"
 #ifdef OBJ
 
 #include "whoami.h"
 #ifdef OBJ
@@ -1005,6 +1005,37 @@ proc(r)
                put(1, op);
                return;
 
                put(1, op);
                return;
 
+       case O_ASRT:
+               if (!opt('t'))
+                       return;
+               if (argc == 0 || argc > 2) {
+                       error("Assert expects one or two arguments");
+                       return;
+               }
+               if (argc == 2) {
+                       /*
+                        * Optional second argument is a string specifying
+                        * why the assertion failed.
+                        */
+                       al = argv[2];
+                       al = stkrval(al[1], NIL , RREQ );
+                       if (al == NIL)
+                               return;
+                       if (classify(al) != TSTR) {
+                               error("Second argument to assert must be a string, not %s", nameof(al));
+                               return;
+                       }
+               } else {
+                       put(2, PTR_CON, NIL);
+               }
+               ap = stkrval(argv[1], NIL , RREQ );
+               if (ap == NIL)
+                       return;
+               if (isnta(ap, "b"))
+                       error("Assert expression must be Boolean, not %ss", nameof(ap));
+               put(1, O_ASRT);
+               return;
+
        case O_PACK:
                if (argc != 3) {
                        error("pack expects three arguments");
        case O_PACK:
                if (argc != 3) {
                        error("pack expects three arguments");
@@ -1088,7 +1119,7 @@ packunp:
                put(1, op);
                return;
        case 0:
                put(1, op);
                return;
        case 0:
-               error("%s is an unimplemented 6400 extension", p->symbol);
+               error("%s is an unimplemented extension", p->symbol);
                return;
 
        default:
                return;
 
        default:
index 5ceb665..256e963 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-static char sccsid[] = "@(#)stat.c 1.6 %G%";
+static char sccsid[] = "@(#)stat.c 1.7 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -116,10 +116,6 @@ top:
                                case T_WITH:
                                        withop(s);
                                        break;
                                case T_WITH:
                                        withop(s);
                                        break;
-                               case T_ASRT:
-                                       putline();
-                                       asrtop(s);
-                                       break;
                        }
                        --level;
                        if (gotos[cbn])
                        }
                        --level;
                        if (gotos[cbn])
@@ -599,39 +595,3 @@ repop(r)
        if (goc != gocnt)
                putcnt();
 }
        if (goc != gocnt)
                putcnt();
 }
-
-/*
- * assert expr
- */
-asrtop(r)
-       register int *r;
-{
-       register struct nl *q;
-
-       if (opt('s')) {
-               standard();
-               error("Assert statement is non-standard");
-       }
-       if (!opt('t'))
-               return;
-       r = r[2];
-#      ifdef OBJ
-           q = rvalue((int *) r, NLNIL , RREQ );
-#      endif OBJ
-#      ifdef PC
-           putleaf( P2ICON , 0 , 0
-                   , ADDTYPE( P2FTN | P2INT , P2PTR ) , "_ASRT" );
-           q = stkrval( r , NLNIL , RREQ );
-#      endif PC
-       if (q == NIL)
-               return;
-       if (isnta(q, "b"))
-               error("Assert expression must be Boolean, not %ss", nameof(q));
-#      ifdef OBJ
-           put(1, O_ASRT);
-#      endif OBJ
-#      ifdef PC
-           putop( P2CALL , P2INT );
-           putdot( filename , line );
-#      endif PC
-}
index 1fcf29d..28c99e8 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-/* static      char sccsid[] = "@(#)tree.h 1.1 %G%"; */
+/* static      char sccsid[] = "@(#)tree.h 1.2 %G%"; */
 
 #define T_MINUS 1
 #define T_MOD 2
 
 #define T_MINUS 1
 #define T_MOD 2
@@ -63,7 +63,6 @@
 #define T_FORD 59
 #define T_GOTO 60
 #define T_IF 61
 #define T_FORD 59
 #define T_GOTO 60
 #define T_IF 61
-#define T_ASRT 62
 #define T_CSET 63
 #define T_RANG 64
 #define T_VAR 65
 #define T_CSET 63
 #define T_RANG 64
 #define T_VAR 65
index eba6a19..6c0c894 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-static char sccsid[] = "@(#)yycosts.c 1.2 %G%";
+static char sccsid[] = "@(#)yycosts.c 1.3 %G%";
 
 #include "whoami.h"
 #include "0.h"
 
 #include "whoami.h"
 #include "0.h"
@@ -100,7 +100,6 @@ inscost(sy, before)
                case '[':
                case YWHILE:
                case YWITH:
                case '[':
                case YWHILE:
                case YWITH:
-               case YASSERT:
                        return (5);
                case YPROCEDURE:
                case YFUNCTION:
                        return (5);
                case YPROCEDURE:
                case YFUNCTION: