00001 00020 #ifndef VRML1DRIVER_H_ 00021 #define VRML1DRIVER_H_ 00022 00023 #include <iostream> 00024 #include <vector> 00025 #include <map> 00026 #include "vrml1-parser.hh" 00027 #include "SubStack.hh" 00028 #include "Document.hh" 00029 #include "Node.hh" 00030 00031 using namespace std; 00032 00033 namespace vrml1 { 00034 class Driver; 00035 } 00036 00037 // Announce to Flex the prototype we want for lexing function, ... 00038 #define YY_DECL \ 00039 vrml1::vrml1_parser::token_type \ 00040 vrml1lex (vrml1::vrml1_parser::semantic_type* yylval, \ 00041 vrml1::vrml1_parser::location_type* yylloc, \ 00042 vrml1::Driver& driver) 00043 // ... and declare it for the parser's sake. 00044 YY_DECL; 00045 00046 00047 namespace vrml1 { 00048 00049 class Driver 00050 { 00051 public: 00052 Driver(); 00053 virtual ~Driver(); 00054 00055 // Handling the scanner 00056 void scan_begin(); 00057 void scan_end(); 00058 bool trace_scanning; 00059 00060 // Handling the parser 00061 void parse (const std::string& f); 00062 std::string file; 00063 bool trace_parsing; 00064 00065 // Error handling 00066 void error (const location& l, const std::string& m); 00067 void error (const std::string& m); 00068 00069 bool parseError() const; 00070 vector<string> errorStrings() const; 00071 00072 // VRML Document handling 00073 Document *getVRML1Doc(); 00074 00075 // Node handling 00076 void pushVRMLDoc(); 00077 void pushNodeSeparator(); 00078 void pushNodeSwitch(); 00079 void pushNodeCube(); 00080 void pushNodeCone(); 00081 void pushNodeSphere(); 00082 void pushNodeCylinder(); 00083 void pushNodeMaterial(); 00084 void pushNodeMaterialBinding(); 00085 void pushNodeTranslation(); 00086 void pushNodeRotation(); 00087 void pushNodeScale(); 00088 void pushNodeMatrixTransform(); 00089 void pushNodeTransform(); 00090 void pushNodeOrthographicCamera(); 00091 void pushNodePerspectiveCamera(); 00092 void pushNodePointLight(); 00093 void pushNodeSpotLight(); 00094 void pushNodeDirectionalLight(); 00095 void pushNodeTexture2Transform(); 00096 void pushNodeShapeHints(); 00097 void pushNodeNormalBinding(); 00098 void pushNodeFontStyle(); 00099 void pushNodeLOD(); 00100 void pushNodeNormal(); 00101 void pushNodeCoordinate3(); 00102 void pushNodeTextureCoordinate2(); 00103 void pushNodePointSet(); 00104 void pushNodeIndexedLineSet(); 00105 void pushNodeIndexedFaceSet(); 00106 void pushNodeTexture2(); 00107 void pushNodeWWWInline(); 00108 void pushNodeWWWAnchor(); 00109 void pushNodeAsciiText(); 00110 bool pushDEF(); 00111 bool pushUSE(); 00112 00113 // Attribute handling 00114 bool pushAttributeSFImage(string name); 00115 void pushAttributeSFString(string name); 00116 void pushAttributeSFBitmask(string name); 00117 void pushAttributeSFMatrix(string name); 00118 void pushAttributeSFRotation(string name); 00119 void pushAttributeSFVec2f(string name); 00120 void pushAttributeMFVec2f(string name); 00121 void pushAttributeSFVec3f(string name); 00122 void pushAttributeMFVec3f(string name); 00123 void pushAttributeSFColor(string name); 00124 void pushAttributeMFColor(string name); 00125 void pushAttributeSFFloat(string name); 00126 void pushAttributeMFFloat(string name); 00127 void pushAttributeSFLong(string name); 00128 void pushAttributeMFLong(string name); 00129 void pushAttributeSFBool(string name); 00130 00131 // Value handling 00132 void pushString(string s); 00133 void pushFloat(float f); 00134 void pushInteger(int i); 00135 void pushBool(bool b); 00136 00137 // Stack handling 00138 void StackUp(); 00139 void StackDown(); 00140 00141 private: 00142 SubStack *m_StackRoot; 00143 SubStack *m_Stack; 00144 00145 map<string, Node*> m_DefMap; 00146 00147 bool m_Error; 00148 vector<string> m_ErrorStr; 00149 00150 Document *m_VRML1Doc; 00151 }; 00152 00153 } 00154 00155 #endif /*VRML1DRIVER_H_*/