~ubuntu-branches/ubuntu/vivid/meshlab/vivid

« back to all changes in this revision

Viewing changes to meshlab/src/meshlabplugins/io_x3d/vrml/VrmlTranslator.atg

  • Committer: Bazaar Package Importer
  • Author(s): Teemu Ikonen
  • Date: 2011-03-28 17:54:11 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110328175411-ntj9e50d1yl0luzb
Tags: 1.3.0a+dfsg1-1
* New upstream version (closes: #618522)
* Repackage the upstream sources to get rid of some files with questionable
  licensing information and useless libraries, see the copyright file for
  details.
* Builds with GCC-4.5 (closes: #565034)
* Fix watch-file to work with new upstream names and dfsg source
  (closes: #582477)
* Require debhelper version 8 or above.
* control:
  - Update standards-version to 3.9.1, cleanup.
  - Remove build-dep to libgl-dev to fix a lintian warning about a
    build-dep to a virtual package.
  - Remove build-dep to asciidoc, add build-dep to libeigen2-dev.
* rules:
  - Remove manpage-related code.
  - Build the necessary code from meshlab/src/external. Also clean it.
  - Override dh_shlibdeps to include /usr/lib/meshlab in search path.
  - Don't install shader licenses.
* install: Install binaries from meshlab/src/distrib.
* copyright: Update to the latest DEP5 format, document changes due to
  source repackaging and add the copyright info for the files added in
  this upstream release.
* Hardcode shadersDir and pluginDir in upstream source to locations
  in the Debian binary package.
* Use source format '3.0 (quilt)'.
* Split changes affecting upstream code to branches in the git repository
  at git.d.o. Add DEP3 patch metadata headers to debian/metapatches and
  generate patches from git branches with gdp (http://gitorious.org/gdp).
  Current patches:
  - 01_muparser: Use Debian muparser.
  - 02_qhull: Use Debian qhull.
  - 03_lib3ds: Use Debian lib3ds.
  - 04_libbz2: Use Debian libbz2.
  - 05_glew: Use Debian GLEW.
  - 06_eigen: Use Debian Eigen.
  - 07_disable-updates: Disable checking for updates on startup.
  - 08_externals: Only build necessary external sources.
  - 09_rpath: Use /usr/lib/meshlab as RPATH in binaries.
  - 10_shadersdir: Hardcode shadersDir to the correct path in Debian
  - 11_pluginsdir: Hardcode pluginsDir to the correct path in Debian
* Add a README.source file documenting the patch generation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <QtXml>
2
 
#include <set>
3
 
 
4
 
COMPILER VrmlTranslator
5
 
 
6
 
        QDomDocument *doc;
7
 
        
8
 
        std::map<QString, QString> defNode;
9
 
        
10
 
        std::set<QString> proto;
11
 
        
12
 
        std::set<QString> x3dNode;
13
 
        
14
 
        void InitX3dNode()
15
 
        {
16
 
          x3dNode.insert("Arc2D"); x3dNode.insert("ArcClose2D"); x3dNode.insert("BallJoint");
17
 
          x3dNode.insert("BooleanFilter"); x3dNode.insert("BooleanSequencer"); x3dNode.insert("BooleanToggle");
18
 
          x3dNode.insert("BooleanTrigger"); x3dNode.insert("BoundedPhysicsModel"); x3dNode.insert("CADAssembly");
19
 
          x3dNode.insert("CADFace"); x3dNode.insert("CADLayer"); x3dNode.insert("CADPart");
20
 
          x3dNode.insert("Circle2D"); x3dNode.insert("ClipPlane"); x3dNode.insert("CollidableOffset");
21
 
          x3dNode.insert("CollidableShape"); x3dNode.insert("CollisionCollection"); x3dNode.insert("CollisionSensor");
22
 
          x3dNode.insert("CollisionSpace"); x3dNode.insert("ColorDamper");x3dNode.insert("ColorRGBA");
23
 
          x3dNode.insert("ComposedCubeMapTexture"); x3dNode.insert("ComposedShader");
24
 
          x3dNode.insert("ComposedTexture3D"); x3dNode.insert("ConeEmitter"); x3dNode.insert("Contact");
25
 
          x3dNode.insert("Contour2D"); x3dNode.insert("ContourPolyline2D"); x3dNode.insert("CoordinateDamper");
26
 
          x3dNode.insert("CoordinateDouble"); x3dNode.insert("CoordinateInterpolator2D");
27
 
          x3dNode.insert("DISEntityManager"); x3dNode.insert("DISEntityTypeMapping");
28
 
          x3dNode.insert("Disk2D"); x3dNode.insert("DoubleAxisHingeJoint"); x3dNode.insert("EaseInEaseOut");
29
 
          x3dNode.insert("EspduTransform"); x3dNode.insert("ExplosionEmitter");
30
 
          x3dNode.insert("FillProperties"); x3dNode.insert("FloatVertexAttribute");
31
 
          x3dNode.insert("FogCoordinate"); x3dNode.insert(" GeneratedCubeMapTexture");
32
 
          x3dNode.insert("GeoCoordinate"); x3dNode.insert("GeoElevationGrid"); x3dNode.insert("GeoLocation"); 
33
 
          x3dNode.insert("GeoLOD"); x3dNode.insert("GeoMetadata"); x3dNode.insert("GeoOrigin");
34
 
          x3dNode.insert("GeoPositionInterpolator"); x3dNode.insert("GeoProximitySensor");
35
 
          x3dNode.insert("GeoTouchSensor"); x3dNode.insert("GeoViewpoint");     x3dNode.insert("GravityPhysicsModel");
36
 
          x3dNode.insert("HAnimDisplacer"); x3dNode.insert("HAnimHumanoid"); x3dNode.insert("HAnimJoint");
37
 
          x3dNode.insert("HAnimSegment"); x3dNode.insert("HAnimSite"); x3dNode.insert("ImageCubeMapTexture");
38
 
          x3dNode.insert("ImageTexture3D"); x3dNode.insert("IndexedQuadSet"); x3dNode.insert("IndexedTriangleFanSet");
39
 
          x3dNode.insert("IndexedTriangleSet"); x3dNode.insert("IndexedTriangleStripSet");
40
 
          x3dNode.insert("IntegerSequencer"); x3dNode.insert("IntegerTrigger"); x3dNode.insert("KeySensor");
41
 
          x3dNode.insert("Layer"); x3dNode.insert("LayerSet"); x3dNode.insert("Layout");
42
 
          x3dNode.insert("LayoutGroup"); x3dNode.insert("LayoutLayer"); x3dNode.insert("LinePicker");
43
 
          x3dNode.insert("LineProperties"); x3dNode.insert("LineSet"); x3dNode.insert("LoadSensor");
44
 
          x3dNode.insert("LocalFog"); x3dNode.insert("Material"); x3dNode.insert("Matrix3VertexAttribute"); 
45
 
          x3dNode.insert("Matrix4VertexAttribute"); x3dNode.insert("MetadataDouble");
46
 
          x3dNode.insert("MetadataFloat"); x3dNode.insert("MetadataInteger"); x3dNode.insert("MetadataSet");
47
 
          x3dNode.insert("MetadataString"); x3dNode.insert("MotorJoint"); x3dNode.insert("MultiTexture");
48
 
          x3dNode.insert("MultiTextureCoordinate"); x3dNode.insert("MultiTextureTransform");
49
 
          x3dNode.insert("NurbsCurve"); x3dNode.insert("NurbsCurve2D"); x3dNode.insert("NurbsOrientationInterpolator");
50
 
          x3dNode.insert("NurbsPatchSurface"); x3dNode.insert("NurbsPositionInterpolator"); x3dNode.insert("NurbsSet");
51
 
          x3dNode.insert("NurbsSurfaceInterpolator"); x3dNode.insert("NurbsSweptSurface");
52
 
          x3dNode.insert("NurbsSwungSurface"); x3dNode.insert("NurbsTextureCoordinate");
53
 
          x3dNode.insert("NurbsTrimmedSurface"); x3dNode.insert("OrientationChaser");
54
 
          x3dNode.insert("OrientationDamper"); x3dNode.insert("OrthoViewpoint"); x3dNode.insert("PackagedShader");
55
 
          x3dNode.insert("ParticleSystem"); x3dNode.insert("PickableGroup"); x3dNode.insert("PixelTexture3D");
56
 
          x3dNode.insert("PointEmitter"); x3dNode.insert("PointPicker"); x3dNode.insert("PointSet");
57
 
          x3dNode.insert("Polyline2D"); x3dNode.insert("PolylineEmitter"); x3dNode.insert("Polypoint2D");
58
 
          x3dNode.insert("PositionChaser"); x3dNode.insert("PositionChaser2D"); x3dNode.insert("PositionDamper");
59
 
          x3dNode.insert("PositionDamper2D"); x3dNode.insert("PositionInterpolator2D");
60
 
          x3dNode.insert("PrimitivePicker"); x3dNode.insert("ProgramShader"); x3dNode.insert("QuadSet");
61
 
          x3dNode.insert("ReceiverPdu"); x3dNode.insert("Rectangle2D"); x3dNode.insert("RigidBody");
62
 
          x3dNode.insert("RigidBodyCollection"); x3dNode.insert("ScalarChaser"); x3dNode.insert("ScreenFontStyle");
63
 
          x3dNode.insert("ScreenGroup"); x3dNode.insert("ShaderPart"); x3dNode.insert("ShaderProgram");
64
 
          x3dNode.insert("SignalPdu"); x3dNode.insert("SingleAxisHingeJoint"); x3dNode.insert("SliderJoint");
65
 
          x3dNode.insert("SplinePositionInterpolator"); x3dNode.insert("SplinePositionInterpolator2D");
66
 
          x3dNode.insert("SplineScalarInterpolator"); x3dNode.insert("SquadOrientationInterpolator");
67
 
          x3dNode.insert("StaticGroup"); x3dNode.insert("StringSensor"); x3dNode.insert("SurfaceEmitter");
68
 
          x3dNode.insert("TexCoordDamper"); x3dNode.insert("TextureBackground");
69
 
          x3dNode.insert("TextureCoordiante3D"); x3dNode.insert("TextureCoordinate4D");
70
 
          x3dNode.insert("TextureCoordinateGenerator"); x3dNode.insert("TextureProperties");
71
 
          x3dNode.insert("TextureTransformMatrix3D"); x3dNode.insert("TextureTransform3D");
72
 
          x3dNode.insert("TimeTrigger"); x3dNode.insert("TransformSensor"); x3dNode.insert("TransmitterPdu");
73
 
          x3dNode.insert("TriangleFanSet"); x3dNode.insert("TriangleSet"); x3dNode.insert("TriangleSet2D");
74
 
          x3dNode.insert("TriangleStripSet"); x3dNode.insert("TwoSidedMaterial"); x3dNode.insert("UniversalJoint");
75
 
          x3dNode.insert(" Viewpoint"); x3dNode.insert("ViewpointGroup"); x3dNode.insert("VolumeEmitter");
76
 
          x3dNode.insert("VolumePicker"); x3dNode.insert("WindPhysicsModel");
77
 
        }
78
 
        
79
 
CHARACTERS
80
 
        digit = "0123456789".
81
 
        invalidChar = '\u0000' .. '\u0020'.
82
 
        idRestChar = ANY - invalidChar - '\u0022' - '\u0023' - '\u0027' - '\u002c' -  '\u002e' - '\u005b' - '\u005c' - '\u005d' - '\u007b' -'\u007d' - '\u007f'.
83
 
        idFirstChar = idRestChar - digit - '\u002b' - '\u002d'.
84
 
        hexDigit = digit + "ABCDEFabcdef".
85
 
        notDigit = ANY - digit.
86
 
        regularStringChar  = ANY - '"' - '\\' - '\n' - '\r'.
87
 
        commentCont = ANY - '\n' - '\r'.
88
 
        
89
 
TOKENS
90
 
        id = idFirstChar {idRestChar}.
91
 
        intCont = ['+'|'-']( digit {digit} | ("0x" | "0X") hexDigit {hexDigit}).
92
 
        realCont = ['+'|'-'] ("." digit {digit} [("e" | "E") ["+" | "-"] digit {digit}]
93
 
                        | digit {digit} ( "." {digit} [("e" | "E" ) ["+" | "-"] digit {digit} ] | ("e" | "E") ["+" | "-"] digit {digit})).
94
 
        string = "\""  { regularStringChar
95
 
          | "\\\'" | "\\\"" | "\\\\" | "\\0" | "\\a" | "\\b" | "\\f" | "\\n" | "\\r" | "\\t" | "\\v"
96
 
          | "\\x" hexDigit [hexDigit] [hexDigit] [hexDigit]
97
 
          | "\\u" hexDigit hexDigit hexDigit hexDigit
98
 
          | "\\U" hexDigit hexDigit hexDigit hexDigit hexDigit hexDigit hexDigit hexDigit
99
 
                  | "\n" | "\r" | "\t"
100
 
          } "\"".
101
 
                  
102
 
        x3dVersion = "V3.0" | "V3.1" | "V3.2".
103
 
        vrmlVersion = "V2.0".
104
 
        
105
 
/*PRAGMAS
106
 
        comment = "#" {commentCont}.
107
 
*/
108
 
COMMENTS FROM '#' TO '\n'
109
 
 
110
 
IGNORE '\r' + '\n' + '\t'
111
 
 
112
 
PRODUCTIONS
113
 
 
114
 
VrmlTranslator                          (.QDomElement root = doc->createElement("X3D");
115
 
                                                          QDomElement scene = doc->createElement("Scene");
116
 
                                                          root.appendChild(scene);
117
 
                                                          InitX3dNode();.)
118
 
=   [HeaderStatement]
119
 
        [ProfileStatement]
120
 
        ComponentStatements
121
 
        MetaStatements
122
 
        Statements<scene>               (.doc->appendChild(root);.)
123
 
        .
124
 
        
125
 
HeaderStatement 
126
 
=       "#"("X3D" [x3dVersion] | "VRML" [vrmlVersion]) "utf8" [string].
127
 
 
128
 
 
129
 
ProfileStatement
130
 
=       "PROFILE" ProfileNameId. 
131
 
 
132
 
 
133
 
ProfileNameId
134
 
=       id.
135
 
 
136
 
 
137
 
ComponentStatements 
138
 
=       {ComponentStatement
139
 
        }.
140
 
 
141
 
 
142
 
ComponentStatement 
143
 
=       "COMPONENT" ComponentNameId
144
 
        ":"ComponentSupportLevel. 
145
 
 
146
 
 
147
 
ComponentNameId 
148
 
=       id. 
149
 
 
150
 
 
151
 
ComponentSupportLevel 
152
 
=       intCont.
153
 
 
154
 
 
155
 
ExportStatement                 (.QString str;.)
156
 
=       "EXPORT" NodeNameId<str>
157
 
        "AS" ExportedNodeNameId.
158
 
        
159
 
 
160
 
ImportStatement                 (.QString str;.)
161
 
=       "IMPORT" InlineNodeNameId
162
 
        "."ExportedNodeNameId
163
 
        "AS" NodeNameId<str>.
164
 
 
165
 
        
166
 
MetaStatements 
167
 
=       {MetaStatement 
168
 
        }.
169
 
        
170
 
 
171
 
MetaStatement 
172
 
=       "META" Metakey
173
 
        Metavalue.
174
 
        
175
 
        
176
 
Metakey
177
 
= string.
178
 
 
179
 
 
180
 
Metavalue 
181
 
= string.
182
 
 
183
 
 
184
 
Statements <QDomElement& parent>                
185
 
=       {Statement<parent>                              
186
 
        }.
187
 
 
188
 
        
189
 
Statement <QDomElement& parent> 
190
 
=       NodeStatement<parent>
191
 
        | ImportStatement
192
 
        | ExportStatement
193
 
        | ProtoStatement<parent>
194
 
        | RouteStatement.
195
 
 
196
 
        
197
 
NodeStatement <QDomElement& parent>     (.QString tagName, attrValue;.)
198
 
=       (Node<parent, tagName, "">
199
 
        | "DEF" NodeNameId<attrValue>   
200
 
        Node<parent, tagName, attrValue>
201
 
        | "USE" NodeNameId<attrValue>   (.std::map<QString, QString>::const_iterator iter = defNode.find(attrValue);
202
 
                                                                          if(iter != defNode.end())
203
 
                                                                          {
204
 
                                                                            QDomElement node = doc->createElement(iter->second);
205
 
                                                                            node.setAttribute("USE", attrValue);
206
 
                                                                            parent.appendChild(node);
207
 
                                                                          }.)
208
 
        )
209
 
        .       
210
 
 
211
 
        
212
 
RootNodeStatement <QDomElement& parent> (.QString tagName, attrValue;.)
213
 
=       (Node<parent, tagName, "">
214
 
        | "DEF" NodeNameId<attrValue>    
215
 
        Node<parent, tagName, attrValue>
216
 
        ).
217
 
        
218
 
ProtoStatement <QDomElement& parent>
219
 
=       Proto<parent>
220
 
        | Externproto<parent>.
221
 
 
222
 
        
223
 
ProtoStatements <QDomElement& parent>           
224
 
=       {ProtoStatement<parent>                         
225
 
        }.
226
 
         
227
 
         
228
 
Proto <QDomElement& parent>                             (.QString name; QDomElement node;.)
229
 
=       "PROTO" NodeTypeId<name>                        (.node = doc->createElement("ProtoDeclare");
230
 
                                                                                  node.setAttribute("name", name);
231
 
                                                                                  proto.insert(name);.)
232
 
        "["                                                             (.QDomElement interface = doc->createElement("ProtoInterface");.)
233
 
        InterfaceDeclarations<interface>        (.node.appendChild(interface);.)
234
 
        "]" "{"                                                         (.QDomElement body = doc->createElement("ProtoBody");.) 
235
 
        ProtoBody<body>                                         (.node.appendChild(body);.)
236
 
        "}"                                                                     (.parent.appendChild(node);.)
237
 
        .
238
 
 
239
 
 
240
 
ProtoBody <QDomElement& parent>
241
 
=       ProtoStatements<parent>
242
 
        RootNodeStatement<parent>
243
 
        Statements<parent>.
244
 
 
245
 
        
246
 
InterfaceDeclarations <QDomElement& parent>
247
 
=       {InterfaceDeclaration<parent>
248
 
        }.
249
 
 
250
 
        
251
 
RestrictedInterfaceDeclaration <QDomElement& parent>    (.QString name; QString type; QString val;
252
 
                                                                                                                  QDomElement node = doc->createElement("field");.)
253
 
=       (("inputOnly" | "eventIn") FieldType<type>
254
 
        InputOnlyId<name>                                                                       (.node.setAttribute("accessType", "inputOnly");.) 
255
 
        | ("outputOnly" | "eventOut") FieldType<type>
256
 
        OutputOnlyId<name>                                                                      (.node.setAttribute("accessType", "outputOnly");.)
257
 
        | ("initializeOnly" | "field") FieldType<type>
258
 
        InitializeOnlyId<name>
259
 
        FieldValue<node, "value", false>                                        (.node.setAttribute("accessType", "initializeOnly");.)
260
 
        )                                                                                                       (.node.setAttribute("name", name);
261
 
                                                                                                                  node.setAttribute("type", type);
262
 
                                                                                                                  parent.appendChild(node);.)
263
 
        .
264
 
 
265
 
        
266
 
InterfaceDeclaration <QDomElement& parent>      (.QString name, type, val; QDomElement node;.)
267
 
=       RestrictedInterfaceDeclaration<parent>
268
 
        | ("inputOutput" | "exposedField")
269
 
        FieldType<type> 
270
 
        FieldId<name> 
271
 
        FieldValue<node, "value", false>                (.node = doc->createElement("field");
272
 
                                                                                          node.setAttribute("name", name);
273
 
                                                                                          node.setAttribute("type", type);
274
 
                                                                                          node.setAttribute("accessType", "inputOutput");
275
 
                                                                                          parent.appendChild(node);.)
276
 
        .
277
 
        
278
 
 
279
 
Externproto <QDomElement& parent>                       (.QString name, url;
280
 
                                                                                          QDomElement node = doc->createElement("ExternProtoDeclare");.) 
281
 
=       "EXTERNPROTO" NodeTypeId<name>                   
282
 
        "["     ExternInterfaceDeclarations<node>
283
 
        "]" URLList<url>                                                (.std::set<QString>::const_iterator iter = x3dNode.find(name);
284
 
                                                                                          if (iter == x3dNode.end())
285
 
                                                                                          {
286
 
                                                                                            node.setAttribute("name", name);
287
 
                                                                                            node.setAttribute("url", url);
288
 
                                                                                            parent.appendChild(node);
289
 
                                                                                            proto.insert(name);
290
 
                                                                                          }.)
291
 
        .
292
 
 
293
 
        
294
 
ExternInterfaceDeclarations <QDomElement& parent>
295
 
=       {ExternInterfaceDeclaration<parent>
296
 
        }.
297
 
 
298
 
        
299
 
ExternInterfaceDeclaration <QDomElement& parent>        (.QString type, name;
300
 
                                                                                                          QDomElement node = doc->createElement("field");.)
301
 
=       (("inputOnly" | "eventIn")                      
302
 
        FieldType<type> InputOnlyId<name>                               (.node.setAttribute("accessType", "inputOnly");.)
303
 
        | ("outputOnly" | "eventOut")
304
 
        FieldType<type> OutputOnlyId<name>                              (.node.setAttribute("accessType", "outputOnly");.)
305
 
        | ("initializeOnly" | "field")
306
 
        FieldType<type> InitializeOnlyId<name>                  (.node.setAttribute("accessType", "initializeOnly");.)
307
 
        | ("inputOutput" | "exposedField")
308
 
        FieldType<type> FieldId<name>                                   (.node.setAttribute("accessType", "inputOutput");.)
309
 
        )                                                                                               (.node.setAttribute("name" , name);
310
 
                                                                                                          node.setAttribute("type", type);
311
 
                                                                                                          parent.appendChild(node);.)
312
 
        .
313
 
 
314
 
        
315
 
RouteStatement                                  (.QString str;.)
316
 
=       "ROUTE" NodeNameId<str>
317
 
        "." OutputOnlyId<str>
318
 
        "TO" NodeNameId <str>
319
 
        "." InputOnlyId<str>.
320
 
 
321
 
        
322
 
URLList <QString& url>
323
 
=       string                                          (.url = QString(coco_string_create_char(t->val));.)
324
 
        | "["{string                            (.url.append(coco_string_create_char(t->val)); url.append(" ");.)
325
 
        [',']}"]".
326
 
 
327
 
 
328
 
Node <QDomElement& parent, QString& tagName, const QString defValue>    (.bool flag = false; QDomElement node;.)                
329
 
=       (NodeTypeId<tagName>                                                                                            (.std::set<QString>::const_iterator iter = proto.find(tagName);
330
 
                                                                                                                                                  if (iter != proto.end())
331
 
                                                                                                                                                  {
332
 
                                                                                                                                                    node = doc->createElement("ProtoInstance");
333
 
                                                                                                                                                    node.setAttribute("name", tagName);
334
 
                                                                                                                                                    flag = true;
335
 
                                                                                                                                                  }
336
 
                                                                                                                                                  else
337
 
                                                                                                                                                    node = doc->createElement(tagName);
338
 
                                                                                                                                                  if (defValue != "")
339
 
                                                                                                                                                  {
340
 
                                                                                                                                                    node.setAttribute("DEF", defValue);
341
 
                                                                                                                                                    defNode[defValue] = tagName;
342
 
                                                                                                                                                  }.) 
343
 
        "{" NodeBody<node, flag> "}"
344
 
        | "Script" "{" ScriptBody "}"                                                                           (.node = doc->createElement("Script");.)
345
 
        )                                                                                                                                       (.parent.appendChild(node);.)
346
 
        .
347
 
 
348
 
        
349
 
NodeBody <QDomElement& parent, bool flag>
350
 
=       {NodeBodyElement<parent, flag>
351
 
        }.
352
 
 
353
 
ScriptBody 
354
 
=       {ScriptBodyElement
355
 
        }.
356
 
 
357
 
        
358
 
ScriptBodyElement                                                       (.QString str; QDomElement elem;.)
359
 
=       NodeBodyElement<elem, false>
360
 
        |("inputOnly" | "eventIn") FieldType<str> InputOnlyId<str> ["IS" InputOnlyId<str>]
361
 
        |("outputOnly" | "eventOut") FieldType<str> OutputOnlyId<str> ["IS" OutputOnlyId<str>]
362
 
        |("initializeOnly" | "field") FieldType<str> InitializeOnlyId<str> (FieldValue<elem, "", false> | "IS" InitializeOnlyId<str>)
363
 
        |("inputOutput" | "exposedField") FieldType<str> InputOutputId<str> "IS" InputOutputId<str>.
364
 
        
365
 
        
366
 
NodeBodyElement <QDomElement& parent, bool flag>        (.QString idName, idProto; QDomElement node;.)
367
 
=       id                                                                                              (.idName = QString(coco_string_create_char(t->val));.) 
368
 
        (FieldValue<parent, idName, flag>
369
 
                | "IS" id                                                                       (.idProto = QString(coco_string_create_char(t->val));
370
 
                                                                                                          node = doc->createElement("IS");
371
 
                                                                                                          QDomElement connect = doc->createElement("connect");
372
 
                                                                                                          connect.setAttribute("nodeField", idName);
373
 
                                                                                                          connect.setAttribute("protoField", idProto);
374
 
                                                                                                          node.appendChild(connect);
375
 
                                                                                                          parent.appendChild(node);
376
 
                                                                                                        .)
377
 
        )| RouteStatement
378
 
        | ProtoStatement<parent>.
379
 
 
380
 
        
381
 
NodeNameId <QString& str>
382
 
=       id                              (.str = QString(coco_string_create_char(t->val));.). 
383
 
 
384
 
 
385
 
NodeTypeId <QString& str> 
386
 
=       id                              (.str = QString(coco_string_create_char(t->val));.).
387
 
 
388
 
 
389
 
InlineNodeNameId 
390
 
=       id.
391
 
 
392
 
 
393
 
ExportedNodeNameId 
394
 
=       id.
395
 
 
396
 
 
397
 
InitializeOnlyId <QString& str> 
398
 
=       id                              (.str = QString(coco_string_create_char(t->val));.).
399
 
 
400
 
 
401
 
InputOnlyId <QString& str> 
402
 
=       id                              (.str = QString(coco_string_create_char(t->val));.). 
403
 
 
404
 
 
405
 
InputOutputId <QString& str> 
406
 
=       id                              (.str = QString(coco_string_create_char(t->val));.). 
407
 
 
408
 
 
409
 
OutputOnlyId <QString& str> 
410
 
=       id                              (.str = QString(coco_string_create_char(t->val));.).
411
 
 
412
 
 
413
 
FieldId <QString& str> 
414
 
=       id                              (.str = QString(coco_string_create_char(t->val));.).
415
 
 
416
 
FieldType <QString& str> 
417
 
=       ("MFBool" | "MFColor" | "MFColorRGBA" | "MFDouble" | "MFFloat" | "MFImage" | "MFInt32" |
418
 
        "MFMatrix3d" | "MFMatrix3f" | "MFMatrix4d" | "MFMatrix4f" | "MFNode" | "MFRotation" |
419
 
        "MFString" | "MFTime" | "MFVec2d" | "MFVec2f" | "MFVec3d"| "MFVec3f" | "MFVec4d" |
420
 
        "MFVec4f" | "SFBool" | "SFColor" | "SFColorRGBA" | "SFDouble" | "SFFloat" | "SFImage" |
421
 
        "SFInt32" | "SFMatrix3d" | "SFMatrix3f" | "SFMatrix4d" | "SFMatrix4f" | "SFNode" |
422
 
        "SFRotation" | "SFString" | "SFTime" | "SFVec2d" | "SFVec2f" | "SFVec3d" | "SFVec3f" | 
423
 
        "SFVec4d" | "SFVec4f")  (.str = QString(coco_string_create_char(t->val));.). 
424
 
 
425
 
 
426
 
FieldValue <QDomElement& parent, QString fieldName, bool flag>  
427
 
=       SingleValue<parent, fieldName, flag>
428
 
        | MultiValue<parent, fieldName, flag>.
429
 
 
430
 
 
431
 
SingleValue <QDomElement& parent, QString fieldName, bool flag>  (.QString value; QDomElement tmpParent = doc->createElement("tmp");.)
432
 
=       (string                                                                                                         (.value.append(coco_string_create_char(t->val)); value.remove("\"");.)
433
 
        | (intCont|realCont)                                                                            (.value.append(coco_string_create_char(t->val));.)
434
 
        [","]{(intCont|realCont)                                                                                        (.value.append(" "); value.append(coco_string_create_char(t->val));.)
435
 
        [","]}
436
 
        | "TRUE"                                                                                                        (.value = "true";.)
437
 
        | "FALSE"                                                                                                       (.value = "false";.)
438
 
                )                                                                                                               (.if (flag)
439
 
                                                                                                                                  {
440
 
                                                                                                                                    QDomElement node = doc->createElement("fieldValue");
441
 
                                                                                                                                    node.setAttribute("name", fieldName);
442
 
                                                                                                                                    node.setAttribute("value", value);
443
 
                                                                                                                                    parent.appendChild(node);
444
 
                                                                                                                                  }
445
 
                                                                                                                                  else
446
 
                                                                                                                                    parent.setAttribute(fieldName, value);.)
447
 
                | NodeStatement<tmpParent>                                                              (.if (flag)
448
 
                                                                                                                                  {
449
 
                                                                                                                                    QDomElement tmp = doc->createElement("fieldValue");
450
 
                                                                                                                                    tmp.setAttribute("name", fieldName);
451
 
                                                                                                                                    tmp.appendChild(tmpParent.firstChildElement());
452
 
                                                                                                                                    parent.appendChild(tmp);
453
 
                                                                                                                                  }
454
 
                                                                                                                                  else
455
 
                                                                                                                                    parent.appendChild(tmpParent.firstChildElement());.)
456
 
                                                                                                                                        
457
 
        .
458
 
 
459
 
        
460
 
MultiValue <QDomElement& parent, QString fieldName, bool flag>  (.QString value; QDomElement tmpParent = doc->createElement("tmp");.)
461
 
=       "["
462
 
        ((MultiNumber<value>
463
 
        |MultiString<value>
464
 
        |MultiBool<value>)                                                                                      (.if (flag)
465
 
                                                                                                                                  {
466
 
                                                                                                                                    QDomElement tmp = doc->createElement("fieldValue");
467
 
                                                                                                                                    tmp.setAttribute("name", fieldName);
468
 
                                                                                                                                    tmp.setAttribute("value", value);
469
 
                                                                                                                                    parent.appendChild(tmp);
470
 
                                                                                                                                  }
471
 
                                                                                                                                  else
472
 
                                                                                                                                    parent.setAttribute(fieldName, value);
473
 
                                                                                                                                .)
474
 
        |{NodeStatement<tmpParent>[","]}                                                                        (.QDomElement child;
475
 
                                                                                                                                  QDomNodeList list = tmpParent.childNodes();
476
 
                                                                                                                                  QDomElement field = doc->createElement("field");
477
 
                                                                                                                                  field.setAttribute("name", fieldName);
478
 
                                                                                                                                  int i = 0;
479
 
                                                                                                                                  while(i < list.size())
480
 
                                                                                                                                  {
481
 
                                                                                                                                    child = list.at(i).toElement();
482
 
                                                                                                                                    if (flag)
483
 
                                                                                                                                      field.appendChild(child.cloneNode());
484
 
                                                                                                                                    else
485
 
                                                                                                                                      parent.appendChild(child.cloneNode());
486
 
                                                                                                                                    i++;
487
 
                                                                                                                                  }
488
 
                                                                                                                                  if (flag)
489
 
                                                                                                                                    parent.appendChild(field);
490
 
                                                                                                                                .)
491
 
        )
492
 
        "]".
493
 
 
494
 
MultiNumber<QString& value>
495
 
=       (intCont|realCont)              (.value.append(coco_string_create_char(t->val));.)
496
 
        [","]
497
 
        {(intCont|realCont)                     (.value.append(" "); value.append(coco_string_create_char(t->val));.)
498
 
        [","]}.
499
 
 
500
 
MultiString<QString& value>
501
 
=       (string)                                (.value.append(coco_string_create_char(t->val));.)
502
 
        [","]
503
 
        {string                                         (.value.append(" "); value.append(coco_string_create_char(t->val));.)
504
 
        [","]}.
505
 
 
506
 
MultiBool<QString& value>
507
 
=       ("TRUE"|"SALVE")                        (.value.append(coco_string_create_char(t->val));.)
508
 
        [","]
509
 
        {("TRUE"|"FALSE")               (.value.append(" "); value.append(coco_string_create_char(t->val));.)
510
 
        [","]}.
511
 
 
512
 
 
513
 
 
514
 
END VrmlTranslator.
 
 
b'\\ No newline at end of file'