/******************************************************************************
// -*- C -*-  // To make emacs recognize the correct program type.
///////////////////////////////////////////////////////////////////////////////
// Language: SRC3
// Purpose:  
//
// By: Hung-chih Yang
// Initiate date:  DATELL--Tue May  6 14:40:31 2003--DATERL
// Finalized date: DATEFL----DATEFR
// To do List:
// Change List:
// Notes:
// Functionalities should be implemented:
//
///////////////////////////////////////////////////////////////////////////////
******************************************************************************/

#ifndef __SRC3AST_H__
#define __SRC3AST_H__

/*****************************************************************************
 definition of a coomon node data structure
 *****************************************************************************/
typedef struct _CommonAttributes {

} CommonAttributes, *PointerCommonAttributes;

/*****************************************************************************
 *****************************************************************************
 AST STEP 0. To define a data structure for each parsing rule.
 *****************************************************************************
 *****************************************************************************/

/*****************************************************************************
 forward declaration for AST node data structures
 *****************************************************************************/

struct _NODEstartRule;
struct _NODEprogramBody;
struct _NODEprogramHeading;
struct _NODEdeclarationList;
struct _NODEnonEmptyDeclarationList;
struct _NODEdeclaration;
struct _NODEvariableDeclaration;
struct _NODEidsDeclaration;
struct _NODEconstantDeclaration;
struct _NODEidList;
struct _NODEtype;
struct _NODEarrayType;
struct _NODEbasicType;
struct _NODErangeInformation;
struct _NODErange;
struct _NODErangeObject;
struct _NODEsubroutineDeclarationList;
struct _NODEnonEmptySubroutineDeclarationList;
struct _NODEsubroutineDeclaration;
struct _NODEsubroutineHeading;
struct _NODEargumentSet;
struct _NODEreturnDeclaration;
struct _NODEargumentList;
struct _NODEsubroutineBody;
struct _NODEstatementBlock;
struct _NODEstatementBody;
struct _NODEstatementList;
struct _NODEnonEmptyStatementList;
struct _NODEstatement;
struct _NODEexpressionList;
struct _NODEnonEmptyExpressionList;
struct _NODEexpression;
struct _NODEfunctionCall;
struct _NODEoperationObject;
struct _NODEvariable;
struct _NODEliteral;
struct _NODEliteralString;
struct _NODEliteralNumber;
struct _NODEliteralInteger;
struct _NODEliteralReal;

typedef struct _NODEstartRule NODEstartRule;
typedef struct _NODEprogramBody NODEprogramBody;
typedef struct _NODEprogramHeading NODEprogramHeading;
typedef struct _NODEdeclarationList NODEdeclarationList;
typedef struct _NODEnonEmptyDeclarationList NODEnonEmptyDeclarationList;
typedef struct _NODEdeclaration NODEdeclaration;
typedef struct _NODEvariableDeclaration NODEvariableDeclaration;
typedef struct _NODEidsDeclaration NODEidsDeclaration;
typedef struct _NODEconstantDeclaration NODEconstantDeclaration;
typedef struct _NODEidList NODEidList;
typedef struct _NODEtype NODEtype;
typedef struct _NODEarrayType NODEarrayType;
typedef struct _NODEbasicType NODEbasicType;
typedef struct _NODErangeInformation NODErangeInformation;
typedef struct _NODErange NODErange;
typedef struct _NODErangeObject NODErangeObject;
typedef struct _NODEsubroutineDeclarationList NODEsubroutineDeclarationList;
typedef struct _NODEnonEmptySubroutineDeclarationList
                NODEnonEmptySubroutineDeclarationList;
