/* %Z%%M% %I% %E% */

/*
 * Copyright (c) 1990, 1991, 1992, 1995 by Wayne C. Gramlich.
 * All rights reserved.
 *
 * Permission to use, copy, modify, distribute, and sell this software
 * for any purpose is hereby granted without fee provided that the above
 * copyright notice and this permission are retained.  The author makes
 * no representations about the suitability of this software for any purpose.
 * It is provided "as is" without express or implied warranty.
 */

/* This file defines the exp data structures: */

#ifndef EXP_DEFS_H
#define EXP_DEFS_H

#ifndef EXP_EXPORTS_H
#include "exp_exports.h"
#endif

#ifndef STR_TYPES_H
#include "str_types.h"
#endif

#ifndef TOKEN_TYPES_H
#include "token_types.h"
#endif

#ifndef TYPE_TYPES_H
#include "type_types.h"
#endif

struct Exp_access_struct {
	Exp		exp;		/* Expression to left of bracket */
	Vec(Exp)	list;		/* Expression list in brackets */
};

struct Exp_assign_struct {
	Vec(Exp)	left;		/* Left list of assignable exps */
	Vec(Exp)	right;		/* Right list of exps */
};

struct Exp_binary_struct {
	Exp		left;		/* Left operand */
	Exp		right;		/* Right operand */
};

struct Exp_define_struct {
	Str		name;		/* Variable name */
	Type_ref	type_ref;	/* Variable type */
};

struct Exp_field_struct {
	Exp		exp;		/* Expression to left of field */
	Str		name;		/* Field name */
};

struct Exp_object_struct {
	Str		name;		/* Routine name */
	Exp		object;		/* Object expression to left of '~' */
	Vec(Exp)	list;		/* Routine arguments */
};

struct Exp_trinary_struct {
	Exp		first;		/* First expression */
	Exp		second;		/* Second expression */
	Exp		third;		/* Third expression */
};

struct Exp_type_struct {
	Str		name;		/* Name to left of '@' */
	Type_ref	type_ref;	/* Type reference on right of '@' */
};

union Exp_operands_union {
	Exp_access	access;		/* Array access expression */
	Exp_assign	assign;		/* Assignment expression */
	Exp_binary	binary;		/* Binary expression */
	Exp_define	define;		/* Define expression */
	Str		error;		/* Error expression */
	Exp_field	field;		/* Field access expression */
	int		integer;	/* Leaf number */
	Vec(Exp)	list;		/* Comma separated expression list */
	Exp_object	object;		/* Object invocation expression */
	Str		string;		/* Leaf string */
	Str		symbol;		/* Leaf symbol */
	Str		text;		/* Leaf text */
	Exp_trinary	trinary;	/* Trinary expression */
	Exp_type	type;		/* Type reference expression */
	Exp		unary;		/* Unary expression */
};

struct Exp_struct {
	Call		call;		/* Assocaiated call tree of (Call)0 */
	Exp_op		op;		/* Operator */
	Exp_operands	operands;	/* Operands */
	int		position;	/* Position in file */
	Token		token;		/* Operator token */
	Type_refs	type_refs;	/* Expression types */
};

#endif /* EXP_DEFS_H */
