Disable all code related to libXp
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / StyleSheet / defToken.l
1
2 %a 30000
3 %e 10000
4 %k 10000
5 %n 10000
6 %o 40000
7 %p 20000
8
9 %{
10 /* $XConsortium: defToken.l /main/5 1996/11/19 16:54:10 drk $ */
11
12 #include <string.h>
13 #include "FeatureDefDictionary.h"
14 #include "defParser.tab.h"
15 #include "Debug.h"
16 #include <iostream>
17 using namespace std;
18
19 extern istream *g_yyin;
20
21 #define YY_INPUT(buf,result,max_size)\
22   {\
23      if (g_yyin -> eof()) {\
24         result=0;\
25      } else {\
26         g_yyin -> read((char *)buf, max_size-1); \
27         result = g_yyin -> gcount(); \
28         buf[result] = 0; \
29      }\
30   }
31
32 int yylineno=1;
33
34 unsigned char* defToken_string_buf = new unsigned char[1024];
35 int defToken_string_buf_size = 1024;
36 int defToken_string_buf_content_size = 0;
37
38 unsigned char* new_copy(const unsigned char* str, int size)
39 {
40    unsigned char* x = new unsigned char[ ( size <= 0 ) ? 1 : size + 1];
41    memcpy(x, str, size);
42    x[size] = 0;
43    return x;
44 }
45
46 void addToDefTokenStringBuf(const unsigned char* str, int size)
47 {
48    if ( size <= 0 ) return;
49
50    if ( defToken_string_buf_size - defToken_string_buf_content_size < size ) {
51       defToken_string_buf_size = 2*(size+defToken_string_buf_content_size);
52       unsigned char* x = new unsigned char[defToken_string_buf_size];
53       memcpy(x, defToken_string_buf, defToken_string_buf_content_size);
54       delete defToken_string_buf;
55       defToken_string_buf = x;
56    }
57
58    memcpy(defToken_string_buf + defToken_string_buf_content_size, str, size);
59    defToken_string_buf_content_size += size;
60    defToken_string_buf[defToken_string_buf_content_size] = 0;
61 }
62
63
64
65 %}
66
67 stringprefix ([Ss][Tt][Rr][Ii][Nn][Gg][_][Pp][Rr][Ee][Ff][Ii][Xx])
68 string ([Ss][Tt][Rr][Ii][Nn][Gg])
69 integer ([Ii][Nn][Tt][Ee][Gg][Ee][Rr])
70 array([Aa][Rr][Rr][Aa][Yy])
71 real ([Rr][Ee][Aa][Ll])
72 unit ([Dd][Ii][Mm][Ee][Nn][Ss][Ii][Oo][Nn])
73 unitpixel ([Dd][Ii][Mm][Ee][Nn][Ss][Ii][Oo][Nn][_][Pp][Ii][Xx][Ee][Ll])
74 boolean ([Bb][Oo][Oo][Ll][Ee][Aa][Nn])
75 %x quoted_string
76
77 %%
78
79 ^"#".*  {
80         }
81
82 ","     {
83            return(COMMA);
84         }
85
86 "*"     {
87            return(STAR);
88         }
89
90 ";"     {
91            return(SEMI_COLON);
92         }
93
94 ":"     {
95            return(COLON);
96         }
97
98 "{"     {
99            return(FSOPEN);
100         }
101
102 "}"     {
103            return(FSCLOSE);
104         }
105
106 "("     {
107            return(OPER_parenopen);
108         }
109
110 ")"     {
111            return(OPER_parenclose);
112         }
113
114
115 {stringprefix} {
116                 yylval.charPtrData = new_copy((unsigned char*)yytext, yyleng);
117                 return(TYPE);
118         }
119
120 {string} {
121                 yylval.charPtrData = new_copy((unsigned char*)yytext, yyleng);
122                 return(TYPE);
123         }
124
125 {integer} {
126                 yylval.charPtrData = new_copy((unsigned char*)yytext, yyleng);
127                 return(TYPE);
128         }
129
130 {real} {
131                 yylval.charPtrData = new_copy((unsigned char*)yytext, yyleng);
132                 return(TYPE);
133         }
134
135 {unit} {
136                 yylval.charPtrData = new_copy((unsigned char*)yytext, yyleng);
137                 return(TYPE);
138         }
139
140 {unitpixel} {
141                 yylval.charPtrData = new_copy((unsigned char*)yytext, yyleng);
142                 return(TYPE);
143         }
144
145 {array} {
146                 yylval.charPtrData = new_copy((unsigned char*)yytext, yyleng);
147                 return(TYPE);
148         }
149
150 {boolean} {
151                 yylval.charPtrData = 
152                    new_copy((unsigned char*)"INTEGER", strlen("INTEGER"));
153                 return(TYPE);
154         }
155
156 [0-9]+          {
157                 yylval.intData = atoi((char*)yytext);
158                 return(INTEGER);
159                 }
160
161 [0-9]+"."[0-9]+ {
162                 yylval.realData = atof((char*)yytext);
163                 return(REAL);
164                 }
165
166 \"              {
167                 BEGIN quoted_string;
168                 }
169
170 <quoted_string>\"       {
171
172                 yylval.charPtrData = 
173                         new unsigned char[defToken_string_buf_content_size+1];
174                 memcpy( yylval.charPtrData, 
175                         defToken_string_buf, 
176                         defToken_string_buf_content_size+1
177                       );
178
179                 defToken_string_buf_content_size = 0;
180                 BEGIN 0;
181
182                 return(QUOTED_STRING);
183                 }
184
185 <quoted_string>.        {
186                 addToDefTokenStringBuf(yytext, yyleng);
187                 }
188
189 "&"[^ \t\n\";.=@+*\/\.\*:?\^,{}\[\]()]+ {
190                 yylval.charPtrData = 
191                   (unsigned char*)strdup((const char*)(yytext+1));
192                 return(REF_NAME);
193                 }
194
195 [^ \t\n\";.=@+*\/\.\*:?\^,{}\[\]()]+    {
196                 yylval.charPtrData = 
197                   (unsigned char*)strdup((const char*)yytext);
198                 return(NORMAL_STRING);
199                 }
200
201 [\t]    {
202         }
203
204 [\n]    {
205            yylineno++;
206         }
207
208 .       {
209         }
210
211
212
213 %%
214
215 void yyerror(char* msg)
216 {
217    cerr << "line " << yylineno << ": " << msg;
218 }
219