2 * $TOG: tokenStyle.l /main/6 1998/04/17 11:50:07 mgreess $
4 * Copyright (c) 1993 HAL Computer Systems International, Ltd.
5 * All rights reserved. Unpublished -- rights reserved under
6 * the Copyright Laws of the United States. USE OF A COPYRIGHT
7 * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
10 * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
11 * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
12 * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
13 * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
16 * RESTRICTED RIGHTS LEGEND
17 * Use, duplication, or disclosure by the Government is subject
18 * to the restrictions as set forth in subparagraph (c)(l)(ii)
19 * of the Rights in Technical Data and Computer Software clause
20 * at DFARS 252.227-7013.
22 * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
38 #include "ParserConst.h"
39 #include "Expression.h"
40 #include "FeatureValue.h"
41 #include "PathTable.h"
43 #include "PathQualifier.h"
44 #include "StyleSheetExceptions.h"
45 #include "style.tab.h"
49 extern istream *g_stylein ;
51 #define YY_INPUT(buf,result,max_size)\
53 if (g_stylein -> eof()) {\
56 g_stylein -> read((char*)buf, max_size-1); \
57 result = g_stylein -> gcount(); \
62 unsigned char* qstring_buf = new unsigned char[1024];
63 int qstring_buf_size = 1024;
64 int qstring_buf_content_size = 0;
66 char* commentBuffer = new char [1024];
67 int commentBufferSize = 1024;
68 int commentBufferContentSize = 0;
72 void addToQstringBuf(const unsigned char* str, int size)
74 if ( size <= 0 ) return;
76 if ( qstring_buf_size - qstring_buf_content_size < size ) {
77 qstring_buf_size = 2*(size+qstring_buf_content_size);
78 unsigned char* x = new unsigned char[qstring_buf_size];
79 memcpy(x, qstring_buf, qstring_buf_content_size);
84 memcpy(qstring_buf + qstring_buf_content_size, str, size);
85 qstring_buf_content_size += size;
86 qstring_buf[qstring_buf_content_size] = 0;
91 unit ([Ii][Nn]|[Ii][Nn][Cc][Hh]|[Pp][Cc]|[Pp][Ii][Cc][Aa]|[Pp][Tt]|[Pp][Oo][Ii][Nn][Tt]|[Pp][Ii][Xx][Ee][Ll]|[Cc][Mm])
93 %x block sgmlgimode quoted_string
100 if ( commentBufferSize < yyleng ) {
101 delete commentBuffer;
102 commentBufferSize = 2 * yyleng ;
103 commentBuffer = new char [commentBufferSize];
106 commentBufferContentSize = yyleng-1;
107 memcpy(commentBuffer, yytext+1, commentBufferContentSize); // copy everything except the #
108 commentBuffer[commentBufferContentSize] = 0;
120 yylval.charData = yytext[0];
125 yylval.charData = yytext[0];
130 yylval.charData = yytext[0];
139 yylval.charData = yytext[0];
176 return(OPER_parenopen);
180 return(OPER_parenclose);
192 if ( strcmp((const char*)yytext, "==") == 0 )
193 yylval.intData = EQUAL;
195 yylval.intData = NOT_EQUAL;
197 return(OPER_equality);
201 return(OPER_logicalnegate);
205 if ( strcmp((const char*)yytext, "<=") == 0 )
206 yylval.intData = LESS_OR_EQUAL;
208 if ( strcmp((const char*)yytext, "<") == 0 )
209 yylval.intData = LESS;
211 if ( strcmp((const char*)yytext, ">=") == 0 )
212 yylval.intData = GREATER_OR_EQUAL;
214 yylval.intData = GREATER;
216 return(OPER_relational);
220 return(GI_CASE_SENSITIVE);
224 yylval.boolData = true;
228 [Ff][Aa][Ll][Ss][Ee] {
229 yylval.boolData = false;
234 yylval.boolData = true;
239 yylval.boolData = false;
243 [0-9]+("."[0-9]+)?{unit} {
245 (unsigned char*)strdup((const char*)yytext);
250 yylval.intData = atoi((char*)yytext);
255 yylval.realData = atof((char*)yytext);
266 new unsigned char[qstring_buf_content_size+1];
267 memcpy( yylval.charPtrData,
269 qstring_buf_content_size+1
272 qstring_buf_content_size = 0;
275 return(QUOTED_STRING);
279 int c = styleinput();
282 addToQstringBuf((unsigned char*)"\"", 1);
285 addToQstringBuf((unsigned char*)"\\", 1);
288 throw(CASTSSEXCEPT StyleSheetException());
292 <quoted_string>[^\\\"]* {
293 addToQstringBuf((unsigned char*)yytext, yyleng);
297 addToQstringBuf((unsigned char*)yytext, yyleng);
302 (unsigned char*)strdup((const char*)yytext);
306 [^ \t\n\".=@+*\/\.\*:?\^,{}\[\]()!]+ {
308 (unsigned char*)strdup((const char*)yytext);
309 return(NORMAL_STRING);
312 <sgmlgimode>[0-9a-zA-Z\.\-]+ {
314 (unsigned char*)strdup((const char*)yytext);
316 return(SGMLGI_STRING);
331 <block>"|#" { BEGIN(0); }
336 void enter_sgmlgi_context()
342 void report_error_location()
344 if ( commentBufferContentSize > 0 ) {
345 cerr << commentBuffer << "\n";
349 void yyerror(char* msg)
352 cerr << "line " << yylineno << ": " << msg << "\n";
354 throw(CASTSSSEEXCEPT StyleSheetSyntaxError());