/* libsizzle/macros.h - macro handling
 
  Copyright (C) 2000 Martin Grabmueller <mgrabmue@cs.tu-berlin.de>
 
  This is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2, or (at your option)
  any later version.
  
  This software is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with this package; see the file COPYING.  If not, write to the
  Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  MA 02111-1307, USA.  */

#ifndef __SIZZLE_MACROS_H__
#define __SIZZLE_MACROS_H__

#if HAVE_CONFIG_H
# include <config.h>
#endif 

#if __SIZZLE_IMPORT__
# define SIZZLE_API __declspec (dllimport)
#elif __SIZZLE_EXPORT__ 
# define SIZZLE_API __declspec (dllexport)
#else
# define SIZZLE_API
#endif

#include "node.h"

#define macro_p(c)      (tagged_p(c) &&\
                         tagged_type(c) == zzz_tagged_type_macro)
#define macro_proc(c)   ((zzz_scm_t) tagged_data0(c))

#if ENABLE_R5RS_MACROS
#define syntax_p(c)     (tagged_p(c) &&\
                         tagged_type(c) == zzz_tagged_type_syntax)
#define syntax_rules(c) ((zzz_scm_t) tagged_data0(c))
#endif /* ENABLE_R5RS_MACROS */

/* The tagged type for macro objects.  */
SIZZLE_API extern zzz_object_t zzz_tagged_type_macro;
#if ENABLE_R5RS_MACROS
/* The tagged type for syntax objects.  */
SIZZLE_API extern zzz_object_t zzz_tagged_type_syntax;
#endif /* ENABLE_R5RS_MACROS */

/* Create a macro with the transformer procedure @var{proc}.  */
SIZZLE_API zzz_scm_t zzz_make_macro (zzz_scm_t proc);

#if ENABLE_R5RS_MACROS
/* Create a syntax object with the transformation rules @var{rules}.  */
SIZZLE_API zzz_scm_t zzz_make_syntax (zzz_scm_t rules);
#endif /* ENABLE_R5RS_MACROS */

/* Expand the macro @var{macro} with parameters @var{params} in the
   environment @var{env} and store the expanded form in the location
   pointed to by @var{result}.  */
SIZZLE_API result_t zzz_expand_macro (zzz_scm_t env, zzz_scm_t macro,
				      zzz_scm_t params, zzz_scm_t * result);

#if ENABLE_R5RS_MACROS
/* Expand the syntax with keyword @var{keyword} and parameters
   @var{params} in the environment @var{env} and store the expanded
   form in the location pointed to by @var{result}.  */
SIZZLE_API result_t zzz_expand_syntax (zzz_scm_t env, zzz_scm_t keyword,
				       zzz_scm_t params, zzz_scm_t * result);
#endif /* ENABLE_R5RS_MACROS */

/* Initialize the macro module.  */
SIZZLE_API result_t zzz_init_macro (void);

#endif /* not __SIZZLE_MACROS_H__ */