typedef struct _NODEsubroutineDeclaration NODEsubroutineDeclaration;
typedef struct _NODEsubroutineHeading NODEsubroutineHeading;
typedef struct _NODEargumentSet NODEargumentSet;
typedef struct _NODEreturnDeclaration NODEreturnDeclaration;
typedef struct _NODEargumentList NODEargumentList;
typedef struct _NODEsubroutineBody NODEsubroutineBody;
typedef struct _NODEstatementBlock NODEstatementBlock;
typedef struct _NODEstatementBody NODEstatementBody;
typedef struct _NODEstatementList NODEstatementList;
typedef struct _NODEnonEmptyStatementList NODEnonEmptyStatementList;
typedef struct _NODEstatement NODEstatement;
typedef struct _NODEexpressionList NODEexpressionList;
typedef struct _NODEnonEmptyExpressionList NODEnonEmptyExpressionList;
typedef struct _NODEexpression NODEexpression;
typedef struct _NODEfunctionCall NODEfunctionCall;
typedef struct _NODEoperationObject NODEoperationObject;
typedef struct _NODEvariable NODEvariable;
typedef struct _NODEliteral NODEliteral;
typedef struct _NODEliteralString NODEliteralString;
typedef struct _NODEliteralNumber NODEliteralNumber;
typedef struct _NODEliteralInteger NODEliteralInteger;
typedef struct _NODEliteralReal NODEliteralReal;

typedef NODEstartRule* PointerNODEstartRule;
typedef NODEprogramBody* PointerNODEprogramBody;
typedef NODEprogramHeading* PointerNODEprogramHeading;
typedef NODEdeclarationList* PointerNODEdeclarationList;
typedef NODEnonEmptyDeclarationList* PointerNODEnonEmptyDeclarationList;
typedef NODEdeclaration* PointerNODEdeclaration;
typedef NODEvariableDeclaration* PointerNODEvariableDeclaration;
typedef NODEidsDeclaration* PointerNODEidsDeclaration;
typedef NODEconstantDeclaration* PointerNODEconstantDeclaration;
typedef NODEidList* PointerNODEidList;
typedef NODEtype* PointerNODEtype;
typedef NODEarrayType* PointerNODEarrayType;
typedef NODEbasicType* PointerNODEbasicType;
typedef NODErangeInformation* PointerNODErangeInformation;
typedef NODErange* PointerNODErange;
typedef NODErangeObject* PointerNODErangeObject;
typedef NODEsubroutineDeclarationList* PointerNODEsubroutineDeclarationList;
typedef NODEnonEmptySubroutineDeclarationList*
        PointerNODEnonEmptySubroutineDeclarationList;
