home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume21 / rayshade / part18 < prev    next >
Text File  |  1991-07-21  |  32KB  |  1,483 lines

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