/*
* From: @(#)rpc_parse.c 1.8 89/02/22 (C) 1987 SMI
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * 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.
* * Neither the name of Sun Microsystems, Inc. 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 COPYRIGHT HOLDERS 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
* COPYRIGHT HOLDER 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.
*/
/*
* rpc_parse.c, Parser for the RPC protocol compiler
* Copyright (C) 1987 Sun Microsystems, Inc.
*/
#include <stdio.h>
#include <string.h>
#include "rpc/types.h"
#include "rpc_scan.h"
#include "rpc_parse.h"
#include "rpc_util.h"
#include "proto.h"
#define ARGNAME "arg"
static void isdefined (definition * defp);
static void def_struct (definition * defp);
static void def_program (definition * defp);
static void def_enum (definition * defp);
static void def_const (definition * defp);
static void def_union (definition * defp);
static void check_type_name (const char *name, int new_type);
static void def_typedef (definition * defp);
static void get_declaration (declaration * dec, defkind dkind);
static void get_prog_declaration (declaration * dec, defkind dkind, int num);
static void get_type (const char **prefixp, const char **typep, defkind dkind);
static void unsigned_dec (const char **typep);
/*
* return the next definition you see
*/
definition *
get_definition (void)
{
definition *defp;
token tok;
defp = ALLOC (definition);
get_token (&tok);
switch (tok.kind)
{
case TOK_STRUCT:
def_struct (defp);
break;
case TOK_UNION:
def_union (defp);
break;
case TOK_TYPEDEF:
def_typedef (defp);
break;
case TOK_ENUM:
def_enum (defp);
break;
case TOK_PROGRAM:
def_program (defp);
break;
case TOK_CONST:
def_const (defp);
break;
case TOK_EOF:
free (defp);
return (NULL);
default:
error ("definition keyword expected");
}
scan (TOK_SEMICOLON, &tok);
isdefined (defp);
return (defp);
}
static void
isdefined (definition * defp)
{
STOREVAL (&defined, defp);
}
static void
def_struct (definition