typedef NODEsubroutineDeclaration* PointerNODEsubroutineDeclaration;
typedef NODEsubroutineHeading* PointerNODEsubroutineHeading;
typedef NODEargumentSet* PointerNODEargumentSet;
typedef NODEreturnDeclaration* PointerNODEreturnDeclaration;
typedef NODEargumentList* PointerNODEargumentList;
typedef NODEsubroutineBody* PointerNODEsubroutineBody;
typedef NODEstatementBlock* PointerNODEstatementBlock;
typedef NODEstatementBody* PointerNODEstatementBody;
typedef NODEstatementList* PointerNODEstatementList;
typedef NODEnonEmptyStatementList* PointerNODEnonEmptyStatementList;
typedef NODEstatement* PointerNODEstatement;
typedef NODEexpressionList* PointerNODEexpressionList;
typedef NODEnonEmptyExpressionList* PointerNODEnonEmptyExpressionList;
typedef NODEexpression* PointerNODEexpression;
typedef NODEfunctionCall* PointerNODEfunctionCall;
typedef NODEoperationObject* PointerNODEoperationObject;
typedef NODEvariable* PointerNODEvariable;
typedef NODEliteral* PointerNODEliteral;
typedef NODEliteralString* PointerNODEliteralString;
typedef NODEliteralNumber* PointerNODEliteralNumber;
typedef NODEliteralInteger* PointerNODEliteralInteger;
typedef NODEliteralReal* PointerNODEliteralReal;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEliteralReal {

  CommonAttributes commonAttributes;

  double literalReal;

} /*NODEliteralReal, *PointerNODEliteralReal*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEliteralInteger {

  CommonAttributes commonAttributes;

  int literalInteger;

} /*NODEliteralInteger, *PointerNODEliteralInteger*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEliteralNumber {

  CommonAttributes commonAttributes;

  PointerNODEliteralInteger pointerLiteralInteger;
  PointerNODEliteralReal pointerLiteralReal;

} /*NODEliteralNumber, *PointerNODEliteralNumber*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEliteralString {

  CommonAttributes commonAttributes;

  char* literalString;

} /*NODEliteralString, *PointerNODEliteralString*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEliteral {

  CommonAttributes commonAttributes;

  PointerNODEliteralString pointerLiteralString;
  PointerNODEliteralNumber pointerLiteralNumber;

} /*NODEliteral, *PointerNODEliteral*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEvariable {

  CommonAttributes commonAttributes;

  char* id;
  PointerNODEnonEmptyExpressionList pointerNonEmptyExpressionList;

} /*NODEvariable, *PointerNODEvariable*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEoperationObject {

  CommonAttributes commonAttributes;

  PointerNODEvariable pointerVariable;
  PointerNODEliteral pointerLiteral;

} /*NODEoperationObject, *PointerNODEoperationObject*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEfunctionCall {

  CommonAttributes commonAttributes;

  PointerNODEexpressionList pointerExpressionList;

} /*NODEfunctionCall, *PointerNODEfunctionCall*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
typedef enum {TYPEandExpression,
              TYPEorExpression,
              TYPEnotExpression,
              TYPEparenthesExpression,
              TYPEgtExpression,
              TYPEgteExpression,
              TYPEltExpression,
              TYPElteExpression,
              TYPEeqExpression,
              TYPEneqExpression,
              TYPEplusExpression,
              TYPEminusExpression,
              TYPEmulExpression,
              TYPEdivExpression,
              TYPEmodExpression,
              TYPEfunctionCallExpression,
              TYPEoperationObjectExpression}
TypeExpression;

/*typedef*/ struct _NODEexpression {

  CommonAttributes commonAttributes;

  TypeExpression typeExpression;
  PointerNODEexpression pointerExpressionFirst;
  PointerNODEexpression pointerExpressionSecond;
  PointerNODEfunctionCall PointerFunctionCall;
  PointerNODEoperationObject PointerOperationObject;

} /*NODEexpression, *PointerNODEexpression*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEnonEmptyExpressionList {

  CommonAttributes commonAttributes;

  PointerNODEexpression pointerExpression;
  PointerNODEnonEmptyExpressionList pointerNonEmptyExpressionList;

} /*NODEnonEmptyExpressionList, *PointerNODEnonEmptyExpressionList*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEexpressionList {

  CommonAttributes commonAttributes;

  PointerNODEnonEmptyExpressionList pointerNonEmptyExpressionList;

} /*NODEexpressionList, *PointerNODEexpressionList*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
typedef enum {TYPEassignStatement,
              TYPEreadStatement,
              TYPEwriteStatement,
              TYPEifStatement,
              TYPEifElseStatement,
              TYPEwhileStatement,
              TYPEreturnStatement,
              TYPEstatementBlockStatement}
TypeStatement;

/*typedef*/ struct _NODEstatement {

  CommonAttributes commonAttributes;

  TypeStatement typeStatement;
  PointerNODEvariable pointerVariable;
  PointerNODEexpression pointerExpression;
  PointerNODEexpressionList pointerExpressionList;
  PointerNODEstatementList pointerStatementList;
  PointerNODEstatementList pointerElseStatementList;
  PointerNODEstatementBlock pointerStatementBlock;

} /*NODEstatement, *PointerNODEstatement*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEnonEmptyStatementList {

  CommonAttributes commonAttributes;

  PointerNODEstatement pointerStatement;
  PointerNODEnonEmptyStatementList pointerNonEmptyStatementList;

} /*NODEnonEmptyStatementList, *PointerNODEnonEmptyStatementList*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEstatementList {

  CommonAttributes commonAttributes;

  PointerNODEnonEmptyStatementList pointerNonEmptyStatementList;

} /*NODEstatementList, *PointerNODEstatementList*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEstatementBody {

  CommonAttributes commonAttributes;

  PointerNODEdeclarationList pointerDeclarationList;
  PointerNODEstatementList pointerStatementList;
  PointerNODEnonEmptySubroutineDeclarationList
    pointerNonEmptySubroutineDeclarationList;

} /*NODEstatementBody, *PointerNODEstatementBody*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEstatementBlock {

  CommonAttributes commonAttributes;

  PointerNODEstatementBody pointerStatementBody;

} /*NODEstatementBlock, *PointerNODEstatementBlock*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEsubroutineBody {

  CommonAttributes commonAttributes;

  PointerNODEstatementBlock pointerStatementBlock;

} /*NODEsubroutineBody, *PointerNODEsubroutineBody*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEargumentList {

  CommonAttributes commonAttributes;

  PointerNODEidsDeclaration pointerIdsDeclaration;
  PointerNODEargumentList pointerArgumentList;

} /*NODEargumentList, *PointerNODEargumentList*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEreturnDeclaration {

  CommonAttributes commonAttributes;
  
  PointerNODEtype pointerType;

} /*NODEreturnDeclaration, *PointerNODEreturnDeclaration*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEargumentSet {

  CommonAttributes commonAttributes;

  PointerNODEargumentList pointerPasByValueArgumentList;
  PointerNODEargumentList pointerPassByReferenceArgumentList;

} /*NODEargumentSet, *PointerNODEargumentSet*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEsubroutineHeading {

  CommonAttributes commonAttributes;

  PointerNODEargumentSet pointerArgumentSet;
  PointerNODEreturnDeclaration pointerReturnDeclaration;

} /*NODEsubroutineHeading, *PointerNODEsubroutineHeading*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEsubroutineDeclaration {

  CommonAttributes commonAttributes;

  PointerNODEsubroutineHeading pointerSubroutineHeading;
  PointerNODEsubroutineBody pointerNODEsubroutineBody;

} /*NODEsubroutineDeclaration, *PointerNODEsubroutineDeclaration*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEnonEmptySubroutineDeclarationList {

  CommonAttributes commonAttributes;

  PointerNODEsubroutineDeclaration pointerSubroutineDeclaration;
  PointerNODEnonEmptySubroutineDeclarationList
    pointerNonEmptySubroutineDeclarationList;

} /*NODEnonEmptySubroutineDeclarationList,
   *PointerNODEnonEmptySubroutineDeclarationList*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEsubroutineDeclarationList {

  CommonAttributes commonAttributes;

  PointerNODEnonEmptySubroutineDeclarationList
    pointerNonEmptySubroutineDeclarationList;

} /*NODEsubroutineDeclarationList, *PointerNODEsubroutineDeclarationList*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
typedef enum {TYPEidRangeObject,
              TYPEliteralIntegerRangeObject}
TypeRangeObject;

/*typedef*/ struct _NODErangeObject {

  CommonAttributes commonAttributes;

  TypeRangeObject typeRangeObject;
  char* id;
  PointerNODEliteralInteger pointerLiteralInteger;

} /*NODErangeObject, *PointerNODErangeObject*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODErange {

  CommonAttributes commonAttributes;

  PointerNODErangeObject pointerRangeObjectFirst;
  PointerNODErangeObject pointerRangeObjectSecond;

} /*NODErange, *PointerNODErange*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODErangeInformation {

  CommonAttributes commonAttributes;

  PointerNODErange pointerRange;
  /*PointerNODErangeInformation pointerRangeInformation;*/
  struct _NODErangeInformation* pointerRangeInformation;

} /*NODErangeInformation, *PointerNODErangeInformation*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
typedef enum {TYPEintBasicType,
              TYPErealBasicType,
              TYPEstringBasicType,
              TYPEboolBasicType}
TypeBasicType;

/*typedef*/ struct _NODEbasicType {

  CommonAttributes commonAttributes;

  TypeBasicType typeBasicType;
  
} /*NODEbasicType, *PointerNODEbasicType*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEarrayType {

  CommonAttributes commonAttributes;
  
  PointerNODErangeInformation pointerRangeInformation;
  PointerNODEbasicType pointerBasicType;

} /*NODEarrayType, *PointerNODEarrayType*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
typedef enum {TYPEarrayType,
              TYPEbasicType}
TypeType;

/*typedef*/ struct _NODEtype {

  CommonAttributes commonAttributes;

  TypeType typeType;
  PointerNODEarrayType pointerArrayType;
  PointerNODEbasicType pointerBasicType;
  
} /*NODEtype, *PointerNODEtype*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEidList {

  CommonAttributes commonAttributes;

  char* id;
  PointerNODEidList pointerIdList;

} /*NODEidList, *PointerNODEidList*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
typedef enum {TYPEliteralConstantDeclaration,
              TYPEidConstantDeclaration}
TypeConstantDeclaration;

/*typedef*/ struct _NODEconstantDeclaration {

  CommonAttributes commonAttributes;

  TypeConstantDeclaration typeConstantDeclaration;
  PointerNODEidList pointerIdList;
  PointerNODEliteral pointerLiteral;
  char* id;

} /*NODEconstantDeclaration, *PointerNODEconstantDeclaration*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEidsDeclaration {

  CommonAttributes commonAttributes;

  PointerNODEidList pointerIdList;
  PointerNODEtype pointerType;

} /*NODEidsDeclaration, *PointerNODEidsDeclaration*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEvariableDeclaration {

  CommonAttributes commonAttributes;

  PointerNODEidsDeclaration pointerIdsDeclaration;

} /*NODEvariableDeclaration, *PointerNODEvariableDeclaration*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
typedef enum {TYPEvariableDeclaration,
              TYPEconstantDeclaration}
TypeDeclaration;

/*typedef*/ struct _NODEdeclaration {

  CommonAttributes commonAttributes;

  TypeDeclaration typeDeclaration;
  PointerNODEvariableDeclaration pointerVariableDeclaration;
  PointerNODEconstantDeclaration pointerConstantDeclaration;

} /*NODEdeclaration, *PointerNODEdeclaration*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEnonEmptyDeclarationList {

  CommonAttributes commonAttributes;

  PointerNODEdeclaration pointerDeclaration;
  PointerNODEnonEmptyDeclarationList pointerNonEmptyDeclarationList;

} /*NODEnonEmptyDeclarationList, *PointerNODEnonEmptyDeclarationList*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEdeclarationList {

  CommonAttributes commonAttributes;

  PointerNODEnonEmptyDeclarationList pointerNonEmptyDeclarationList;

} /*NODEdeclarationList, *PointerNODEdeclarationList*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEprogramHeading {

  CommonAttributes commonAttributes;

  char* programID;

} /*NODEprogramHeading, *PointerNODEprogramHeading*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEprogramBody {

  CommonAttributes commonAttributes;

  PointerNODEdeclarationList pointerDeclarationList;
  PointerNODEsubroutineDeclarationList pointerSubroutineDeclarationList;
  PointerNODEstatementBlock pointerStatementBlock;

} /*NODEprogramBody, *PointerNODEprogramBody*/;

/*****************************************************************************
 definition of a node data structure
 *****************************************************************************/
/*typedef*/ struct _NODEstartRule {

  CommonAttributes commonAttributes;

  char* programID;
  PointerNODEprogramHeading pointerProgramHeading;
  PointerNODEprogramBody pointerProgramBody;

} /*NODEstartRule, *PointerNODEstartRule*/;

/*****************************************************************************
 *****************************************************************************
 AST STEP 0. To define a data structure for each parsing rule.
 *****************************************************************************
 *****************************************************************************/

#endif /* #define __SRC3AST_H__ */
