home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / gnusmalltalk / msttree.h < prev    next >
C/C++ Source or Header  |  1992-02-15  |  3KB  |  139 lines

  1. /***********************************************************************
  2.  *
  3.  *    Semantic Tree information declarations.
  4.  *
  5.  ***********************************************************************/
  6.  
  7. /***********************************************************************
  8.  *
  9.  * Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
  10.  * Written by Steve Byrne.
  11.  *
  12.  * This file is part of GNU Smalltalk.
  13.  *
  14.  * GNU Smalltalk is free software; you can redistribute it and/or modify it
  15.  * under the terms of the GNU General Public License as published by the Free
  16.  * Software Foundation; either version 1, or (at your option) any later 
  17.  * version.
  18.  * 
  19.  * GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
  20.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
  21.  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  22.  * more details.
  23.  * 
  24.  * You should have received a copy of the GNU General Public License along with
  25.  * GNU Smalltalk; see the file COPYING.  If not, write to the Free Software
  26.  * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  
  27.  *
  28.  ***********************************************************************/
  29.  
  30.  
  31. /*
  32.  *    Change Log
  33.  * ============================================================================
  34.  * Author      Date       Change 
  35.  * sbyrne    30 Dec 88      Created.
  36.  *
  37.  */
  38.  
  39.  
  40. #ifndef __MSTTREE__
  41. #define __MSTTREE__
  42.  
  43. typedef enum {
  44.   methodNodeType,
  45.   unaryExprType,
  46.   binaryExprType,
  47.   keywordExprType,
  48.   variableNodeType,
  49.   keywordListType,
  50.   variableListType,
  51.   statementListType,
  52.   returnExprType,
  53.   assignExprType,
  54.   constExprType,
  55.   symbolNodeType,
  56.   arrayEltListType,
  57.   blockNodeType,
  58.   cascadedMessageNodeType,
  59.   messageListType,
  60. } NodeType;
  61.  
  62. #undef TreeNode
  63. typedef struct TreeNodeStruct *TreeNode;
  64.  
  65. typedef struct ListNodeStruct {
  66.   char        *name;
  67.   TreeNode     value;
  68.   TreeNode     next;
  69.   TreeNode    *nextAddr;
  70. } ListNode;
  71.  
  72. typedef struct ExprNodeStruct {
  73.   TreeNode    receiver;
  74.   OOP        selector;
  75.   TreeNode    expression;
  76. } ExprNode;
  77.  
  78. typedef enum {
  79.   intConst,
  80.   floatConst,
  81.   charConst,
  82.   stringConst,
  83.   symbolConst,
  84.   arrayConst
  85. } ConstType;
  86.  
  87. typedef struct ConstNodeStruct {
  88.   ConstType    constType;
  89.   union {
  90.     long    iVal;
  91.     double    fVal;
  92.     Byte    cVal;
  93.     char    *sVal;
  94.     OOP        symVal;
  95.     TreeNode    aVal;
  96.   } val;
  97. } ConstNode;
  98.  
  99. typedef struct MethodNodeStruct {
  100.   TreeNode     selectorExpr;
  101.   TreeNode     temporaries;
  102.   int        primitiveIndex;
  103.   TreeNode     statements;
  104. } MethodNode;
  105.  
  106.  
  107. struct TreeNodeStruct {
  108.   NodeType    nodeType;
  109.   union {
  110.     ListNode        nvList;
  111.     ExprNode        nvExpr;
  112.     ConstNode        nvConst;
  113.     MethodNode        nvMethod;
  114.   }         nodeVal;
  115. };
  116.  
  117. #define vList        nodeVal.nvList
  118. #define vExpr        nodeVal.nvExpr
  119. #define vConst        nodeVal.nvConst
  120. #define vMethod        nodeVal.nvMethod
  121.  
  122.  
  123. extern TreeNode        makeMethod(), makeUnaryExpr(), makeBinaryExpr(),
  124.             makeKeywordExpr(), makeVariable(), makeKeywordList(),
  125.             makeVariableList(), makeStatementList(), makeAssign(),
  126.             makeReturn(), makeIntConstant(), makeFloatConstant(),
  127.             makeCharConstant(),makeSymbolConstant(),
  128.             makeStringConstant(), makeArrayConstant(),
  129.             internIdent(), internBinOP(), internKeywordList(),
  130.             makeArrayElt(), makeBlock(), makeCascadedMessage(),
  131.             makeMessageList();
  132.  
  133. extern void        addNode(), freeTree(), printTree();
  134.  
  135. extern Boolean         hadError;
  136.  
  137.  
  138. #endif /* __MSTTREE__ */
  139.