1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 /* Author: Patrick Daehne */
42 #if __GNUC__ >= 4 || __GNUC_MINOR__ >=3
43 #pragma GCC diagnostic ignored "-Wold-style-cast"
45 #if __GNUC__ >= 4 || __GNUC_MINOR__ >=3
46 #pragma GCC diagnostic ignored "-Wsign-compare"
48 #if __GNUC__ >= 4 || __GNUC_MINOR__ >=3
49 #pragma GCC diagnostic ignored "-Weffc++"
53 #pragma warning (disable : 111 810)
56 #define YY_NEVER_INTERACTIVE 1
57 #define YY_NO_UNISTD_H 1 // Makes problems on Windows
59 #include "OSGScanParseLexer.h"
64 #pragma set woff 1174,1552,1110,1209
67 #if defined(OSG_LINUX_ICC) || defined(OSG_WIN32_ICL)
68 #pragma warning( disable : 193 810 177 279 111 )
73 %option yyclass="OSGScanParseLexer"
82 hex [+\-]?0[xX][0-9a-fA-F]+
84 double [+\-]?((([0-9]+(\.)?)|([0-9]*\.[0-9]+))([eE][+\-]?[0-9]+)?)
85 /* Not VRML conformant */
86 IdFirstChar [^\x00-\x19 "#'+,\-.0-9[\\\]{}\x7f]
87 /* Not VRML conformant */
88 IdRestChar [^\x00-\x19 "#',.[\\\]{}\x7f]
89 Id {IdFirstChar}{IdRestChar}*
98 int tmp = expectToken;
104 <INITIAL>{utf8bom} BEGIN(HEADER);
105 <INITIAL,HEADER>[\r\n \t]+ BEGIN(HEADER);
106 <INITIAL,HEADER>#.* BEGIN(NODE); lvalp->stringVal = yytext; return TOK_HEADER;
108 PROFILE BEGIN(NODE); return TOK_PROFILE;
109 COMPONENT BEGIN(NODE); return TOK_COMPONENT;
110 META BEGIN(NODE); return TOK_META;
112 PROTO BEGIN(NODE); return TOK_PROTO;
113 EXTERNPROTO BEGIN(NODE); return TOK_EXTERNPROTO;
114 IS BEGIN(NODE); return TOK_IS;
116 DEF BEGIN(NODE); return TOK_DEF;
117 USE BEGIN(NODE); return TOK_USE;
119 ROUTE BEGIN(NODE); return TOK_ROUTE;
120 TO BEGIN(NODE); return TOK_TO;
122 IMPORT BEGIN(NODE); return TOK_IMPORT;
123 EXPORT BEGIN(NODE); return TOK_EXPORT;
124 AS BEGIN(NODE); return TOK_AS;
126 eventIn BEGIN(NODE); return TOK_eventIn;
127 inputOnly BEGIN(NODE); return TOK_eventIn;
128 eventOut BEGIN(NODE); return TOK_eventOut;
129 outputOnly BEGIN(NODE); return TOK_eventOut;
130 exposedField BEGIN(NODE); return TOK_exposedField;
131 inputOutput BEGIN(NODE); return TOK_exposedField;
132 field BEGIN(NODE); return TOK_field;
133 initializeOnly BEGIN(NODE); return TOK_field;
134 ClusterLocal BEGIN(NODE); return TOK_ClusterLocal;
135 ThreadLocal BEGIN(NODE); return TOK_ThreadLocal;
137 MFBool BEGIN(NODE); lvalp->intVal = TOK_MFBool; return TOK_MFBool;
138 MFColor BEGIN(NODE); lvalp->intVal = TOK_MFColor; return TOK_MFColor;
139 MFColorRGBA BEGIN(NODE); lvalp->intVal = TOK_MFColorRGBA; return TOK_MFColorRGBA;
140 MFDouble BEGIN(NODE); lvalp->intVal = TOK_MFDouble; return TOK_MFDouble;
141 MFFloat BEGIN(NODE); lvalp->intVal = TOK_MFFloat; return TOK_MFFloat;
142 MFImage BEGIN(NODE); lvalp->intVal = TOK_MFImage; return TOK_MFImage;
143 MFInt32 BEGIN(NODE); lvalp->intVal = TOK_MFInt32; return TOK_MFInt32;
144 MFMatrix3d BEGIN(NODE); lvalp->intVal = TOK_MFMatrix3d; return TOK_MFMatrix3d;
145 MFMatrix3f BEGIN(NODE); lvalp->intVal = TOK_MFMatrix3f; return TOK_MFMatrix3f;
146 MFMatrix4d BEGIN(NODE); lvalp->intVal = TOK_MFMatrix4d; return TOK_MFMatrix4d;
147 MFMatrix4f BEGIN(NODE); lvalp->intVal = TOK_MFMatrix4f; return TOK_MFMatrix4f;
148 MFNode BEGIN(NODE); lvalp->intVal = TOK_MFNode; return TOK_MFNode;
149 MFRotation BEGIN(NODE); lvalp->intVal = TOK_MFRotation; return TOK_MFRotation;
150 MFString BEGIN(NODE); lvalp->intVal = TOK_MFString; return TOK_MFString;
151 MFTime BEGIN(NODE); lvalp->intVal = TOK_MFTime; return TOK_MFTime;
152 MFVec2d BEGIN(NODE); lvalp->intVal = TOK_MFVec2d; return TOK_MFVec2d;
153 MFVec2f BEGIN(NODE); lvalp->intVal = TOK_MFVec2f; return TOK_MFVec2f;
154 MFVec3d BEGIN(NODE); lvalp->intVal = TOK_MFVec3d; return TOK_MFVec3d;
155 MFVec3f BEGIN(NODE); lvalp->intVal = TOK_MFVec3f; return TOK_MFVec3f;
156 MFVec4d BEGIN(NODE); lvalp->intVal = TOK_MFVec4d; return TOK_MFVec4d;
157 MFVec4f BEGIN(NODE); lvalp->intVal = TOK_MFVec4f; return TOK_MFVec4f;
158 SFBool BEGIN(NODE); lvalp->intVal = TOK_SFBool; return TOK_SFBool;
159 SFColor BEGIN(NODE); lvalp->intVal = TOK_SFColor; return TOK_SFColor;
160 SFColorRGBA BEGIN(NODE); lvalp->intVal = TOK_SFColorRGBA; return TOK_SFColorRGBA;
161 SFDouble BEGIN(NODE); lvalp->intVal = TOK_SFDouble; return TOK_SFDouble;
162 SFFloat BEGIN(NODE); lvalp->intVal = TOK_SFFloat; return TOK_SFFloat;
163 SFImage BEGIN(NODE); lvalp->intVal = TOK_SFImage; return TOK_SFImage;
164 SFInt32 BEGIN(NODE); lvalp->intVal = TOK_SFInt32; return TOK_SFInt32;
165 SFMatrix3d BEGIN(NODE); lvalp->intVal = TOK_SFMatrix3d; return TOK_SFMatrix3d;
166 SFMatrix3f BEGIN(NODE); lvalp->intVal = TOK_SFMatrix3f; return TOK_SFMatrix3f;
167 SFMatrix4d BEGIN(NODE); lvalp->intVal = TOK_SFMatrix4d; return TOK_SFMatrix4d;
168 SFMatrix4f BEGIN(NODE); lvalp->intVal = TOK_SFMatrix4f; return TOK_SFMatrix4f;
169 SFNode BEGIN(NODE); lvalp->intVal = TOK_SFNode; return TOK_SFNode;
170 SFRotation BEGIN(NODE); lvalp->intVal = TOK_SFRotation; return TOK_SFRotation;
171 SFString BEGIN(NODE); lvalp->intVal = TOK_SFString; return TOK_SFString;
172 SFTime BEGIN(NODE); lvalp->intVal = TOK_SFTime; return TOK_SFTime;
173 SFVec2d BEGIN(NODE); lvalp->intVal = TOK_SFVec2d; return TOK_SFVec2d;
174 SFVec2f BEGIN(NODE); lvalp->intVal = TOK_SFVec2f; return TOK_SFVec2f;
175 SFVec3d BEGIN(NODE); lvalp->intVal = TOK_SFVec3d; return TOK_SFVec3d;
176 SFVec3f BEGIN(NODE); lvalp->intVal = TOK_SFVec3f; return TOK_SFVec3f;
177 SFVec4d BEGIN(NODE); lvalp->intVal = TOK_SFVec4d; return TOK_SFVec4d;
178 SFVec4f BEGIN(NODE); lvalp->intVal = TOK_SFVec4f; return TOK_SFVec4f;
179 /* The following types are not VRML conformant */
180 MFColor4f BEGIN(NODE); lvalp->intVal = TOK_MFColorRGBA; return TOK_MFColorRGBA;
181 MFColor4i BEGIN(NODE); lvalp->intVal = TOK_MFColor4i; return TOK_MFColor4i;
182 MFColor3f BEGIN(NODE); lvalp->intVal = TOK_MFColor; return TOK_MFColor;
183 MFMatrix BEGIN(NODE); lvalp->intVal = TOK_MFMatrix4f; return TOK_MFMatrix4f;
184 MFPnt2f BEGIN(NODE); lvalp->intVal = TOK_MFPnt2f; return TOK_MFPnt2f;
185 MFPnt3f BEGIN(NODE); lvalp->intVal = TOK_MFPnt3f; return TOK_MFPnt3f;
186 MFPnt4f BEGIN(NODE); lvalp->intVal = TOK_MFPnt4f; return TOK_MFPnt4f;
187 MFPlane BEGIN(NODE); lvalp->intVal = TOK_MFPlane; return TOK_MFPlane;
188 SFColor4f BEGIN(NODE); lvalp->intVal = TOK_SFColorRGBA; return TOK_SFColorRGBA;
189 SFColor4i BEGIN(NODE); lvalp->intVal = TOK_SFColor4i; return TOK_SFColor4i;
190 SFColor3f BEGIN(NODE); lvalp->intVal = TOK_SFColor; return TOK_SFColor;
191 SFMatrix BEGIN(NODE); lvalp->intVal = TOK_SFMatrix4f; return TOK_SFMatrix4f;
192 SFPnt2f BEGIN(NODE); lvalp->intVal = TOK_SFPnt2f; return TOK_SFPnt2f;
193 SFPnt3f BEGIN(NODE); lvalp->intVal = TOK_SFPnt3f; return TOK_SFPnt3f;
194 SFPnt4f BEGIN(NODE); lvalp->intVal = TOK_SFPnt4f; return TOK_SFPnt4f;
195 SFPlane BEGIN(NODE); lvalp->intVal = TOK_SFPlane; return TOK_SFPlane;
196 SFVolume BEGIN(NODE); lvalp->intVal = TOK_SFVolume; return TOK_SFVolume;
200 lvalp->intVal = strtoul(yytext, 0, 0);
201 if (imageIntsExpected > 0)
202 if ((--imageIntsExpected == 0) || (*yytext == '-')) /* Not VRML conformant */
204 imageIntsExpected = 0;
205 expectToken = TOK_ImageFinished;
211 lvalp->intVal = strtoul(yytext, 0, 0);
212 if (imageIntsExpected > 0)
213 if ((--imageIntsExpected == 0) || (*yytext == '-')) /* Not VRML conformant */
215 imageIntsExpected = 0;
216 expectToken = TOK_ImageFinished;
220 {double} BEGIN(NODE); lvalp->doubleVal = strtod(yytext, 0); return TOK_double;
221 /* Not VRML conformant */
222 [Tt][Rr][Uu][Ee] BEGIN(NODE); lvalp->boolVal = true; return TOK_bool;
223 /* Not VRML conformant */
224 [Ff][Aa][Ll][Ss][Ee] BEGIN(NODE); lvalp->boolVal = false; return TOK_bool;
225 NULL BEGIN(NODE); return TOK_NULL;
226 {Id} BEGIN(NODE); lvalp->stringVal = yytext; return TOK_Id;
228 "\"" tmpStr.erase(); BEGIN STRING;
229 <STRING>"\\\\" tmpStr.append(1, '\\');
230 <STRING>"\\\"" tmpStr.append(1, '"');
231 <STRING>[^"] tmpStr.append(1, yytext[0]);
232 <STRING>"\"" BEGIN(NODE); lvalp->stringVal = tmpStr.c_str(); return TOK_string;
233 <STRING><<EOF>> BEGIN(NODE); return TOK_Error;
235 "{" BEGIN(NODE); return '{';
236 "}" BEGIN(NODE); return '}';
237 "[" BEGIN(NODE); return '[';
238 "]" BEGIN(NODE); return ']';
239 "." BEGIN(NODE); return '.';
240 /*":" BEGIN(NODE); return ':';*/
242 <NODE>"#" BEGIN(COMMENT);
244 <COMMENT>"\n" BEGIN(NODE);
255 #pragma warning (default : 111 810)