10 /* $XConsortium: defToken.l /main/5 1996/11/19 16:54:10 drk $ */
13 #include "FeatureDefDictionary.h"
14 #include "defParser.tab.h"
19 extern istream *g_yyin;
21 #define YY_INPUT(buf,result,max_size)\
23 if (g_yyin -> eof()) {\
26 g_yyin -> read((char *)buf, max_size-1); \
27 result = g_yyin -> gcount(); \
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;
38 unsigned char* new_copy(const unsigned char* str, int size)
40 unsigned char* x = new unsigned char[ ( size <= 0 ) ? 1 : size + 1];
46 void addToDefTokenStringBuf(const unsigned char* str, int size)
48 if ( size <= 0 ) return;
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;
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;
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])
107 return(OPER_parenopen);
111 return(OPER_parenclose);
116 yylval.charPtrData = new_copy((unsigned char*)yytext, yyleng);
121 yylval.charPtrData = new_copy((unsigned char*)yytext, yyleng);
126 yylval.charPtrData = new_copy((unsigned char*)yytext, yyleng);
131 yylval.charPtrData = new_copy((unsigned char*)yytext, yyleng);
136 yylval.charPtrData = new_copy((unsigned char*)yytext, yyleng);
141 yylval.charPtrData = new_copy((unsigned char*)yytext, yyleng);
146 yylval.charPtrData = new_copy((unsigned char*)yytext, yyleng);
152 new_copy((unsigned char*)"INTEGER", strlen("INTEGER"));
157 yylval.intData = atoi((char*)yytext);
162 yylval.realData = atof((char*)yytext);
173 new unsigned char[defToken_string_buf_content_size+1];
174 memcpy( yylval.charPtrData,
176 defToken_string_buf_content_size+1
179 defToken_string_buf_content_size = 0;
182 return(QUOTED_STRING);
186 addToDefTokenStringBuf(yytext, yyleng);
189 "&"[^ \t\n\";.=@+*\/\.\*:?\^,{}\[\]()]+ {
191 (unsigned char*)strdup((const char*)(yytext+1));
195 [^ \t\n\";.=@+*\/\.\*:?\^,{}\[\]()]+ {
197 (unsigned char*)strdup((const char*)yytext);
198 return(NORMAL_STRING);
215 void yyerror(char* msg)
217 cerr << "line " << yylineno << ": " << msg;