BSD 4 release
[unix-history] / usr / src / cmd / pi / pas.y
index 506a7b9..6598e80 100644 (file)
@@ -1,14 +1,4 @@
-/*
- * pi - Pascal interpreter code translator
- *
- * Charles Haley, Bill Joy UCB
- * Version 1.0 August 1977
- *
- * pxp - Pascal execution profiler
- *
- * Bill Joy UCB
- * Version 1.0 August 1977
- */
+/* Copyright (c) 1979 Regents of the University of California */
 
 /*
  * Yacc grammar for UNIX Pascal
 
 /*
  * Yacc grammar for UNIX Pascal
@@ -43,7 +33,7 @@
  *        the same time.
  *
  *     5) Creates the semantic restriction checking routine yyEactr
  *        the same time.
  *
  *     5) Creates the semantic restriction checking routine yyEactr
- *        by processing action lines containing `@'.
+ *        by processing action lines containing `@@'.
  *
  * This compiler uses a different version of the yacc parser, a
  * different yyerror which is called yerror, and requires more
  *
  * This compiler uses a different version of the yacc parser, a
  * different yyerror which is called yerror, and requires more
@@ -74,7 +64,8 @@
        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          YLAST
+       YASSERT         YCASELAB        YILLCH          YEXTERN
+       YLAST
 
 /*
  * PRECEDENCE DECLARATIONS
 
 /*
  * PRECEDENCE DECLARATIONS
 %left  YNOT
 \f
 %{
 %left  YNOT
 \f
 %{
-
 /*
  * GLOBALS FOR ACTIONS
  */
 
 /*
  * GLOBALS FOR ACTIONS
  */
 
+/* Copyright (c) 1979 Regents of the University of California */
+
+/* static      char sccsid[] = "@(#)pas.y 1.3 9/2/80"; */
+
 /*
  * The following line marks the end of the yacc
  * Constant definitions which are removed from
  * y.tab.c and placed in the file y.tab.h.
  */
 ##
 /*
  * The following line marks the end of the yacc
  * Constant definitions which are removed from
  * y.tab.c and placed in the file y.tab.h.
  */
 ##
+/* Copyright (c) 1979 Regents of the University of California */
 
 
-#include "whoami"
+static char sccsid[] = "@(#)pas.y 1.3 9/2/80";
+
+#include "whoami.h"
 #include "0.h"
 #include "yy.h"
 #include "tree.h"
 #include "0.h"
 #include "yy.h"
 #include "tree.h"
  */
 
 goal:
  */
 
 goal:
-       prog_hedr decls procs block '.'
-               = funcend($1, $4, lineof($5));
+       prog_hedr decls block '.'
+               = funcend($1, $3, lineof($4));
+               |
+       decls
+               = segend();
                ;
                ;
+       
 
 prog_hedr:
        YPROG YID '(' id_list ')' ';' 
 
 prog_hedr:
        YPROG YID '(' id_list ')' ';' 
@@ -180,6 +181,8 @@ decl:
                |
        var_decl
                = varend();
                |
        var_decl
                = varend();
+               |
+       proc_decl
                ;
 \f
 /*
                ;
 \f
 /*
@@ -268,18 +271,15 @@ Verror:
  * PROCEDURE AND FUNCTION DECLARATION PART
  */
 
  * PROCEDURE AND FUNCTION DECLARATION PART
  */
 
-procs:
-       /* lambda */
-               |
-       procs proc
-               = trfree();
-               ;
-proc:
+proc_decl:
        phead YFORWARD ';'
                = funcfwd($1);
                |
        phead YFORWARD ';'
                = funcfwd($1);
                |
-       pheadres decls procs block ';'
-               = funcend($1, $4, lineof($5));
+       phead YEXTERN ';'
+               = funcext($1);
+               |
+       pheadres decls block ';'
+               = funcend($1, $3, lineof($4));
                ;
 pheadres:
        phead
                ;
 pheadres:
        phead
@@ -708,7 +708,7 @@ element:
 variable:
        YID
                = {
 variable:
        YID
                = {
-                       @ return (identis(var, VAR));
+                       @@ return (identis(var, VAR));
                        $$ = setupvar($1, NIL);
                  }
                |
                        $$ = setupvar($1, NIL);
                  }
                |
@@ -848,7 +848,7 @@ id_list:
 /*
  * Identifier productions with semantic restrictions
  *
 /*
  * Identifier productions with semantic restrictions
  *
- * For these productions, the character @ signifies
+ * For these productions, the characters @@ signify
  * that the associated C statement is to provide
  * the semantic restriction for this reduction.
  * These lines are made into a procedure yyEactr, similar to
  * that the associated C statement is to provide
  * the semantic restriction for this reduction.
  * These lines are made into a procedure yyEactr, similar to
@@ -863,40 +863,40 @@ id_list:
 
 const_id:
        YID
 
 const_id:
        YID
-               = @ return (identis(var, CONST));
+               = @@ return (identis(var, CONST));
                ;
 type_id:
        YID
                = {
                ;
 type_id:
        YID
                = {
-                       @ return (identis(var, TYPE));
+                       @@ return (identis(var, TYPE));
                        $$ = tree3(T_TYID, lineof(yyline), $1);
                  }
                ;
 var_id:
        YID
                        $$ = tree3(T_TYID, lineof(yyline), $1);
                  }
                ;
 var_id:
        YID
-               = @ return (identis(var, VAR));
+               = @@ return (identis(var, VAR));
                ;
 array_id:
        YID
                ;
 array_id:
        YID
-               = @ return (identis(var, ARRAY));
+               = @@ return (identis(var, ARRAY));
                ;
 ptr_id:
        YID
                ;
 ptr_id:
        YID
-               = @ return (identis(var, PTRFILE));
+               = @@ return (identis(var, PTRFILE));
                ;
 record_id:
        YID
                ;
 record_id:
        YID
-               = @ return (identis(var, RECORD));
+               = @@ return (identis(var, RECORD));
                ;
 field_id:
        YID
                ;
 field_id:
        YID
-               = @ return (identis(var, FIELD));
+               = @@ return (identis(var, FIELD));
                ;
 proc_id:
        YID
                ;
 proc_id:
        YID
-               = @ return (identis(var, PROC));
+               = @@ return (identis(var, PROC));
                ;
 func_id:
        YID
                ;
 func_id:
        YID
-               = @ return (identis(var, FUNC));
+               = @@ return (identis(var, FUNC));
                ;
                ;