-
- Copyright (C) 1976
- by the
- Board of Trustees
- of the
- University of Illinois
-
- All rights reserved
-
-
-FILE NAME:
- parse.c
-
-PURPOSE:
- Contains the routines which keep track of the parse stack.
-
-GLOBALS:
- p_stack = The parse stack, set by both routines
- il = Stack of indentation levels, set by parse
- cstk = Stack of case statement indentation levels, set by parse
- tos = Pointer to top of stack, set by both routines.
-
-FUNCTIONS:
- parse
- reduce
-*/\f
-/*
-
- Copyright (C) 1976
- by the
- Board of Trustees
- of the
- University of Illinois
-
- All rights reserved
-
-
-NAME:
- parse
-
-FUNCTION:
- Parse is given one input which is a "maxi token" just scanned from
- input. Maxi tokens are signifigant constructs such as else, {, do,
- if (...), etc. Parse works with reduce to maintain a parse stack
- of these constructs. Parse is responsible for the "shift" portion
- of the parse algorithm, and reduce handles the "reduce" portion.
-
-ALGORITHM:
- 1) If there is "ifstmt" on the stack and input is anything other than
- an else, then change the top of stack (TOS) to <stmt>. Do a reduce.
- 2) Use a switch statement to implement the following shift operations:
-
- TOS\b\b\b___ Input\b\b\b\b\b_____ Stack\b\b\b\b\b_____ Note\b\b\b\b____
- decl decl nothing
- anything else decl decl
- "dostmt" while (..) Change TOS to <stmt>
- anything else while (..) while
- "ifstmt" else Change TOS to "ifelse"
- { <stmtl> } Change { <stmtl>
- to <stmtl>
- switch (..) switch
- do do
- for(..) for
- ; <stmt>
- { { <stmt>
-
-PARAMETERS:
- tk An integer code for the maxi token scanned
-
-RETURNS:
- Nothing
-
-GLOBALS:
- break_comma = Set to true when in a declaration but not initialization
- btype_2
- case_ind =
- cstk =
- i_l_follow =
- il = Stack of indentation levels
- ind_level =
- p_stack = Stack of token codes
- search_brace = Set to true if we must look for possibility of moving a
- brace
- tos = Pointer to top of p_stack, il, and cstk
-
-CALLS:
- printf (lib)
- reduce
-
-CALLED BY:
- main
-
-HISTORY:
- initial coding November 1976 D A Willcox of CAC
-
-*/\f
+ * Copyright (c) 1985 Sun Microsystems, Inc.
+ * Copyright (c) 1980 The Regents of the University of California.
+ * Copyright (c) 1976 Board of Trustees of the University of Illinois.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley, the University of Illinois,
+ * Urbana, and Sun Microsystems, Inc. The name of either University
+ * or Sun Microsystems may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)parse.c 5.7 (Berkeley) %G%";
+#endif /* not lint */