home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Graphics / graphics-16000.iso / msdos / raytrace / rayshade / src / yacc.y < prev   
Text File  |  1992-04-30  |  31KB  |  1,490 lines

  1. /* yacc.y                                   */
  2. /*                                       */
  3. /* Copyright (C) 1989, 1991, Craig E. Kolb                   */
  4. /* All rights reserved.                               */
  5. /*                                       */
  6. /* This software may be freely copied, modified, and redistributed,       */
  7. /* provided that this copyright notice is preserved on all copies.       */
  8. /*                                       */
  9. /* You may not distribute this software, in whole or in part, as part of   */
  10. /* any commercial product without the express consent of the authors.       */
  11. /*                                        */
  12. /* There is no warranty or other guarantee of fitness of this software       */
  13. /* for any purpose.  It is provided solely "as is".               */
  14. /* $Id: yacc.y,v 4.0.1.4 92/01/10 16:29:55 cek Exp Locker: cek $ */
  15. %{
  16. #include "rayshade.h"
  17.  
  18. #include "symtab.h"
  19. #include "builtin.h"
  20.  
  21. #include "atmosphere.h"
  22. #include "surface.h"
  23. #include "texture.h"
  24. #include "image.h"
  25. #include "geom.h"
  26. #include "light.h"
  27. #include "options.h"
  28. #include "stats.h"
  29. #include "viewing.h"
  30.  
  31. #include "blob.h"
  32. #include "box.h"
  33. #include "cone.h"
  34. #include "csg.h"
  35. #include "cylinder.h"
  36. #include "disc.h"
  37. #include "grid.h"
  38. #include "hf.h"
  39. #include "instance.h"
  40. #include "list.h"
  41. #include "plane.h"
  42. #include "poly.h"
  43. #include "sphere.h"
  44. #include "torus.h"
  45. #include "triangle.h"
  46.  
  47. #include "point.h"
  48. #include "infinite.h"
  49. #include "spot.h"
  50. #include "jittered.h"
  51. #include "extended.h"
  52.  
  53. #include "blotch.h"
  54. #include "bump.h"
  55. #include "checker.h"
  56. #include "cloud.h"
  57. #include "fbm.h"
  58. #include "fbmbump.h"
  59. #include "gloss.h"
  60. #include "imagetext.h"
  61. #include "marble.h"
  62. #include "mount.h"
  63. #include "sky.h"
  64. #include "stripe.h"
  65. #include "windy.h"
  66. #include "wood.h"
  67.  
  68. #include "fog.h"
  69. #include "fogdeck.h"
  70. #include "mist.h"
  71.  
  72. #include "rotate.h"
  73. #include "scale.h"
  74. #include "translate.h"
  75. #include "xform.h"
  76.  
  77. Geom *NewAggregate();
  78. char yyfilename[BUFSIZ];            /* Input filename */
  79. GeomList *Defstack;                /* Geom definition stack. */
  80. int Npoints = 0;                /* # of points in Polypoints */
  81. Surface *tmpsurf;                /* Working surface */
  82. SurfList *CurSurf;
  83. Texture *CurText;                /* Working list of textures */
  84. ImageText *Imagetext;                /* Working image texture */
  85. Trans *TransHead, *TransTail;            /* Linked list of current transformations */
  86. Atmosphere *CurEffect = (Atmosphere *)NULL;    /* Current atmos. effects */
  87. PointList *Polypoints;                /* List of vertices */
  88. MetaList *Metapoints, *Metapoint;
  89. extern FILE *yyin;                /* input file pointer */
  90. int yylineno;                /* Current line # in file */
  91. extern Atmosphere *AtmosEffects;        /* atmospheric effects */
  92. extern Medium TopMedium;            /* "air" */
  93. extern void    GeomAddToDefined(),
  94.         LightAddToDefined(),
  95.         SurfaceAddToDefined();
  96. extern Surface    *SurfaceGetNamed();
  97. extern Geom     *GeomGetNamed();
  98.  
  99. /*
  100.  * Issue error message containing filename and line number, and exit.
  101.  */
  102. /*VARARGS1*/
  103. yyerror(s, pat1, pat2)
  104. char *s, *pat1, *pat2;
  105. {
  106.     fprintf(stderr,"%s: Error: %s: line %d: ", Options.progname,
  107.             yyfilename, yylineno);
  108.     fprintf(stderr, s, pat1, pat2);
  109.     if (*s && s[strlen(s) -1] != '\n')
  110.         /* YACC doesn't put newlines on error messages. */
  111.         fprintf(stderr,"\n");
  112.     fflush(stderr);
  113.     exit(1);
  114. }
  115.  
  116. %}
  117. %union {
  118.     char *c;
  119.     int i;
  120.     Float d;
  121.     Vector v;
  122.     Vec2d uv;
  123.     Color col;
  124.     Atmosphere *atmos;
  125.     Light *light;
  126.     Surface *surf;
  127.     Geom *obj;
  128.     Texture *text;
  129.     Mapping *map;
  130.     Trans *trans;
  131.     Expr *e;
  132.     SymtabEntry *sym;
  133. }
  134. %token <d> tFLOAT
  135. %token <c> tSTRING tFILENAME
  136. %token tAPERTURE tAPPLYSURF
  137. %token tBACKGROUND tBLOB tBLOTCH tBOX tBUMP tCONE tCYL tDIRECTIONAL tCURSURF
  138. %token tEXTENDED tEYEP tFBM tFBMBUMP tFOCALDIST tFOG tFOGDECK tFOV tGLOSS tGRID
  139. %token tHEIGHTFIELD tLIGHT tLIST tLOOKP tMARBLE tMAXDEPTH tMIST
  140. %token tJITTER tNOJITTER tDEFINE
  141. %token tOBJECT tOUTFILE  tSKY tDISC tDIFFERENCE tUNION tINTERSECT
  142. %token tPLANE tPOINT tPOLY tROTATE tSPOT tPRINT
  143. %token tSCALE tSCREEN tSPHERE tSURFACE
  144. %token tTHRESH tTRANSLATE tTRANSFORM tTRIANGLE tTRIANGLEUV tUP tEND
  145. %token tTEXTURE tCHECKER tWOOD tCONTRAST tCUTOFF tCLOUD
  146. %token tAMBIENT tDIFFUSE tREFLECT tTRANSP tSPECULAR tSPECPOW
  147. %token tINDEX tATMOSPHERE tNOSHADOW tAREA tTRANSLU tTORUS
  148. %token tEYESEP tSHADOWTRANSP tREPORT tVERBOSE tQUIET tWINDOW tCROP tSTRIPE
  149. %token tMAP tUV tSPHERICAL tCYLINDRICAL tPLANAR
  150. %token tIMAGE tSMOOTH tCOMPONENT tTEXTSURF tRANGE tTILE tSTARTTIME tFRAMELENGTH
  151. %token tNAME tFILTER tGAUSS tBODY tSAMPLE tEXTINCT tWINDY tMOUNT
  152. %token tSHUTTER tFRAMES
  153. %type <c> Filename
  154. %type <e> AnimExpr MExpr ParenExpr
  155. %type <d> Expr Float
  156. %type <v> Vector
  157. %type <uv> Vec2d
  158. %type <col> Color Intensity Lightdef
  159. %type <text> Texturetype
  160. %type <i> SurfCompName IExpr CombineOp
  161. %type <atmos> EffectType
  162. %type <light> LightType
  163. %type <obj> PrimType Primitive TransTextObj
  164. %type <obj> Csg Aggregate Object TransObj ObjType
  165. %type <obj> Blob Box Cone Cylinder Disc HeightField Plane Poly
  166. %type <obj> Sphere Triangle Torus AggregateType List Grid AggregateCreate
  167. %type <obj> NamedObject
  168. %type <surf> Surface OptSurface NamedSurf
  169. %type <surf> SurfSpec ModifyNamedSurf
  170. %type <map> Mapping MapMethod OptMapping
  171. %type <trans> TransformType
  172. %type <sym> Symtabent
  173.  
  174. %left '+' '-'
  175. %left '*' '/' '%'
  176. %left UMINUS
  177. %right '^'
  178. %%
  179. Items        : /* empty */
  180.         | Items Item
  181.         ;
  182. Item        : Eyep
  183.         | Lookp
  184.         | Up
  185.         | Fov
  186.         | Screen
  187.         | Window
  188.         | Crop
  189.         | Report
  190.         | Aperture
  191.         | Focaldist
  192.         | Eyesep
  193.         | Maxdepth
  194.         | Sample
  195.         | Filter
  196.         | Contrast
  197.         | Cutoff
  198.         | Background
  199.         | Shadowtransp
  200.         | Light
  201.         | SurfDef
  202.         | CurSurf
  203.         | Outfile
  204.         | Instance
  205.         | NameObject
  206.         | GlobalEffects
  207.         | Define
  208.         | Frames
  209.         | Starttime
  210.         | Shutter
  211.         | Framelength
  212.             | Print
  213.         ;
  214. Instance    : TransTextObj
  215.         {
  216.             if ($1) {
  217.                 /*
  218.                  * Add instance to current object.
  219.                  */
  220.                 $1->next = Defstack->obj->next;
  221.                 Defstack->obj->next = $1;
  222.             }
  223.         }
  224. TransTextObj    : TransObj Textures
  225.         {
  226.             if ($$ && CurText) {
  227.                 $$->texture = TextAppend(CurText, $$->texture);
  228.             }
  229.             CurText = (Texture *)NULL;
  230.         }
  231.         ;    
  232. TransObj    : Object Transforms
  233.         {
  234.             $$ = $1;
  235.             if ($$ != (Geom *)NULL) {
  236.                 if (TransHead) {
  237.                     $$->trans = TransHead;
  238.                     $$->transtail = TransTail;
  239.                     /*
  240.                      * We compose non-animated tranformation lists,
  241.                      * so we're only animated if it's one long,
  242.                      * or it's animated itself.
  243.                      */
  244.                     if ($$->trans->assoc || $$->trans->next)
  245.                         /* geometry is animated...*/
  246.                         $$->animtrans = TRUE;
  247.                 }
  248.             }
  249.         }
  250.         ;
  251. Object        : ObjType
  252.         {
  253.             if ($$)
  254.                 StatsAddRep($$);
  255.         }
  256.         | NamedObject
  257.         ;
  258. ObjType        : Primitive
  259.         | Aggregate
  260.         ;
  261. Primitive    : PrimType
  262.         {
  263.             if ($$)
  264.                 $$->prims = 1;    /* one primitive */
  265.         }
  266.         ;
  267. PrimType    : Plane
  268.         | Sphere
  269.         | Box
  270.         | Triangle
  271.         | Cylinder
  272.         | Cone
  273.         | Poly
  274.         | HeightField
  275.         | Disc
  276.         | Torus
  277.         | Blob
  278.         ;
  279. NameObject    : tNAME tSTRING TransTextObj
  280.         {
  281.             if ($3) {
  282.                 $3->name = $2;
  283.                 GeomAddToDefined($3);
  284.             }
  285.         };
  286. Aggdefs        : Aggdefs Aggdef
  287.         |
  288.         ;
  289. Aggdef        : Instance
  290.         | SurfDef
  291.         | CurSurf
  292.         | NameObject
  293.         ;
  294. Textures    : Textures Texture
  295.         |
  296.         ;
  297. Texture        : tTEXTURE Texturetype Transforms
  298.         {
  299.             if ($2 != (Texture *)NULL) {
  300.                 /*
  301.                  * Set transformation information.
  302.                  */
  303.                 if (TransHead) {
  304.                     $2->trans = TransHead;
  305.                     /*
  306.                      * We compose non-animated tranformation lists,
  307.                      * so we're only animated if it's one long,
  308.                      * or it's animated itself.
  309.                      */
  310.                     if ($2->trans->assoc || $2->trans->next)
  311.                         /* texture transformation is animated...*/
  312.                         $2->animtrans = TRUE;
  313.                 }
  314.                 /*
  315.                  * Walk to the end of list of textures and
  316.                  * append new texture.  This is done so that
  317.                  * textures are applied in the expected order.
  318.                  */
  319.                 CurText = TextAppend($2, CurText);
  320.             }
  321.         }
  322.         ;
  323. Texturetype    : tCHECKER Surface
  324.         {
  325.             $$ = TextCheckerCreate($2);
  326.         }
  327.         | tBLOTCH Expr Surface
  328.         {
  329.             $$ = TextBlotchCreate($2, $3);
  330.         }
  331.         | tBUMP Expr
  332.         {
  333.             $$ = TextBumpCreate($2);
  334.         }
  335.         | tMARBLE
  336.         {
  337.             $$ = TextMarbleCreate((char *)NULL);
  338.         }
  339.         | tMARBLE Filename
  340.         {
  341.             $$ = TextMarbleCreate($2);
  342.         }
  343.         | tFBM Expr Expr Expr Expr IExpr Expr
  344.         {
  345.             $$ = TextFBmCreate($2, $3, $4, $5, $6, $7,
  346.                         (char *)NULL);
  347.         }
  348.         | tFBM Expr Expr Expr Expr IExpr Expr Filename
  349.         {
  350.             $$ = TextFBmCreate($2, $3, $4, $5, $6, $7, $8);
  351.         }
  352.         | tFBMBUMP Expr Expr Expr Expr IExpr 
  353.         {
  354.             $$ = TextFBmBumpCreate($2, $3, $4, $5, $6);
  355.         }
  356.         | tWOOD
  357.         {
  358.             $$ = TextWoodCreate();
  359.         }
  360.         | tGLOSS Expr 
  361.         {
  362.             $$ = TextGlossCreate($2);
  363.         }
  364.         | tCLOUD Expr Expr Expr IExpr Expr Expr Expr
  365.         {
  366.             $$ = TextCloudCreate($2, $3, $4, $5, $6, $7, $8);
  367.         }
  368.         | tSKY Expr Expr Expr IExpr Expr Expr
  369.         {
  370.             $$ = TextSkyCreate($2, $3, $4, $5, $6, $7);
  371.         }
  372.         | ImageText
  373.         {
  374.             /*
  375.              * Image texturing has so many options
  376.              * that specification is keyword-based.
  377.              */
  378.             if (Imagetext->image == (Image *)NULL)
  379.                 $$ = (Texture *)NULL;
  380.             else
  381.                 $$ = TextCreate(Imagetext, ImageTextApply);
  382.             Imagetext = (ImageText *)NULL;
  383.         }
  384.         | tSTRIPE Surface Expr Expr OptMapping
  385.         {
  386.             $$ = TextStripeCreate($2, $3, $4, $5);
  387.         }
  388.         | tWINDY Expr Expr Expr Expr IExpr Expr Expr Expr
  389.         {
  390.             $$ = TextWindyCreate($2, $3, $4, $5, $6, $7, $8, $9);
  391.         }
  392.         | tMOUNT Filename Expr Expr
  393.         {
  394.             $$ = TextMountCreate($2, $3, $4);
  395.         }
  396.         ;
  397. ImageText    : ImageTextType ImageTextOptions
  398.         ;
  399. ImageTextType    : tIMAGE Filename
  400.         {
  401.             Imagetext = ImageTextCreate($2);
  402.         }
  403.         ;
  404. ImageTextOptions: ImageTextOptions ImageTextOption
  405.         | /* EMPTY */
  406.         ;
  407. ImageTextOption: tCOMPONENT SurfCompName
  408.         {
  409.             /* set texture to modify given component */    
  410.             ImageTextSetComponent(Imagetext, $2);
  411.         }
  412.         | tTILE Expr Expr
  413.         {
  414.             Imagetext->tileu = $2;
  415.             Imagetext->tilev = $3;
  416.         }
  417.         | tTEXTSURF Surface
  418.         {
  419.             Imagetext->surf = $2;
  420.         }
  421.         | tRANGE Expr Expr
  422.         {
  423.             Imagetext->hi = $2;
  424.             Imagetext->lo = $3;
  425.         }
  426.         | tSMOOTH
  427.         {
  428.             Imagetext->smooth = TRUE;
  429.         }
  430.         | Mapping
  431.         {
  432.             Imagetext->mapping = $1;
  433.         };
  434. NamedObject    : tOBJECT Surface tSTRING
  435.         {
  436.             Geom *otmp;
  437.             /*
  438.              * Create an instance of the named object.
  439.              */
  440.             otmp = GeomGetNamed($3);
  441.             if (otmp == (Geom *)NULL)
  442.                 RLerror(RL_PANIC,
  443.                   "There is no object named \"%s\".", $3,"","");
  444.             $$ = GeomInstanceCreate(otmp);
  445.             $$->surf = $2;
  446.             $$->prims = otmp->prims;
  447.         }
  448.         | tOBJECT tSTRING
  449.         {
  450.             Geom *otmp;
  451.  
  452.             otmp = GeomGetNamed($2);
  453.             if (otmp == (Geom *)NULL)
  454.                 RLerror(RL_PANIC,
  455.                   "There is no object named \"%s\".", $2,"","");
  456.             $$ = GeomInstanceCreate(otmp);
  457.             $$->surf = CurSurf->surf;
  458.             $$->prims = otmp->prims;
  459.         };
  460. Transforms    : Transforms PostTransform
  461.         | /* empty */
  462.         {
  463.             TransHead = TransTail = (Trans *)NULL;
  464.         };
  465. PostTransform    : TransformType
  466.         {
  467.             if (TransHead == (Trans *)NULL) {
  468.                 /* we're the list, head and tail */
  469.                 TransHead = TransTail = $1;
  470.             } else {
  471.                 if ($1->animated || TransTail->animated) {
  472.                     /* new tail */
  473.                     $1->prev = TransTail;
  474.                     TransTail->next = $1;
  475.                     TransTail = $1;
  476.                 } else {
  477.                     /* collapse with tail */
  478.                     TransCompose(TransTail, $1, TransTail);
  479.                     TransFree($1);
  480.                 }
  481.             }
  482.         }
  483.         ;
  484. TransformType    : tSCALE AnimExpr AnimExpr AnimExpr
  485.         {
  486.             $$ = TransScaleCreate();
  487.             TransScaleSetX($$, $2);
  488.             TransScaleSetY($$, $3);
  489.             TransScaleSetZ($$, $4);
  490.             if (!$$->animated)
  491.                 TransPropagate($$);
  492.                 
  493.         }
  494.         | tTRANSLATE AnimExpr AnimExpr AnimExpr
  495.         {
  496.             $$ = TransTranslateCreate();
  497.             TransTranslateSetX($$, $2);
  498.             TransTranslateSetY($$, $3);
  499.             TransTranslateSetZ($$, $4);
  500.             if (!$$->animated)
  501.                 TransPropagate($$);
  502.         }
  503.         | tROTATE AnimExpr AnimExpr AnimExpr AnimExpr
  504.         {
  505.             $$ = TransRotateCreate();
  506.             TransRotateSetX($$, $2);
  507.             TransRotateSetY($$, $3);
  508.             TransRotateSetZ($$, $4);
  509.             TransRotateSetTheta($$, $5);
  510.             if (!$$->animated)
  511.                 TransPropagate($$);
  512.         }
  513.         | tTRANSFORM    AnimExpr AnimExpr AnimExpr
  514.                 AnimExpr AnimExpr AnimExpr
  515.                 AnimExpr AnimExpr AnimExpr
  516.         {
  517.             $$ = TransXformCreate();
  518.             TransXformSetX0($$, $2);
  519.             TransXformSetY0($$, $3);
  520.             TransXformSetZ0($$, $4);
  521.             TransXformSetX1($$, $5);
  522.             TransXformSetY1($$, $6);
  523.             TransXformSetZ1($$, $7);
  524.             TransXformSetX2($$, $8);
  525.             TransXformSetY2($$, $9);
  526.             TransXformSetZ2($$, $10);
  527.             if (!$$->animated)
  528.                 TransPropagate($$);
  529.         }
  530.         | tTRANSFORM    AnimExpr AnimExpr AnimExpr
  531.                 AnimExpr AnimExpr AnimExpr
  532.                 AnimExpr AnimExpr AnimExpr
  533.                 AnimExpr AnimExpr AnimExpr
  534.         {
  535.             $$ = TransXformCreate();
  536.             TransXformSetX0($$, $2);
  537.             TransXformSetY0($$, $3);
  538.             TransXformSetZ0($$, $4);
  539.             TransXformSetX1($$, $5);
  540.             TransXformSetY1($$, $6);
  541.             TransXformSetZ1($$, $7);
  542.             TransXformSetX2($$, $8);
  543.             TransXformSetY2($$, $9);
  544.             TransXformSetZ2($$, $10);
  545.             TransXformSetXt($$, $11);
  546.             TransXformSetYt($$, $12);
  547.             TransXformSetZt($$, $13);
  548.             if (!$$->animated)
  549.                 TransPropagate($$);
  550.         };
  551. Eyep        : tEYEP Vector Transforms
  552.         {
  553.             Camera.pos = $2;
  554.             /*
  555.              * Eye can be transformed...
  556.             if (CurMatrix) {
  557.                 PointTransform(&Camera.pos, CurMatrix);
  558.                 free((voidstar)CurMatrix);
  559.                 CurMatrix = (Matrix*)NULL;
  560.             }
  561.              */
  562.         }
  563.         ;
  564. Lookp        : tLOOKP Vector
  565.         {
  566.             Camera.lookp = $2;
  567.         }
  568.         ;
  569. Up        : tUP Vector
  570.         {
  571.             Camera.up = $2;
  572.         }
  573.         ;
  574. Fov        : tFOV Expr Expr
  575.         {
  576.             Camera.hfov = $2;
  577.             Camera.vfov = $3;
  578.         }
  579.         | tFOV Expr
  580.         {
  581.             Camera.hfov = $2;
  582.             Camera.vfov = UNSET;
  583.         }
  584.         ;
  585. Sample        : tSAMPLE IExpr tJITTER
  586.         {
  587.             if (!Options.samples_set)
  588.                 Options.samples = $2;
  589.             if (!Options.jitter_set)
  590.                 Options.jitter = TRUE;
  591.         }
  592.         | tSAMPLE IExpr tNOJITTER
  593.         {
  594.             if (!Options.samples_set)
  595.                 Options.samples = $2;
  596.             if (!Options.jitter_set)
  597.                 Options.jitter = FALSE;
  598.         }
  599.         | tSAMPLE IExpr
  600.         {
  601.             if (!Options.samples_set)
  602.                 Options.samples = $2;
  603.         }
  604.         ;
  605. Filter        : tFILTER tBOX Expr
  606.         {
  607.             Options.gaussian = FALSE;
  608.             Options.filterwidth = $3;
  609.         }
  610.         | tFILTER tBOX
  611.         {
  612.             Options.gaussian = FALSE;
  613.         }    
  614.         | tFILTER tGAUSS Expr
  615.         {
  616.             Options.gaussian = TRUE;
  617.             Options.filterwidth = $3;
  618.         }
  619.         | tFILTER tGAUSS
  620.         {
  621.             Options.gaussian = TRUE;
  622.         };
  623. Starttime    : tSTARTTIME Expr
  624.         {
  625.             Options.starttime = $2;
  626.         };
  627. Frames        : tFRAMES IExpr
  628.         {
  629.             if (!Options.totalframes_set)
  630.                 Options.totalframes = $2;
  631.         };
  632. Framelength    : tFRAMELENGTH Expr
  633.         {
  634.             Options.framelength = $2;
  635.         };
  636. Shutter        : tSHUTTER Expr
  637.         {
  638.             Options.shutterspeed = $2;
  639.         };
  640. Contrast    : tCONTRAST Expr Expr Expr
  641.         {
  642.             if (!Options.contrast_set) {
  643.                 Options.contrast.r = $2;
  644.                 Options.contrast.g = $3;
  645.                 Options.contrast.b = $4;
  646.             }
  647.         }
  648.         ;
  649. Cutoff        : tCUTOFF Intensity
  650.         {
  651.             if (!Options.cutoff_set)
  652.                 Options.cutoff = $2;
  653.         }
  654.         ;
  655. Screen        : tSCREEN IExpr IExpr 
  656.         {
  657.             if (!Options.resolution_set) {
  658.                 Screen.xres = $2;
  659.                 Screen.yres = $3;
  660.             }
  661.         }
  662.         ;
  663. Window        : tWINDOW IExpr IExpr IExpr IExpr
  664.         {
  665.             if (!Options.window_set) {
  666.                 Options.window[LOW][X] = $2;
  667.                 Options.window[HIGH][X] = $3;
  668.                 Options.window[LOW][Y] = $4;
  669.                 Options.window[HIGH][Y] = $5;
  670.                 /*
  671.                  * We must let ViewingSetup know
  672.                  * that a window has been defined.
  673.                  */
  674.                 Options.window_set = TRUE;
  675.             }
  676.         }
  677.         ;
  678. Crop        : tCROP Expr Expr Expr Expr
  679.         {
  680.             if (!Options.crop_set) {
  681.                 Options.crop[LOW][X] = $2;
  682.                 Options.crop[HIGH][X] = $3;
  683.                 Options.crop[LOW][Y] = $4;
  684.                 Options.crop[HIGH][Y] = $5;
  685.             }
  686.         }
  687.         ;
  688. Report        : tREPORT Verbose Quiet IExpr Filename
  689.         {
  690.             if (!Options.freq_set)
  691.                 Options.report_freq = $4;
  692.             if (Options.statsname == (char *)NULL)
  693.                 Options.statsname = strsave($5);
  694.         }
  695.         | tREPORT Verbose Quiet IExpr
  696.         {
  697.             if (!Options.freq_set)
  698.                 Options.report_freq = $4;
  699.         }
  700.         | tREPORT Verbose Quiet Filename
  701.         {
  702.             if (Options.statsname == (char *)NULL)
  703.                 Options.statsname = strsave($4);
  704.         }
  705.         | tREPORT Verbose Quiet
  706.         ;
  707. Verbose        : tVERBOSE
  708.         { Options.verbose = TRUE; }
  709.         |
  710.         ;
  711. Quiet        : tQUIET
  712.         { Options.quiet = TRUE; }
  713.         |
  714.         ;
  715. Aperture    : tAPERTURE Expr
  716.         {
  717.             Camera.aperture = $2;
  718.         }
  719.         ;
  720. Focaldist    : tFOCALDIST Expr
  721.         {
  722.             Camera.focaldist = $2;
  723.         }
  724.         ;
  725. Eyesep        : tEYESEP Expr
  726.         {
  727.             if (!Options.eyesep_set)
  728.                 Options.eyesep = $2;
  729.         }
  730.         ;
  731. Maxdepth    : tMAXDEPTH IExpr
  732.         {
  733.             if (!Options.maxdepth_set)
  734.                 Options.maxdepth = $2;
  735.         }
  736.         ;
  737. Background    : tBACKGROUND Color
  738.         {
  739.             Screen.background = $2;
  740.         }
  741.         ;
  742. Shadowtransp    : tSHADOWTRANSP
  743.         {
  744.             Options.shadowtransp = !Options.shadowtransp;
  745.         }
  746.         ;
  747. Light        : LightType
  748.         {
  749.             LightAddToDefined($1);
  750.         }
  751.         | LightType tNOSHADOW
  752.         {
  753.             $1->shadow = FALSE;
  754.             LightAddToDefined($1);
  755.         }
  756.         | tLIGHT Intensity tAMBIENT
  757.         {
  758.             Options.ambient = $2;
  759.         }
  760.         | Lightdef tAREA Vector Vector IExpr Vector IExpr
  761.         {
  762.             extern void AreaLightCreate();
  763.             /* Area light is strange in that the
  764.              * Creation routine does the installation.
  765.              */
  766.             AreaLightCreate(&$1, &$3, &$4, $5, &$6, $7, TRUE);
  767.         }
  768.         | Lightdef tAREA Vector Vector IExpr Vector IExpr tNOSHADOW
  769.         {
  770.             extern void AreaLightCreate();
  771.             /* Area light is strange in that the
  772.              * Creation routine does the installation.
  773.              */
  774.             AreaLightCreate(&$1, &$3, &$4, $5, &$6, $7, FALSE);
  775.         };
  776. LightType    : Lightdef tPOINT Vector
  777.         {
  778.             $$ = LightPointCreate(&$1, &$3);
  779.         }
  780.         | Lightdef tDIRECTIONAL Vector
  781.         {
  782.             $$ = LightInfiniteCreate(&$1, &$3);
  783.         }
  784.         | Lightdef tEXTENDED Expr Vector
  785.         {
  786.             $$ = LightExtendedCreate(&$1, $3, &$4);
  787.         }
  788.         | Lightdef tSPOT Vector Vector Expr
  789.         {
  790.             $$ = LightSpotCreate(&$1, &$3, &$4, $5, 0., 0.);
  791.         }
  792.         | Lightdef tSPOT Vector Vector Expr Expr Expr
  793.         {
  794.             /* light <intens> spot from <to> coef inner_rad
  795.                     outer_rad */
  796.             $$ = LightSpotCreate(&$1, &$3, &$4, $5, $6, $7);
  797.         };
  798. Lightdef    : tLIGHT Intensity
  799.         {
  800.             $$ = $2;
  801.         }
  802.         ;
  803. CurSurf        : tAPPLYSURF Surface
  804.         {
  805.             CurSurf->surf = $2;
  806.         }
  807.         ;
  808. OptSurface    : Surface
  809.         | /* EMPTY */
  810.         {
  811.             $$ = CurSurf->surf;
  812.         }
  813.         ;
  814. Surface        : NamedSurf
  815.         | ModifyNamedSurf
  816.         | SurfSpec
  817.         ;
  818. NamedSurf    : tSTRING
  819.         {
  820.             $$ = SurfaceGetNamed($1);
  821.             /*
  822.              * Free up memory allocated for surf name.
  823.              * We bother doing this because for large models
  824.              * converted from 3.0, surfnames this can account
  825.              * for lots o' bytes.
  826.              */
  827.             free((voidstar)$1);
  828.         }
  829.         | tCURSURF
  830.         {
  831.             extern Surface DefaultSurface;
  832.  
  833.             if (CurSurf->surf)
  834.                 $$ = CurSurf->surf;
  835.             else
  836.                 $$ = &DefaultSurface;
  837.         }
  838.         ;
  839. ModifyNamedSurf : CopyNamedSurf SurfComponent SurfComponents
  840.         {
  841.             $$ = tmpsurf;
  842.             tmpsurf = (Surface *)NULL;
  843.         }
  844.         | CopyCurSurf SurfComponent SurfComponents
  845.         {
  846.             $$ = tmpsurf;
  847.             tmpsurf = (Surface *)NULL;
  848.         }
  849.         ;
  850. CopyNamedSurf    : tSTRING
  851.         {
  852.             tmpsurf = SurfaceCopy(SurfaceGetNamed($1));
  853.         }
  854.         ;
  855. CopyCurSurf    : tCURSURF
  856.         {
  857.             extern Surface DefaultSurface;
  858.             if (CurSurf->surf)
  859.                 tmpsurf = SurfaceCopy(CurSurf->surf);
  860.             else
  861.                 tmpsurf = SurfaceCopy(&DefaultSurface);
  862.         }
  863.         ;
  864. SurfSpec    : SurfComponent SurfComponents
  865.         {
  866.             $$ = tmpsurf;
  867.             tmpsurf = (Surface *)NULL;
  868.         } 
  869.         ;
  870. SurfDef        : tSURFACE tSTRING Surface
  871.         {
  872.             tmpsurf = SurfaceCopy($3);
  873.             tmpsurf->name = strsave($2);
  874.             SurfaceAddToDefined(tmpsurf);
  875.             tmpsurf = (Surface *)NULL;
  876.         }
  877.         | tSURFACE tSTRING
  878.         {
  879.             /* black surface */
  880.             tmpsurf = SurfaceCreate();
  881.             tmpsurf->name = strsave($2);
  882.             SurfaceAddToDefined(tmpsurf);
  883.             tmpsurf = (Surface *)NULL;
  884.         }
  885.         ;
  886. SurfComponents    : SurfComponents SurfComponent
  887.         | /* EMPTY */
  888.         ;
  889. SurfComponent    : Ambient
  890.         | Diffuse
  891.         | Specular
  892.         | Specpow
  893.         | Body
  894.         | Reflect
  895.         | Transp
  896.         | Extinct
  897.         | Index
  898.         | Translu
  899.         | Noshadow
  900.         ;
  901. Ambient        : tAMBIENT Color
  902.         {
  903.             if (tmpsurf == (Surface *)NULL)
  904.                 tmpsurf = SurfaceCreate();
  905.             tmpsurf->amb = $2;
  906.         }
  907.         ;
  908. Diffuse        : tDIFFUSE Color
  909.         {
  910.             if (tmpsurf == (Surface *)NULL)
  911.                 tmpsurf = SurfaceCreate();
  912.             tmpsurf->diff = $2;
  913.         }
  914.         ;
  915. Specular    : tSPECULAR Color
  916.         {
  917.             if (tmpsurf == (Surface *)NULL)
  918.                 tmpsurf = SurfaceCreate();
  919.             tmpsurf->spec = $2;
  920.         }
  921.         ;
  922. Body        : tBODY Color
  923.         {
  924.             if (tmpsurf == (Surface *)NULL)
  925.                 tmpsurf = SurfaceCreate();
  926.             tmpsurf->body = $2;
  927.         };
  928. Extinct        : tEXTINCT Expr
  929.         {
  930.             if (tmpsurf == (Surface *)NULL)
  931.                 tmpsurf = SurfaceCreate();
  932.             tmpsurf->statten = $2;
  933.         };
  934. Specpow        : tSPECPOW Expr
  935.         {
  936.             if (tmpsurf == (Surface *)NULL)
  937.                 tmpsurf = SurfaceCreate();
  938.             tmpsurf->srexp = $2;
  939.         }
  940.         ;
  941. Reflect        : tREFLECT Expr
  942.         {
  943.             if (tmpsurf == (Surface *)NULL)
  944.                 tmpsurf = SurfaceCreate();
  945.             tmpsurf->reflect = $2;
  946.         }
  947.         ;
  948. Transp        : tTRANSP Expr
  949.         {
  950.             if (tmpsurf == (Surface *)NULL)
  951.                 tmpsurf = SurfaceCreate();
  952.             tmpsurf->transp = $2;
  953.         }
  954.         ;
  955. Index        : tINDEX Expr
  956.         {
  957.             if (tmpsurf == (Surface *)NULL)
  958.                 tmpsurf = SurfaceCreate();
  959.             tmpsurf->index = $2;
  960.         }
  961.         ;
  962. Translu        : tTRANSLU Expr Color Expr
  963.         {
  964.             if (tmpsurf == (Surface *)NULL)
  965.                 tmpsurf = SurfaceCreate();
  966.             tmpsurf->translucency = $2;
  967.             tmpsurf->translu = $3;
  968.             tmpsurf->stexp = $4;
  969.         }
  970.         ;
  971. Noshadow    : tNOSHADOW
  972.         {
  973.             if (tmpsurf == (Surface *)NULL)
  974.                 tmpsurf = SurfaceCreate();
  975.             tmpsurf->noshadow = TRUE;
  976.         }
  977.         ;
  978. HeightField    : tHEIGHTFIELD Surface Filename
  979.         {
  980.             $$ = GeomHfCreate($3);
  981.             if ($$)
  982.                 $$->surf = $2;
  983.         }
  984.         | tHEIGHTFIELD Filename
  985.         {
  986.             $$ = GeomHfCreate($2);
  987.         }
  988.         ;
  989. Poly        : tPOLY OptSurface Polypoints
  990.         {
  991.             $$ = GeomPolygonCreate(Polypoints, Npoints,
  992.                 Options.flipnorm);
  993.             if ($$)
  994.                 $$->surf = $2;
  995.             Polypoints = (PointList *)NULL;
  996.             Npoints = 0;
  997.         }
  998.         ;
  999. Polypoints    : /* empty */
  1000.         | Polypoints Polypoint
  1001.         ;
  1002. Polypoint    : Vector
  1003.         {
  1004.             PointList *ptmp;
  1005.  
  1006.             ptmp = (PointList *)Malloc(sizeof(PointList));
  1007.             ptmp->vec = $1;
  1008.             ptmp->next = Polypoints;
  1009.             Polypoints = ptmp;
  1010.             Npoints++;
  1011.         }
  1012.         ;
  1013. Aggregate    : AggregateDef
  1014.         {
  1015.             if (Defstack->obj) {
  1016.                 /*
  1017.                  * Set object texture to current texture.
  1018.                  */
  1019.                 Defstack->obj->texture = CurText;
  1020.             }
  1021.             CurText = (Texture *)NULL;
  1022.             /*
  1023.              * Pop topmost object on stack.
  1024.              */
  1025.             $$ = Defstack->obj;
  1026.             Defstack = GeomStackPop(Defstack);
  1027.             /* Pop current surface */
  1028.             CurSurf = SurfPop(CurSurf);
  1029.             /* Make current default surf aggregate's default */
  1030.             $$->surf = CurSurf->surf;
  1031.         }
  1032.         ;
  1033. AggregateDef    : AggregateCreate Aggdefs tEND
  1034.         {
  1035.             /* Convert aggregate, pop stacks, etc. */
  1036.             if ($1) {
  1037.                 if (Defstack->obj->next == (Geom *)NULL) {
  1038.                     RLerror(RL_WARN,
  1039.                         "Null object defined.\n","","","");
  1040.                     Defstack->obj = (Geom *)NULL;
  1041.                 } else {
  1042.                     /*
  1043.                      * Convert the linked list of objects
  1044.                      * associated with the topmost object
  1045.                      * to the appropriate aggregate type.
  1046.                      */
  1047.                     Defstack->obj->prims=AggregateConvert(
  1048.                         Defstack->obj,
  1049.                         Defstack->obj->next);
  1050.                     /*
  1051.                      * Make sure conversion worked OK.
  1052.                      */
  1053.                     if (Defstack->obj->prims <= 0)
  1054.                         Defstack->obj = (Geom *)NULL;
  1055.                 }
  1056.             }
  1057.         }
  1058.         ;
  1059. AggregateCreate    : AggregateType
  1060.         {
  1061.             if ($1) {
  1062.                 Defstack = GeomStackPush($1, Defstack);
  1063.                 CurSurf = SurfPush((Surface *)NULL, CurSurf);
  1064.             }
  1065.         };
  1066. AggregateType    : List
  1067.         | Grid
  1068.         | Csg
  1069.         ;
  1070. List        : tLIST
  1071.         {
  1072.             $$ = GeomListCreate();
  1073.         }
  1074.         ;
  1075. Grid        : tGRID IExpr IExpr IExpr
  1076.         {
  1077.             $$ = GeomGridCreate($2, $3, $4);
  1078.         }
  1079.         ;
  1080. Csg        : CombineOp
  1081.         {
  1082.             $$ = GeomCsgCreate($1);
  1083.             Options.csg = TRUE;
  1084.         }
  1085.         ;
  1086. CombineOp    : tUNION
  1087.         {
  1088.             $$ = CSG_UNION;
  1089.         }
  1090.         | tINTERSECT
  1091.         {
  1092.             $$ = CSG_INTERSECT;
  1093.         }
  1094.         | tDIFFERENCE
  1095.         {
  1096.             $$ = CSG_DIFFERENCE;
  1097.         }
  1098.             ;
  1099. Cone        : tCONE OptSurface Expr Vector Expr Vector
  1100.         {
  1101.             if (equal($3, $5)) {
  1102.                 /* It's really a cylinder */
  1103.                 $$ = GeomCylinderCreate($3, &$4, &$6);
  1104.             } else
  1105.                 $$ = GeomConeCreate($3, &$4, $5, &$6);
  1106.             if ($$)
  1107.                 $$->surf = $2;
  1108.         }
  1109.         ;
  1110. Cylinder    : tCYL OptSurface Expr Vector Vector
  1111.         {
  1112.             $$ = GeomCylinderCreate($3, &$4, &$5);
  1113.             if ($$)
  1114.                 $$->surf = $2;
  1115.         }
  1116.         ;
  1117. Sphere        : tSPHERE OptSurface Expr Vector
  1118.         {
  1119.             $$ = GeomSphereCreate($3, &($4));
  1120.             if ($$)
  1121.                 $$->surf = $2;
  1122.         }
  1123.         ;
  1124. Disc        : tDISC OptSurface Expr Vector Vector
  1125.         {
  1126.             $$ = GeomDiscCreate($3, &($4), &($5));
  1127.             if ($$)
  1128.                 $$->surf = $2;
  1129.         }
  1130.         ;
  1131. Box        : tBOX OptSurface Vector Vector
  1132.         {
  1133.             $$ = GeomBoxCreate(&$3, &$4);
  1134.             if ($$)
  1135.                 $$->surf = $2;
  1136.         }
  1137.         ;
  1138. Triangle    : tTRIANGLE OptSurface Vector Vector Vector
  1139.         {
  1140.             $$ = GeomTriangleCreate(FLATTRI, &($3), &($4), &($5),
  1141.                 (Vector *)NULL, (Vector *)NULL, (Vector *)NULL,
  1142.                 (Vec2d *)NULL, (Vec2d *)NULL, (Vec2d *)NULL,
  1143.                 Options.flipnorm);
  1144.             if ($$)
  1145.                 $$->surf = $2;
  1146.         }
  1147.         | tTRIANGLE OptSurface  Vector Vector
  1148.                     Vector Vector
  1149.                     Vector Vector
  1150.         {
  1151.             $$ = GeomTriangleCreate(PHONGTRI, &($3), &($5),
  1152.                 &($7), &($4), &($6), &($8),
  1153.                 (Vec2d *)NULL, (Vec2d *)NULL, (Vec2d *)NULL,
  1154.                 Options.flipnorm);
  1155.             if ($$)
  1156.                 $$->surf = $2;
  1157.         }
  1158.         | tTRIANGLEUV OptSurface Vector Vector Vec2d
  1159.                      Vector Vector Vec2d
  1160.                      Vector Vector Vec2d
  1161.         {
  1162.             $$ = GeomTriangleCreate(PHONGTRI, &($3), &($6), &($9),
  1163.                         &($4), &($7), &($10),
  1164.                         &($5), &($8), &($11),
  1165.                         Options.flipnorm);
  1166.             if ($$)
  1167.                 $$->surf = $2;
  1168.         }
  1169.         ;
  1170. Plane        : tPLANE OptSurface Vector Vector
  1171.         {
  1172.             $$ = GeomPlaneCreate(&($3), &($4));
  1173.             if ($$)
  1174.                 $$->surf = $2;
  1175.         }
  1176.         ;
  1177. Torus        : tTORUS OptSurface Expr Expr Vector Vector
  1178.         {
  1179.             $$ = GeomTorusCreate($3, $4, &($5), &($6));
  1180.             if ($$)
  1181.                 $$->surf = $2;
  1182.         }
  1183.         ;
  1184. Blob        : tBLOB OptSurface Expr MetaPoints
  1185.         {
  1186.             $$ = GeomBlobCreate($3, Metapoints, Npoints);
  1187.             if ($$)
  1188.                 $$->surf = $2;
  1189.             Metapoints = (MetaList *)NULL;
  1190.             Npoints = 0;
  1191.         }
  1192.         ;
  1193. MetaPoints    : /* empty */
  1194.         | MetaPoints MetaPoint
  1195.         ;
  1196. MetaPoint    : Expr Expr Expr Expr Expr
  1197.         {
  1198.             Metapoint = (MetaList *)Malloc(sizeof(MetaList));
  1199.             Metapoint->mvec.c0 = $1;
  1200.             Metapoint->mvec.rs = $2;
  1201.             Metapoint->mvec.x = $3;
  1202.             Metapoint->mvec.y = $4;
  1203.             Metapoint->mvec.z = $5;
  1204.             Metapoint->next = Metapoints;
  1205.             Metapoints = Metapoint;
  1206.             Npoints++;
  1207.         }
  1208.         ;
  1209. Outfile        : tOUTFILE Filename
  1210.         {
  1211.             if (Options.imgname != (char *)NULL)
  1212.                 /* Already set on command line. */
  1213.                 RLerror(RL_WARN,
  1214.                     "Ignoring output file name \"%s\".\n",
  1215.                     $2,"","");
  1216.             else
  1217.                 Options.imgname = strsave($2);
  1218.         }
  1219.         ;
  1220. GlobalEffects    : tATMOSPHERE Effects
  1221.         {
  1222.             AtmosEffects = CurEffect;
  1223.             CurEffect = (Atmosphere *)NULL;
  1224.         }
  1225.         | tATMOSPHERE IExpr Effects
  1226.         {
  1227.             if ($2 <= 0.)
  1228.                 RLerror(RL_PANIC,
  1229.                 "Index of refraction must be positive.\n","","","");
  1230.             TopMedium.index = $2;
  1231.             AtmosEffects = CurEffect;
  1232.             CurEffect = (Atmosphere *)NULL;
  1233.         }
  1234.         ;
  1235. Effects        : Effects Effect
  1236.         |
  1237.         ;
  1238. Effect        : EffectType
  1239.         {
  1240.             $1->next = CurEffect;
  1241.             CurEffect = $1;
  1242.         }
  1243.         ;
  1244. EffectType    : tMIST Color Color Expr Expr
  1245.         {
  1246.             $$ = AtmosMistCreate(&($2), &($3), $4, $5);
  1247.         }
  1248.         | tFOG Color Color
  1249.         {
  1250.             $$ = AtmosFogCreate(&($2), &($3));
  1251.         }
  1252.         | tFOGDECK Expr Expr Vector Expr IExpr Color Color
  1253.         {
  1254.             $$ = AtmosFogdeckCreate($2, $3, &$4, $5, $6, &$7, &$8);
  1255.         }
  1256.         ;
  1257. Color        : Expr Expr Expr
  1258.         {
  1259.             $$.r = $1;
  1260.             $$.g = $2;
  1261.             $$.b = $3;
  1262.         }
  1263.         ;
  1264. Vector        : Expr Expr Expr
  1265.         {
  1266.             $$.x = $1;
  1267.             $$.y = $2;
  1268.             $$.z = $3;
  1269.         }
  1270.         ;
  1271. Vec2d        : Expr Expr 
  1272.         {
  1273.             $$.u = $1;
  1274.             $$.v = $2;
  1275.         }
  1276.         ;
  1277. OptMapping    : Mapping
  1278.         | /* EMPTY */
  1279.         {
  1280.             $$ = UVMappingCreate();
  1281.         }
  1282.         ;
  1283. Mapping        : tMAP MapMethod
  1284.         {
  1285.             $$ = $2;
  1286.         }
  1287.         ;
  1288. MapMethod    : tUV
  1289.         {
  1290.             $$ = UVMappingCreate();
  1291.         }
  1292.         | tSPHERICAL
  1293.         {
  1294.             $$ = SphereMappingCreate((Vector *)NULL,
  1295.                 (Vector *)NULL, (Vector *)NULL);
  1296.         }
  1297.         | tSPHERICAL Vector Vector Vector
  1298.         {
  1299.             /* origin up uaxis */
  1300.             $$ = SphereMappingCreate(&$2, &$3, &$4);
  1301.         }
  1302.         | tCYLINDRICAL
  1303.         {
  1304.             $$ = CylMappingCreate((Vector *)NULL,
  1305.                 (Vector *)NULL, (Vector *)NULL);
  1306.         }
  1307.         | tCYLINDRICAL Vector Vector Vector
  1308.         {
  1309.             /* origin up uaxis */
  1310.             $$ = CylMappingCreate(&$2, &$3, &$4);
  1311.         }
  1312.         | tPLANAR
  1313.         {
  1314.             $$ = LinearMappingCreate((Vector *)NULL,
  1315.                 (Vector *)NULL, (Vector *)NULL);
  1316.         }
  1317.         | tPLANAR Vector Vector Vector
  1318.         {
  1319.             /* origin up uaxis */
  1320.             $$ = LinearMappingCreate(&$2, &$3, &$4);
  1321.         }
  1322.         ;
  1323. SurfCompName    : tAMBIENT
  1324.         {
  1325.             $$ = AMBIENT;
  1326.         }
  1327.         | tDIFFUSE
  1328.         {
  1329.             $$ = DIFFUSE;
  1330.         }
  1331.         | tBODY
  1332.         {
  1333.             $$ = BODY;
  1334.         }
  1335.         | tSPECULAR
  1336.         {
  1337.             $$ = SPECULAR;
  1338.         }
  1339.         | tREFLECT
  1340.         {
  1341.             $$ = REFLECT;
  1342.         }
  1343.         | tTRANSP
  1344.         {
  1345.             $$ = TRANSP;
  1346.         }
  1347.         | tSPECPOW
  1348.         {
  1349.             $$ = SPECPOW;
  1350.         }
  1351.         | tBUMP
  1352.         {
  1353.             $$ = BUMP;
  1354.         }
  1355.         | tINDEX
  1356.         {
  1357.             $$ = INDEX;
  1358.         }
  1359.         ;
  1360. Intensity    : Expr
  1361.         { $$.r = $$.g = $$.b = $1; }
  1362.         | Color
  1363.         ;
  1364. Print        : tPRINT Expr
  1365.         {
  1366.             fprintf(stderr,"%f\n",$2);
  1367.         }
  1368. Define        : tDEFINE tSTRING AnimExpr
  1369.         {
  1370.             SymtabAddEntry($2, $3->type, $3, NULL, $3->timevary, 0);
  1371.         };
  1372. IExpr        : Expr
  1373.         { $$ = (int)$1; }
  1374.         ;
  1375. Expr        : Float
  1376.         | ParenExpr
  1377.         {
  1378.             if (!$1->timevary) {
  1379.                 $$ = ExprEval($1);
  1380.             } else {
  1381.                 RLerror(RL_PANIC, "Illegal expression use.\n","","","");
  1382.             }
  1383.         }
  1384.         ;
  1385. AnimExpr    : Float
  1386.         {
  1387.             $$ = ExprReuseFloatCreate($1);
  1388.         }
  1389.         | ParenExpr
  1390.         ;
  1391. ParenExpr    : '(' MExpr ')'
  1392.         {
  1393.             $$ = $2;
  1394.         };
  1395. MExpr        : tFLOAT
  1396.         {
  1397.             $$ = ExprFloatCreate($1, FALSE);
  1398.         }
  1399.         | tSTRING
  1400.         {
  1401.             $$ = ExprFloatSymtabFind($1);
  1402.         }
  1403.         | Symtabent '(' MExpr ')'
  1404.         {
  1405.             $$ = ExprResolve1($3, $1->value.fp, $1->timevary);
  1406.         }
  1407.         | Symtabent '(' MExpr ',' MExpr ')'
  1408.         {
  1409.             $$ = ExprResolve2($3, $5,
  1410.                     $1->value.fp,
  1411.                     $1->timevary);
  1412.         }
  1413.         | Symtabent '(' MExpr ',' MExpr ',' MExpr ')'
  1414.         {
  1415.             $$ = ExprResolve3($3, $5, $7, 
  1416.                     $1->value.fp,
  1417.                     $1->timevary);
  1418.         }
  1419.         | Symtabent '(' MExpr ',' MExpr ',' MExpr ',' MExpr ')'
  1420.         {
  1421.             $$ = ExprResolve4($3, $5, $7, $9, 
  1422.                     $1->value.fp,
  1423.                     $1->timevary);
  1424.         }
  1425.         | Symtabent
  1426.             '(' MExpr ',' MExpr ',' MExpr ',' MExpr ',' MExpr ')'
  1427.         {
  1428.             $$ = ExprResolve5($3, $5, $7, $9, $11,
  1429.                     $1->value.fp,
  1430.                     $1->timevary);
  1431.         }
  1432.         | '(' MExpr ')'
  1433.         {
  1434.             $$ = $2;
  1435.         }
  1436.         | MExpr '+' MExpr
  1437.         {
  1438.             $$ = ExprResolve2($1, $3, SumExpr, FALSE);
  1439.         }
  1440.         | MExpr '-' MExpr
  1441.         {
  1442.             $$ = ExprResolve2($1, $3, DiffExpr, FALSE);
  1443.         }
  1444.         | MExpr '*' MExpr
  1445.         {
  1446.             $$ = ExprResolve2($1, $3, MultExpr, FALSE);
  1447.         }
  1448.         | MExpr '/' MExpr
  1449.         {
  1450.             $$ = ExprResolve2($1, $3, DivideExpr, FALSE);
  1451.         }
  1452.         | MExpr '%' MExpr
  1453.         {
  1454.             $$ = ExprResolve2($1, $3, ModExpr, FALSE);
  1455.         }
  1456.         | '-' MExpr %prec UMINUS
  1457.         {
  1458.             $$ = ExprResolve1($2, NegateExpr, FALSE);
  1459.         }
  1460.         | '+' MExpr %prec UMINUS
  1461.         {
  1462.             $$ = $2;
  1463.         }
  1464.         | MExpr '^' MExpr
  1465.         {
  1466.             $$ = ExprResolve2($1, $3, pow, FALSE);
  1467.         } ;
  1468. Float        : tFLOAT
  1469.         | '-' tFLOAT
  1470.         { $$ = -$2; }
  1471.         | '+' tFLOAT
  1472.         { $$ = $2; };
  1473. Filename    : tSTRING
  1474.         | tFILENAME
  1475.         ;
  1476. Symtabent    : tSTRING
  1477.         {
  1478.             $$ = SymtabBuiltinFind($1);
  1479.         };
  1480. %%
  1481.  
  1482. Geom *
  1483. NewAggregate(obj)
  1484. Geom *obj;
  1485. {
  1486.     obj->name = Defstack->obj->name;
  1487.     obj->next = Defstack->obj->next;
  1488.     return obj;
  1489. }
  1490.