home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / unofficial-plug-ins / mathmap / exprtree.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-21  |  4.0 KB  |  160 lines

  1. /*
  2.  * exprtree.h
  3.  *
  4.  * MathMap
  5.  *
  6.  * Copyright (C) 1997-2000 Mark Probst
  7.  *
  8.  * This program is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU General Public License
  10.  * as published by the Free Software Foundation; either version 2
  11.  * of the License, or (at your option) any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  * GNU General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with this program; if not, write to the Free Software
  20.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23. #ifndef __EXPRTREE_H__
  24. #define __EXPRTREE_H__
  25.  
  26. #include "vars.h"
  27. #include "builtins.h"
  28. #include "internals.h"
  29. #include "macros.h"
  30.  
  31. #define MAX_IDENT_LENGTH    63
  32.  
  33. typedef char ident[MAX_IDENT_LENGTH + 1];
  34.  
  35. struct _overload_entry_t;
  36. struct _userval_t;
  37.  
  38. typedef struct _exprtree
  39. {
  40.     int type;
  41.     tuple_info_t result;
  42.     int tmpvarnum;
  43.  
  44.     union
  45.     {
  46.     tuple_t tuple_const;
  47.     variable_t *var;
  48.     internal_t *internal;
  49.     struct
  50.     {
  51.         struct _userval_t *userval;
  52.         struct _exprtree *args;
  53.     } userval;
  54.     struct
  55.     {
  56.         int length;
  57.         struct _exprtree *elems;
  58.     } tuple;
  59.     struct
  60.     {
  61.         struct _exprtree *tuple;
  62.         struct _exprtree *subscripts;
  63.     } select;
  64.     struct
  65.     {
  66.         int tagnum;
  67.         struct _exprtree *tuple;
  68.     } cast;
  69.     struct
  70.     {
  71.         int tagnum;
  72.         struct _exprtree *tuple;
  73.     } convert;
  74.     struct
  75.     {
  76.         struct _overload_entry_t *entry;
  77.         struct _exprtree *args;
  78.     } func;
  79.     struct
  80.     {
  81.         struct _exprtree *left;
  82.         struct _exprtree *right;
  83.     } operator;
  84.     struct
  85.     {
  86.         variable_t *var;
  87.         struct _exprtree *value;
  88.     } assignment;
  89.     struct
  90.     {
  91.         variable_t *var;
  92.         struct _exprtree *subscripts;
  93.         struct _exprtree *value;
  94.     } sub_assignment;
  95.     struct
  96.     {
  97.         struct _exprtree *condition;
  98.         struct _exprtree *consequent;
  99.         struct _exprtree *alternative;
  100.         int label1;
  101.         int label2;
  102.     } ifExpr;
  103.     struct
  104.     {
  105.         struct _exprtree *invariant;
  106.         struct _exprtree *body;
  107.         int label1;
  108.         int label2;
  109.     } whileExpr;
  110.     struct
  111.     {
  112.         macro_function_t macro;
  113.         struct _exprtree *args;
  114.     } macro;
  115.     } val;
  116.  
  117.     struct _exprtree *next;
  118. } exprtree;
  119.  
  120. #define EXPR_TUPLE_CONST     1
  121. #define EXPR_FUNC            2
  122. #define EXPR_INTERNAL        3
  123. #define EXPR_SEQUENCE        4
  124. #define EXPR_ASSIGNMENT      5
  125. #define EXPR_VARIABLE        6
  126. #define EXPR_IF_THEN         7
  127. #define EXPR_IF_THEN_ELSE    8
  128. #define EXPR_WHILE           9
  129. #define EXPR_DO_WHILE       10
  130. #define EXPR_TUPLE          11
  131. #define EXPR_SELECT         12
  132. #define EXPR_CAST           13
  133. #define EXPR_CONVERT        14
  134. #define EXPR_SUB_ASSIGNMENT 15
  135. #define EXPR_USERVAL        16
  136.  
  137. exprtree* make_number (float num);
  138. exprtree* make_range (int first, int last);
  139. exprtree* make_var (const char *name); /* should use variable_t instead */
  140. exprtree* make_tuple (exprtree *elems);
  141. exprtree* make_select (exprtree *tuple, exprtree *subscripts);
  142. exprtree* make_cast (const char *tagname, exprtree *tuple); /* should use tag number instead */
  143. exprtree* make_convert (const char *tagname, exprtree *tuple); /* ditto */
  144. exprtree* make_function (const char *name, exprtree *args);
  145. exprtree* make_userval (const char *type, const char *name, exprtree *args);
  146. exprtree* make_sequence (exprtree *left, exprtree *right);
  147. exprtree* make_assignment (char *name, exprtree *value); /* should use variable_t instead */
  148. exprtree* make_sub_assignment (char *name, exprtree *subscripts, exprtree *value);
  149. exprtree* make_if_then (exprtree *condition, exprtree *consequent);
  150. exprtree* make_if_then_else (exprtree *condition, exprtree *consequent, exprtree *alternative);
  151. exprtree* make_while (exprtree *invariant, exprtree *body);
  152. exprtree* make_do_while (exprtree *body, exprtree *invariant);
  153.  
  154. int exprlist_length (exprtree *list);
  155. exprtree* exprlist_append (exprtree *list1, exprtree *list2);
  156.  
  157. double eval_exprtree (exprtree *tree);
  158.  
  159. #endif
  160.