home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / IRIT / POLY3DS.ZIP / PARSER.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-05  |  4.1 KB  |  132 lines

  1. /*****************************************************************************
  2. * General definitions of the Praser module goes into here:             *
  3. *****************************************************************************/
  4.  
  5. #ifndef PARSER_H
  6. #define PARSER_H
  7.  
  8. #ifndef LINE_LEN
  9. #define LINE_LEN    255
  10. #endif  LINE_LEN
  11.  
  12. #define NAME_LEN    6
  13.  
  14. #ifndef TRUE
  15. #define TRUE        1
  16. #define FALSE        0
  17. #endif
  18.  
  19. #ifndef NULL
  20. #define NULL        0
  21. #endif
  22.  
  23. #define FILE_TYPE_DATA    1
  24. #define FILE_TYPE_VIEW    2
  25.  
  26. #define    UNGET_STACK_SIZE    5
  27.  
  28. /*****************************************************************************
  29. * Tokens definitions goes into here                                          *
  30. *****************************************************************************/
  31. #define TOKEN_OPEN_PAREN    1
  32. #define TOKEN_CLOSE_PAREN    2
  33.  
  34. #define TOKEN_NUMBER        10 /* Not used as number & names are decoded */
  35.                     /* according to their places in grammer. */
  36.  
  37. #define TOKEN_VERTEX    20
  38. #define TOKEN_POLYGON    21
  39. #define TOKEN_POLYLINE    22
  40. #define TOKEN_POINTLIST    23
  41. #define TOKEN_OBJECT    24
  42. #define TOKEN_COLOR    25
  43. #define TOKEN_INTERNAL    26
  44. #define TOKEN_NORMAL    27
  45. #define TOKEN_PLANE    28
  46.  
  47. #define TOKEN_OTHER    100            /* Probably names & numbers. */
  48. #define TOKEN_EOF    -1
  49.  
  50. #define VERTEX_ENTRY    0x0001              /* Entry type, up to 16 types. */
  51. #define POLYGON_ENTRY    0x0002
  52. #define POLYLINE_ENTRY    0x0004
  53. #define OBJECT_ENTRY    0x0008
  54. #define COLOR_ENTRY    0x0010
  55.  
  56. #define POLYGON        1
  57. #define POLYLINE    2
  58. #define POINTLIST    3
  59.  
  60. /*****************************************************************************
  61. * Parser error codes are following:                                          *
  62. *****************************************************************************/
  63. #define P_ERR_NumberExpected    1
  64. #define P_ERR_CloseParanExpected 2
  65. #define P_ERR_ListCompUndef    3
  66. #define P_ERR_UndefExprHeader    4
  67. #define P_ERR_NameTooLong    5
  68.  
  69. #define P_WRN_ObjectNameTrunc    100
  70.  
  71. /*****************************************************************************
  72. * And some more definitions ...                                              *
  73. *****************************************************************************/
  74.  
  75. typedef unsigned char Byte;
  76.  
  77. typedef struct BinTree {       /* The entries are saved as binary trees. */
  78.     struct BinTree *right, *left;              /* Classic, isnt it !? */
  79.     union {
  80.     VoidPtr              PVoid;
  81.         struct VertexStruct  *PVertex;
  82.         struct PolygonStruct *PPolygon;
  83.         struct ObjectStruct  *PObject;
  84.     } Data;
  85.     char Name[NAME_LEN];
  86.     Byte EntryType;                /* Kind of pointer in union. */
  87.     Byte Used;         /* TRUE if allready has been used (multi - referenced). */
  88. } BinTree;
  89.  
  90. typedef struct FileDescription {  /* Each data file loaded gets such struct. */
  91.     BinTree *VertexPointer,            /* Pointers on the binary trees ...  */
  92.         *PolygonPointer,
  93.         *ObjectPointer;
  94. } FileDescription;
  95.  
  96. /* Use the following structure if linear list operations are to be performed */
  97. /* on VertexStruct/PolygonStruct/ObjectStruct (Virtual functions...).         */
  98. typedef struct LinearListStruct {
  99.     struct LinearListStruct *Pnext;
  100. } LinearListStruct;
  101.  
  102. typedef struct VertexStruct {
  103.     struct VertexStruct *Pnext;
  104.     float Coord[3];                       /* The 3D coords. */
  105.     float Normal[3];                       /* The 3D normal. */
  106.     Byte Transform;
  107.     Byte Internal;               /* If edge is Internal (IRIT output). */
  108.     Byte HasNormal;                /* If edge has a normal defined. */
  109. } VertexStruct;
  110.  
  111. typedef struct PolygonStruct {
  112.     struct PolygonStruct *Pnext;
  113.     VertexStruct *PVertex;                /* The polygon vertices. */
  114.     float Plane[4];                  /* The Polygon plane equation. */
  115.     Byte PolyType;             /* One of POLYGON, POLYLINE, POINTLIST. */
  116.     Byte HasPlane;              /* If polygon has a plane defined. */
  117. } PolygonStruct;
  118.  
  119. typedef struct ObjectStruct {
  120.     struct ObjectStruct *Pnext;
  121.     PolygonStruct *PPolygon;                /* The objects polygons. */
  122.     int Color;
  123. } ObjectStruct;
  124.  
  125. /* And function prototypes: */
  126.  
  127. FileDescription *GetDataFile(FILE *f);
  128. void GetViewFile(FILE *f, int FileExists);
  129. BinTree *GetBinTree(char *RecName, BinTree *Tree);
  130.  
  131. #endif PARSER_H
  132.