home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / macraysh.sit / Code / Source / lex.l < prev    next >
Encoding:
Text File  |  1991-07-19  |  5.2 KB  |  216 lines

  1. /* lex.l                                   */
  2. /* Copyright (C) 1989, 1991, Craig E. Kolb                   */
  3. /* All rights reserved.                               */
  4. /*                                       */
  5. /* This software may be freely copied, modified, and redistributed,       */
  6. /* provided that this copyright notice is preserved on all copies.       */
  7. /*                                       */
  8. /* You may not distribute this software, in whole or in part, as part of   */
  9. /* any commercial product without the express consent of the authors.       */
  10. /*                                        */
  11. /* There is no warranty or other guarantee of fitness of this software       */
  12. /* for any purpose.  It is provided solely "as is".               */
  13. /*                                       */
  14. /* $Id: lex.l,v 4.0 91/07/17 14:46:15 kolb Exp Locker: kolb $ */
  15. %{
  16. #include "config.h"
  17. #include "rayshade.h"
  18. #ifdef I_STRING
  19. #include <string.h>
  20. #else
  21. #include <strings.h>
  22. #endif
  23. #include "liblight/light.h"
  24. #include "libsurf/atmosphere.h"
  25. #include "libsurf/surface.h"
  26. #include "libtext/texture.h"
  27. #include "libobj/geom.h"
  28. #include "symtab.h"
  29. #include "y.tab.h"
  30. extern char *strsave();
  31. %}
  32. alpha    [a-zA-Z]
  33. special    [\.\_-]
  34. digit    [0-9]
  35. exp    [Ee][-+]?{digit}+
  36. string    {alpha}({alpha}|{digit}|{special})*
  37. filename "/"?"/"?(("."|".."|{string})"/")*{string}
  38. %p 9400
  39. %e 1200
  40. %n 600
  41. %%
  42. [ \t\n]            ;
  43. ^#            handlehash();
  44. "/*"            skipcomments();
  45. ambient            return tAMBIENT;
  46. aperture        return tAPERTURE;
  47. applysurf        return tAPPLYSURF;
  48. area            return tAREA;
  49. atmosphere        return tATMOSPHERE;
  50. background        return tBACKGROUND;
  51. blob            return tBLOB;
  52. blotch            return tBLOTCH;
  53. body            return tBODY;
  54. box            return tBOX;
  55. bump            return tBUMP;
  56. checker            return tCHECKER;
  57. cloud            return tCLOUD;
  58. cone            return tCONE;
  59. component        return tCOMPONENT;
  60. contrast        return tCONTRAST;
  61. cursurf            return tCURSURF;
  62. cutoff            return tCUTOFF;
  63. cylinder        return tCYL;
  64. cylindrical        return tCYLINDRICAL;
  65. define            return tDEFINE;
  66. diffuse            return tDIFFUSE;
  67. difference        return tDIFFERENCE;
  68. directional        return tDIRECTIONAL;
  69. disc            return tDISC;
  70. end            return tEND;
  71. extended        return tEXTENDED;
  72. extinct            return tEXTINCT;
  73. eyep            return tEYEP;
  74. eyesep            return tEYESEP;
  75. filter            return tFILTER;
  76. fbm            return tFBM;
  77. fbmbump            return tFBMBUMP;
  78. focaldist        return tFOCALDIST;
  79. fog            return tFOG;
  80. fogdeck            return tFOGDECK;
  81. fov            return tFOV;
  82. framelength        return tFRAMELENGTH;
  83. frames            return tFRAMES;
  84. gauss            return tGAUSS;
  85. gloss            return tGLOSS;
  86. grid            return tGRID;
  87. heightfield        return tHEIGHTFIELD;
  88. image            return tIMAGE;
  89. index            return tINDEX;
  90. intersect        return tINTERSECT;
  91. jitter            return tJITTER;
  92. light            return tLIGHT;
  93. list            return tLIST;
  94. lookp            return tLOOKP;
  95. map            return tMAP;
  96. marble            return tMARBLE;
  97. maxdepth        return tMAXDEPTH;
  98. mount            return tMOUNT;
  99. mist            return tMIST;
  100. name            return tNAME;
  101. nojitter        return tNOJITTER;
  102. noshadow        return tNOSHADOW;
  103. object            return tOBJECT;
  104. outfile            return tOUTFILE;
  105. plane            return tPLANE;
  106. planar            return tPLANAR;
  107. point            return tPOINT;
  108. poly            return tPOLY;
  109. polygon            return tPOLY;
  110. print            return tPRINT;
  111. quiet            return tQUIET;
  112. range            return tRANGE;
  113. reflect            return tREFLECT;
  114. reflective        return tREFLECT;
  115. report            return tREPORT;
  116. resolution        return tSCREEN; /* A synonym for screen */
  117. rotate            return tROTATE;
  118. sample            return tSAMPLE;
  119. scale            return tSCALE;
  120. screen            return tSCREEN;
  121. shadowtransp        return tSHADOWTRANSP;
  122. shutter            return tSHUTTER;
  123. sky            return tSKY;
  124. smooth            return tSMOOTH;
  125. sphere            return tSPHERE;
  126. spherical        return tSPHERICAL;
  127. specular        return tSPECULAR;
  128. specpow            return tSPECPOW;
  129. spot            return tSPOT;
  130. starttime        return tSTARTTIME;
  131. stripe            return tSTRIPE;
  132. surface            return tSURFACE;
  133. textsurf        return tTEXTSURF;
  134. texture            return tTEXTURE;
  135. tile            return tTILE;
  136. torus            return tTORUS;
  137. transform        return tTRANSFORM;
  138. translate        return tTRANSLATE;
  139. translu            return tTRANSLU;
  140. translucency        return tTRANSLU;
  141. transp            return tTRANSP;
  142. transparent        return tTRANSP;
  143. triangle        return tTRIANGLE;
  144. triangleuv        return tTRIANGLEUV;
  145. union            return tUNION;
  146. up            return tUP;
  147. uv            return tUV;
  148. verbose            return tVERBOSE;
  149. windy            return tWINDY;
  150. wood            return tWOOD;
  151. {digit}+ |
  152. {digit}+"."{digit}*({exp})? |
  153. {digit}*"."{digit}+({exp})? |
  154. {digit}+{exp}        {yylval.d = atof(yytext); return tFLOAT;}
  155. {string}        {yylval.c = strsave(yytext); return tSTRING;}
  156. {filename}        {yylval.c = strsave(yytext); return tFILENAME;}
  157. .            return yytext[0];
  158.  
  159. %%
  160. yywrap() {return 1;}
  161. /*
  162.  * Skip over comments.
  163.  */
  164. skipcomments()
  165. {
  166.     char c;
  167.  
  168.     while (1) {
  169.         while (input() != '*')
  170.             ;
  171.         if ((c = input()) == '/')
  172.             return;
  173.         unput(c);
  174.     }
  175. }
  176. /*
  177.  * Deal with ccp-produced lines of the form:
  178.  * # n "filename"
  179.  * and
  180.  * # n
  181.  * Where filename is the name of the file being processed, and n is
  182.  * the current line number in that file.
  183.  */
  184. handlehash()
  185. {
  186.     char buf[BUFSIZ];
  187.     int i;
  188.     extern int yylineno;
  189.     extern char yyfilename[];
  190.  
  191.     /*
  192.      * Read the entire line into buf.
  193.      */
  194.     for (i = 0; (buf[i] = input()) != '\n'; i++)
  195.             ;
  196.     unput(buf[i]);        /* To make sure consecutive # lines work. */
  197.     buf[i] = (char)NULL;    /* Replace newline with NULL. */
  198.  
  199.     /*
  200.      * Complain if the line was not of the form #n "filename"
  201.      */
  202.     if ((i = sscanf(buf, "%d \"%[^\"]s\"", &yylineno, yyfilename)) == 0) {
  203.         RLerror(RL_PANIC, "Unknown '#' control (%s).",buf);
  204.         exit(1);
  205.     }
  206.     if (i == 1) {
  207.         if (index(buf, '"') != (char *)NULL) {
  208.             /*
  209.              * Filename was "", which means stdin.
  210.              */
  211.             (void)strcpy(yyfilename, "stdin");
  212.         }
  213.     }
  214.     yylineno--;  /* The newline we unput will increment yylineno */
  215. }
  216.