home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / vogle / prev.lha / lex.l < prev    next >
Encoding:
Lex Description  |  1991-03-20  |  4.6 KB  |  339 lines

  1. %{
  2. #include <math.h>
  3. #include "art.h"
  4. #include "objs.h"
  5. #include "gram.h"
  6.  
  7. extern int    linecount;
  8.  
  9. extern char    currentfile[];
  10.  
  11. extern symbol    *lookup();
  12.  
  13. extern double    atof();
  14.  
  15. %}
  16.  
  17. %p 4000
  18. %a 3000
  19. %n 550
  20.  
  21. %%
  22.  
  23. perspective    return(PERSPECTIVE);
  24.  
  25. orthographic    return(ORTHOGRAPHIC);
  26.  
  27. projection    return(PROJECTION);
  28.  
  29. maxtreedepth    return(MAXTREEDEPTH);
  30.  
  31. screensize    return(SCREENSIZE);
  32.  
  33. source        return(SOURCE);
  34.  
  35. amplitude    return(AMPLITUDE);
  36.  
  37. wavelength    return(WAVELENGTH);
  38.  
  39. damping        return(DAMPING);
  40.  
  41. phase        return(PHASE);
  42.  
  43. scalefactor    return(SCALEFACTOR);
  44.  
  45. sourceradius    return(SOURCERADIUS);
  46.  
  47. turbulence    return(TURBULENCE);
  48.  
  49. squeeze        return(SQUEEZE);
  50.  
  51. geofile        return(OFFFILE);
  52.  
  53. offfile        return(OFFFILE);
  54.  
  55. colou?rfile    return(COLOURFILE);
  56.  
  57. normalfile    return(NORMALFILE);
  58.  
  59. vnormalfile    return(VNORMALFILE);
  60.  
  61. vortfile    return(VORTFILE);
  62.  
  63. top        return(TOP);
  64.  
  65. base        return(BASE);
  66.  
  67. constant    return(CONST);
  68.  
  69. coefficients    return(COEFFS);
  70.  
  71. order        return(ORDER);
  72.  
  73. csg        return(CSG);
  74.  
  75. composite    return(COMPOSITE);
  76.  
  77. phongshading    {
  78.             yylval.y_int = PHONGSHADING;
  79.             return(OPTION);
  80.         }
  81.  
  82. backfacing    {
  83.             yylval.y_int = ART_BACKFACING;
  84.             return(OPTION);
  85.         }
  86.  
  87. on        return(ON);
  88.  
  89. off        return(OFF);
  90.  
  91. material    return(MATERIAL);
  92.  
  93. center        return(CENTER);
  94.  
  95. colou?r        return(COLOUR);
  96.  
  97. ambient        return(AMBIENT);
  98.  
  99. reflectance    return(REFLECTANCE);
  100.  
  101. absorption    return(ABSORPTION);
  102.  
  103. transparency    return(TRANSPARENCY);
  104.  
  105. hazecolou?r    return(HAZECOLOUR);
  106.  
  107. fogfactor    return(FOGFACTOR);
  108.  
  109. rfactor        return(RFACTOR);
  110.  
  111. falloff        return(FALLOFF);
  112.  
  113. ri        return(RI);
  114.  
  115. repeat        return(REPEAT);
  116.  
  117. radius        return(RADIUS);
  118.  
  119. radii        return(RADII);
  120.  
  121. light        return(LIGHT);
  122.  
  123. direction    return(DIRECTION);
  124.  
  125. angle        return(ANGLE);
  126.  
  127. insideangle    return(INSIDEANGLE);
  128.  
  129. beamdistribution    return(BEAMDISTRIBUTION);
  130.  
  131. numrays        return(NUMRAYS);
  132.  
  133. vertex        return(VERTEX);
  134.  
  135. location    return(LOCATION);
  136.  
  137. tile        return(TILE);
  138.  
  139. texture        return(TEXTURE);
  140.  
  141. map        return(MAP);
  142.  
  143. colou?rmap    return(COLOURMAP);
  144.  
  145. range        return(RANGE);
  146.  
  147. blend        return(BLEND);
  148.  
  149. blendcolou?r    return(BLENDCOLOR);
  150.  
  151. scalefactors    return(SCALEFACTORS);
  152.  
  153. size        return(SIZE);
  154.  
  155. equation    return(EQUATION);
  156.  
  157. translate    return(ART_TRANSLATE);
  158.  
  159. rotate        return(ART_ROTATE);
  160.  
  161. scale        return(ART_SCALE);
  162.  
  163. lookat        return(LOOKAT);
  164.  
  165. up        return(UP);
  166.  
  167. fieldofview    return(FIELDOFVIEW);
  168.  
  169. raysperpixel    return(RAYSPERPIXEL);
  170.  
  171. pixelgrid    return(PIXELGRID);
  172.  
  173. shadows        return(SHADOWS);
  174.  
  175. title        return(TITLE);
  176.  
  177. background    return(BACKGROUND);
  178.  
  179. maxhitlevel    return(MAXHITLEVEL);
  180.  
  181. output        return(OUTPUT);
  182.  
  183. twentyfivebit    return(TWENTYFIVEBIT);
  184.  
  185. rgb        {
  186.             yylval.y_int = PIX_RGB;
  187.             return(FILETYPE);
  188.         }
  189.  
  190. rle        {
  191.             yylval.y_int = PIX_RLE;
  192.             return(FILETYPE);
  193.         }
  194.  
  195. rgba        {
  196.             yylval.y_int = PIX_RGBA;
  197.             return(FILETYPE);
  198.         }
  199.  
  200. rlea        {
  201.             yylval.y_int = PIX_RLEA;
  202.             return(FILETYPE);
  203.         }
  204.  
  205. [a-zA-Z_][/a-zA-Z_.0-9]*    {
  206.             if ((yylval.y_sym = lookup(yytext)) != (symbol *)NULL)
  207.                 return(OBJECT_TYPE);
  208.             else {
  209.                 yylval.y_str = (char *)smalloc(strlen(yytext) + 1);
  210.                 strcpy(yylval.y_str, yytext);
  211.  
  212.                 return(NAME);
  213.             }
  214.         }
  215.  
  216. [0-9]*    {
  217.             yylval.y_int = atoi(yytext);
  218.             return(INTEGER);
  219.         }
  220.  
  221. [0-9]*\.[0-9]*    {
  222.             yylval.y_flt = atof(yytext);
  223.             return(FLOAT);
  224.         }
  225.  
  226. "+"        return(PLUS);
  227.  
  228. "-"        return(MINUS);
  229.  
  230. "/"        return(DIV);
  231.  
  232. "*"        return(MULT);
  233.  
  234. "%"        return(PCENT);
  235.  
  236. "^"        return(POWER);
  237.  
  238. ","        return(COMMA);
  239.  
  240. "("        return(LP);
  241.  
  242. ")"        return(RP);
  243.  
  244. "="        return(EQUALS);
  245.  
  246. "$$"        return(DOLS);
  247.  
  248. "\""        {
  249.             char    buf[BUFSIZ], *p;
  250.             
  251.             for (p = buf; (*p = getchar()) != '"'; p++)
  252.                 if (*p == '\n' || *p == EOF)
  253.                     yyerror("syntax error");
  254.  
  255.             *p = 0;
  256.  
  257.             yylval.y_str = (char *)smalloc(strlen(buf) + 1);
  258.             strcpy(yylval.y_str, buf);
  259.  
  260.             return(NAME);
  261.         }
  262.  
  263. "{"        {
  264.             return(LBRACE);
  265.         }
  266.  
  267. "}"        {
  268.             return(RBRACE);
  269.         }
  270.  
  271. "'"        return(QUOTE);
  272.  
  273. "\n"        {
  274.             linecount++;
  275.         }
  276.  
  277. [ \t]        {
  278.             ;
  279.         }
  280.  
  281. #        {
  282.             int    c, i, j;
  283.             char    buf[BUFSIZ], *p;
  284.  
  285.             i = 0;
  286.             while ((buf[i] = getchar()) != '\n' && !feof(stdin))
  287.                 i++;
  288.  
  289.             if (sscanf(buf, "%d", &linecount) != 1)
  290.                 linecount++;
  291.             else {
  292.                 for (p = buf; p != &buf[i]; p++)
  293.                     if (*p == '"')
  294.                         break;
  295.  
  296.                 if (p == &buf[i])
  297.                     linecount++;
  298.                 else {
  299.                     j = 0;
  300.                     p++;
  301.                     while (*p != '"' && p != &buf[i])
  302.                         currentfile[j++] = *p++;
  303.                     currentfile[j] = 0;
  304.                 }
  305.             }
  306.         }
  307.  
  308. "/*"        {
  309.             int    c1, c2;
  310.             int    comline, incomment = 1;
  311.             char    buf[BUFSIZ];
  312.  
  313.             comline = linecount;
  314.  
  315.             do {
  316.                 while ((c1 = getchar()) != '*' && c1 != '/' && c1 != EOF)
  317.                     if (c1 == '\n')
  318.                         linecount++;
  319.  
  320.                 c2 = getchar();
  321.                 if (c2 == '\n')
  322.                     linecount++;
  323.  
  324.                 if (c1 == '*' && c2 == '/')
  325.                     incomment--;
  326.  
  327.                 if (c1 == '/' && c2 == '*') {
  328.                     incomment++;
  329.                     comline = linecount;
  330.                 }
  331.  
  332.             } while (incomment && c2 != EOF);
  333.  
  334.             if (c1 == EOF || c2 == EOF) {
  335.                 sprintf(buf, "art: unterminated comment - started line %d.\n", comline);
  336.                 fatal(buf);
  337.             }
  338.         }
  339.