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