Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / tas / tut / txtarea.l
1 %{
2 #include MUT_H
3 #include <string.h>
4 #include "txtarea.tab.h"
5
6 #define YY_NO_UNPUT
7
8 int txt_flagwidth=0;
9 int txt_flagheight=0;
10 int txt_flagwidth2=0;
11 int txt_flagheight2=0;
12 int txt_flagarea=0;
13 extern ht *tut_tablasharea;
14 long txt_get;
15 char *txt_name;
16 double txt_width;
17 double txt_height;
18 %}
19
20 upper_alpha [A-Z]
21 lower_alpha [a-z]
22 num [0-9]
23 alpha ({upper_alpha}|{lower_alpha})
24 alphanum ({alpha}|{num})
25 number -?{num}+(\.({num}*))?
26 ident {alpha}(([[|./:_]?)+{alphanum}((\[|\\\[|$){num}+(\]|\\\]|$))?)*
27
28 width [wW][iI][dD][tT][hH]
29 height [hH][eE][iI][gG][hH][tT]
30 area [aA][rR][eE][aA]
31
32 wsp [ \t\n\r]*
33
34
35
36 %%
37
38 {width} { txt_flagwidth=1 ;}
39
40 {height} { txt_flagheight=1 ;}
41
42 {area} { txt_flagarea=1 ;}
43
44 {ident} {
45 if(!txt_flagarea && txt_flagwidth2 && txt_flagheight2){
46 txt_flagwidth2=0;
47 txt_flagheight2=0;
48 txt_get=addhtitem(tut_tablasharea,txt_name,(long)(txt_width*txt_height*1000.0));
49 }
50 else if(txt_flagarea){
51 txt_flagarea=0;
52 }
53 txtarealval.text = namealloc (yytext) ;
54 txt_name=txtarealval.text;
55 }
56
57 {number} {
58 if(txt_flagarea) {
59 txtarealval.real = strtod (yytext, (char**)NULL);
60 txt_get=addhtitem(tut_tablasharea,txt_name,(long)(txtarealval.real*1000.0));
61 }
62 else if(txt_flagwidth) {
63 txt_width = strtod (yytext, (char**)NULL);
64 txt_flagwidth2=1;
65 txt_flagwidth=0;
66 }
67 else if(txt_flagheight) {
68 txt_height = strtod (yytext, (char**)NULL);
69 txt_flagheight2=1;
70 txt_flagheight=0;
71 }
72
73 }
74 {wsp} {;}
75
76 %%
77
78
79
80 int yywrap () { return 1 ; }