home *** CD-ROM | disk | FTP | other *** search
/ ftp.sunet.sepub/pictures / 2014.11.ftp.sunet.se-pictures.tar / ftp.sunet.se / pub / pictures / ACiD-artpacks / programs / unix / editors / gimp-plugins-unstable-0_99_23_tar.gz / gimp-plugins-unstable-0_99_23_tar / gimp-plugins-unstable-0.99.23 / user_filter / afslex.l next >
Text File  |  1998-02-20  |  2KB  |  94 lines

  1. %{
  2. /*
  3.  * Written 1997 Jens Ch. Restemeier <jchrr@hrz.uni-bielefeld.de>
  4.  * 
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or
  8.  * (at your option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  */
  20. #include <string.h>
  21. #include <ctype.h>
  22.  
  23. #include "afstree.h"
  24. #include "afsparse.h"
  25. #include "afsparse.tab.h"
  26.  
  27. int depth;
  28. %}
  29.  
  30. %%
  31.  
  32. "&&"    return t_and;
  33. "||"    return t_or;
  34. "=="    return t_eq;
  35. "!="    return t_neq;
  36. "<="    return t_le;
  37. ">="    return t_be;
  38. "<<"    return t_shl;
  39. ">>"    return t_shr;
  40.  
  41. "dmin"    return t_dmin;
  42. "mmin"    return t_mmin;
  43.  
  44. "abs"    return t_abs;
  45. "add"    return t_add;
  46. "cnv"    return t_cnv;
  47. "ctl"    return t_ctl;
  48. "dif"    return t_dif;
  49. "get"    return t_get;
  50. "put"    return t_put;
  51. "max"    return t_max;
  52. "min"    return t_min;
  53. "mix"    return t_mix;
  54. "rnd"    return t_rnd;
  55. "scl"    return t_scl;
  56. "sqr"    return t_sqr;
  57. "src"    return t_src;
  58. "sub"    return t_sub;
  59. "val"    return t_val;
  60. "c2d"    return t_c2d;
  61. "c2m"    return t_c2m;
  62. "cos"    return t_cos;
  63. "r2x"    return t_r2x;
  64. "r2y"    return t_r2y;
  65. "rad"    return t_rad;
  66. "sin"    return t_sin;
  67. "tan"    return t_tan;
  68.  
  69. [\r\n\t" "]    /* ignore NL/CR/TAB/SPACE */
  70.  
  71. [0-9]+  {
  72.         yylval=malloc(sizeof(s_afstree));
  73.         yylval->op_type=OP_CONST;
  74.         yylval->value=atoi(yytext); 
  75.         yylval->nodes=NULL;
  76.         return v_int; 
  77.     }
  78.  
  79. "("    { depth++; return yytext[0]; }
  80. ")"    { if (depth>0) depth--; return yytext[0]; }
  81. ","    { if (depth>0) return yytext[0]; else return t_comma; }
  82. .    return yytext[0];
  83.  
  84. %%
  85.  
  86. void do_parse(char *s)  
  87. {
  88.         YY_BUFFER_STATE yy_buffer_state;
  89.     depth=0;
  90.         yy_buffer_state=yy_scan_string(s);
  91.         yyparse();
  92.         yy_delete_buffer(yy_buffer_state);
  93. }
  94.