From: Braden M. <br...@us...> - 2006-11-17 06:47:09
|
Update of /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv2405/src/libopenvrml/openvrml Modified Files: Tag: OpenVRML-0_16-BRANCH Vrml97Parser.g X3DVrmlParser.g browser.cpp Log Message: Write parser error and warning messages using openvrml::browser::err rather than use the libantlr default (which writes directly to std::cerr). Index: X3DVrmlParser.g =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml/X3DVrmlParser.g,v retrieving revision 1.21 retrieving revision 1.21.2.1 diff -C2 -d -r1.21 -r1.21.2.1 *** X3DVrmlParser.g 12 Apr 2006 20:08:15 -0000 1.21 --- X3DVrmlParser.g 17 Nov 2006 06:47:06 -0000 1.21.2.1 *************** *** 217,227 **** { public: ! X3DVrmlParser(antlr::TokenStream & lexer, const std::string & uri): antlr::LLkParser(lexer, 1), ! uri(uri) ! {} private: ! const std::string uri; } --- 217,246 ---- { public: ! X3DVrmlParser(openvrml::browser & b, ! antlr::TokenStream & lexer, ! const std::string & uri): antlr::LLkParser(lexer, 1), ! browser_(&b) ! { ! this->Parser::setFilename(uri); ! } ! ! virtual void reportError(const antlr::RecognitionException & ex) ! { ! this->browser_->err(this->getFilename() + ": " + ex.toString()); ! } ! ! virtual void reportError(const std::string & s) ! { ! this->browser_->err(this->getFilename() + ": error: " + s); ! } ! ! virtual void reportWarning(const std::string & s) ! { ! this->browser_->err(this->getFilename() + ": warning: " + s); ! } private: ! openvrml::browser * browser_; } *************** *** 236,240 **** const profile & p = ::profile_registry_.at(profile_id); std::auto_ptr<scope> root_scope_auto_ptr = ! p.create_root_scope(scene.browser(), this->uri); const boost::shared_ptr<scope> root_scope(root_scope_auto_ptr); } --- 255,259 ---- const profile & p = ::profile_registry_.at(profile_id); std::auto_ptr<scope> root_scope_auto_ptr = ! p.create_root_scope(scene.browser(), this->getFilename()); const boost::shared_ptr<scope> root_scope(root_scope_auto_ptr); } *************** *** 247,251 **** throw antlr::SemanticException("unrecognized profile \"" + profile_id + "\"", ! this->uri, LT(1)->getLine(), LT(1)->getColumn()); --- 266,270 ---- throw antlr::SemanticException("unrecognized profile \"" + profile_id + "\"", ! this->getFilename(), LT(1)->getLine(), LT(1)->getColumn()); *************** *** 271,275 **** throw antlr::SemanticException("unrecognized component \"" + id->getText() + "\"", ! this->uri, id->getLine(), id->getColumn()); --- 290,294 ---- throw antlr::SemanticException("unrecognized component \"" + id->getText() + "\"", ! this->getFilename(), id->getLine(), id->getColumn()); *************** *** 277,281 **** catch [std::invalid_argument & ex] { throw antlr::SemanticException(ex.what(), ! this->uri, id->getLine(), id->getColumn()); --- 296,300 ---- catch [std::invalid_argument & ex] { throw antlr::SemanticException(ex.what(), ! this->getFilename(), id->getLine(), id->getColumn()); Index: browser.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml/browser.cpp,v retrieving revision 1.190.2.2 retrieving revision 1.190.2.3 diff -C2 -d -r1.190.2.2 -r1.190.2.3 *** browser.cpp 23 Oct 2006 06:39:17 -0000 1.190.2.2 --- browser.cpp 17 Nov 2006 06:47:06 -0000 1.190.2.3 *************** *** 3600,3608 **** || iequals(type, x_vrml_media_type)) { Vrml97Scanner scanner(in); ! Vrml97Parser parser(scanner, uri); parser.vrmlScene(scene, nodes, meta); } else if (iequals(type, x3d_vrml_media_type)) { X3DVrmlScanner scanner(in); ! X3DVrmlParser parser(scanner, uri); parser.vrmlScene(scene, nodes, meta); } else { --- 3600,3608 ---- || iequals(type, x_vrml_media_type)) { Vrml97Scanner scanner(in); ! Vrml97Parser parser(scene.browser(), scanner, uri); parser.vrmlScene(scene, nodes, meta); } else if (iequals(type, x3d_vrml_media_type)) { X3DVrmlScanner scanner(in); ! X3DVrmlParser parser(scene.browser(), scanner, uri); parser.vrmlScene(scene, nodes, meta); } else { *************** *** 6094,6097 **** --- 6094,6102 ---- } catch (antlr::ANTLRException & ex) { browser.err(ex.getMessage()); + } catch (invalid_vrml & ex) { + std::ostringstream out; + out << ex.url << ':' << ex.line << ':' << ex.column << ": error: " + << ex.what(); + browser.err(out.str()); } catch (unreachable_url &) { throw; Index: Vrml97Parser.g =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml/Vrml97Parser.g,v retrieving revision 1.68 retrieving revision 1.68.2.1 diff -C2 -d -r1.68 -r1.68.2.1 *** Vrml97Parser.g 2 Aug 2006 03:20:02 -0000 1.68 --- Vrml97Parser.g 17 Nov 2006 06:47:06 -0000 1.68.2.1 *************** *** 611,621 **** { public: ! Vrml97Parser(antlr::TokenStream & lexer, const std::string & uri): antlr::LLkParser(lexer, 1), ! uri(uri) ! {} private: ! const std::string uri; } --- 611,640 ---- { public: ! Vrml97Parser(openvrml::browser & b, ! antlr::TokenStream & lexer, ! const std::string & uri): antlr::LLkParser(lexer, 1), ! browser_(&b) ! { ! this->Parser::setFilename(uri); ! } ! ! virtual void reportError(const antlr::RecognitionException & ex) ! { ! this->browser_->err(this->getFilename() + ": " + ex.toString()); ! } ! ! virtual void reportError(const std::string & s) ! { ! this->browser_->err(this->getFilename() + ": error: " + s); ! } ! ! virtual void reportWarning(const std::string & s) ! { ! this->browser_->err(this->getFilename() + ": warning: " + s); ! } private: ! openvrml::browser * browser_; } *************** *** 629,633 **** const profile & p = ::profile_registry_.at(vrml97_profile::id); std::auto_ptr<scope> root_scope_auto_ptr = ! p.create_root_scope(scene.browser(), this->uri); const boost::shared_ptr<scope> root_scope(root_scope_auto_ptr); } --- 648,652 ---- const profile & p = ::profile_registry_.at(vrml97_profile::id); std::auto_ptr<scope> root_scope_auto_ptr = ! p.create_root_scope(scene.browser(), this->getFilename()); const boost::shared_ptr<scope> root_scope(root_scope_auto_ptr); } *************** *** 673,677 **** + "\" has not been defined in " + "this scope", ! this->uri, id1->getLine(), id1->getColumn()); --- 692,696 ---- + "\" has not been defined in " + "this scope", ! this->getFilename(), id1->getLine(), id1->getColumn()); *************** *** 739,745 **** if (!dynamic_pointer_cast<proto_node_metatype>( ! scene.browser().node_metatype(node_metatype_id(this->uri)))) { ! scene.browser().add_node_metatype(node_metatype_id(this->uri), ! node_metatype); } --- 758,766 ---- if (!dynamic_pointer_cast<proto_node_metatype>( ! scene.browser().node_metatype( ! node_metatype_id(this->getFilename())))) { ! scene.browser() ! .add_node_metatype(node_metatype_id(this->getFilename()), ! node_metatype); } *************** *** 755,759 **** + "\" has already been defined in " "this scope", ! this->uri, id->getLine(), id->getColumn()); --- 776,780 ---- + "\" has already been defined in " "this scope", ! this->getFilename(), id->getLine(), id->getColumn()); *************** *** 786,790 **** + "\" conflicts with previous " "declaration", ! this->uri, id0->getLine(), id0->getColumn()); --- 807,811 ---- + "\" conflicts with previous " "declaration", ! this->getFilename(), id0->getLine(), id0->getColumn()); *************** *** 812,816 **** + "\" conflicts with previous " "declaration", ! this->uri, id1->getLine(), id1->getColumn()); --- 833,837 ---- + "\" conflicts with previous " "declaration", ! this->getFilename(), id1->getLine(), id1->getColumn()); *************** *** 924,928 **** + "\" has not been defined in " + "this scope", ! this->uri, id1->getLine(), id1->getColumn()); --- 945,949 ---- + "\" has not been defined in " + "this scope", ! this->getFilename(), id1->getLine(), id1->getColumn()); *************** *** 957,965 **** // string, we call create_file_url with an empty (relative) uri. // ! const ::uri base_uri = anonymous_stream_id(::uri(uri)) ? scene.browser().world_url().empty() ? create_file_url(::uri()) : ::uri(scene.browser().world_url()) ! : ::uri(this->uri); } : KEYWORD_EXTERNPROTO id:ID LBRACKET --- 978,986 ---- // string, we call create_file_url with an empty (relative) uri. // ! const ::uri base_uri = anonymous_stream_id(::uri(this->getFilename())) ? scene.browser().world_url().empty() ? create_file_url(::uri()) : ::uri(scene.browser().world_url()) ! : ::uri(this->getFilename()); } : KEYWORD_EXTERNPROTO id:ID LBRACKET *************** *** 1015,1019 **** + "\" has already been defined in " + "this scope", ! this->uri, id->getLine(), id->getColumn()); --- 1036,1040 ---- + "\" has already been defined in " + "this scope", ! this->getFilename(), id->getLine(), id->getColumn()); *************** *** 1041,1045 **** + "\" conflicts with previous " "declaration", ! this->uri, id->getLine(), id->getColumn()); --- 1062,1066 ---- + "\" conflicts with previous " "declaration", ! this->getFilename(), id->getLine(), id->getColumn()); *************** *** 1085,1089 **** + "\" has not been defined in this " "scope", ! this->uri, from_node_id->getLine(), from_node_id->getColumn()); --- 1106,1110 ---- + "\" has not been defined in this " "scope", ! this->getFilename(), from_node_id->getLine(), from_node_id->getColumn()); *************** *** 1096,1100 **** + "\" has not been defined in this " "scope", ! this->uri, to_node_id->getLine(), to_node_id->getColumn()); --- 1117,1121 ---- + "\" has not been defined in this " "scope", ! this->getFilename(), to_node_id->getLine(), to_node_id->getColumn()); *************** *** 1110,1114 **** } catch (runtime_error & ex) { throw SemanticException(ex.what(), ! this->uri, from_node_id->getLine(), from_node_id->getColumn()); --- 1131,1135 ---- } catch (runtime_error & ex) { throw SemanticException(ex.what(), ! this->getFilename(), from_node_id->getLine(), from_node_id->getColumn()); *************** *** 1132,1136 **** + "\" has not been defined in this " "scope", ! this->uri, from_node_id->getLine(), from_node_id->getColumn()); --- 1153,1157 ---- + "\" has not been defined in this " "scope", ! this->getFilename(), from_node_id->getLine(), from_node_id->getColumn()); *************** *** 1143,1147 **** + "\" has not been defined in this " "scope", ! this->uri, to_node_id->getLine(), to_node_id->getColumn()); --- 1164,1168 ---- + "\" has not been defined in this " "scope", ! this->getFilename(), to_node_id->getLine(), to_node_id->getColumn()); *************** *** 1166,1170 **** "no eventOut \"" + eventout_id->getText() + "\"", ! this->uri, eventout_id->getLine(), eventout_id->getColumn()); --- 1187,1191 ---- "no eventOut \"" + eventout_id->getText() + "\"", ! this->getFilename(), eventout_id->getLine(), eventout_id->getColumn()); *************** *** 1181,1185 **** "eventIn \"" + eventin_id->getText() + "\"", ! this->uri, eventin_id->getLine(), eventin_id->getColumn()); --- 1202,1206 ---- "eventIn \"" + eventin_id->getText() + "\"", ! this->getFilename(), eventin_id->getLine(), eventin_id->getColumn()); *************** *** 1189,1193 **** throw SemanticException("mismatch between eventOut and " "eventIn types", ! this->uri, eventin_id->getLine(), eventin_id->getColumn()); --- 1210,1214 ---- throw SemanticException("mismatch between eventOut and " "eventIn types", ! this->getFilename(), eventin_id->getLine(), eventin_id->getColumn()); *************** *** 1236,1240 **** throw SemanticException("unknown node type \"" + nodeTypeId->getText() + "\"", ! this->uri, nodeTypeId->getLine(), nodeTypeId->getColumn()); --- 1257,1261 ---- throw SemanticException("unknown node type \"" + nodeTypeId->getText() + "\"", ! this->getFilename(), nodeTypeId->getLine(), nodeTypeId->getColumn()); *************** *** 1254,1258 **** catch [std::invalid_argument & ex] { throw SemanticException(ex.what(), ! this->uri, LT(1)->getLine(), LT(1)->getColumn()); --- 1275,1279 ---- catch [std::invalid_argument & ex] { throw SemanticException(ex.what(), ! this->getFilename(), LT(1)->getLine(), LT(1)->getColumn()); *************** *** 1260,1264 **** catch [unsupported_interface & ex] { throw SemanticException(ex.what(), ! this->uri, LT(1)->getLine(), LT(1)->getColumn()); --- 1281,1285 ---- catch [unsupported_interface & ex] { throw SemanticException(ex.what(), ! this->getFilename(), LT(1)->getLine(), LT(1)->getColumn()); *************** *** 1267,1271 **** throw SemanticException("incorrect value type for field or " "exposedField", ! this->uri, LT(1)->getLine(), LT(1)->getColumn()); --- 1288,1292 ---- throw SemanticException("incorrect value type for field or " "exposedField", ! this->getFilename(), LT(1)->getLine(), LT(1)->getColumn()); *************** *** 1298,1302 **** throw SemanticException("Node has no field or exposedField \"" + id->getText() + "\"", ! this->uri, id->getLine(), id->getColumn()); --- 1319,1323 ---- throw SemanticException("Node has no field or exposedField \"" + id->getText() + "\"", ! this->getFilename(), id->getLine(), id->getColumn()); *************** *** 1310,1314 **** throw SemanticException("value for " + id->getText() + " already declared", ! this->uri, id->getLine(), id->getColumn()); --- 1331,1335 ---- throw SemanticException("value for " + id->getText() + " already declared", ! this->getFilename(), id->getLine(), id->getColumn()); *************** *** 1340,1344 **** + "\" conflicts with previous " "declaration", ! this->uri, id->getLine(), id->getColumn()); --- 1361,1365 ---- + "\" conflicts with previous " "declaration", ! this->getFilename(), id->getLine(), id->getColumn()); *************** *** 1380,1384 **** + "\" already declared for Script " "node", ! this->uri, id->getLine(), id->getColumn()); --- 1401,1405 ---- + "\" already declared for Script " "node", ! this->getFilename(), id->getLine(), id->getColumn()); *************** *** 1438,1442 **** throw SemanticException("unknown node type \"" + nodeTypeId->getText() + "\"", ! this->uri, nodeTypeId->getLine(), nodeTypeId->getColumn()); --- 1459,1463 ---- throw SemanticException("unknown node type \"" + nodeTypeId->getText() + "\"", ! this->getFilename(), nodeTypeId->getLine(), nodeTypeId->getColumn()); *************** *** 1486,1490 **** throw SemanticException("node has no interface \"" + interface_id->getText() + "\"", ! this->uri, interface_id->getLine(), interface_id->getColumn()); --- 1507,1511 ---- throw SemanticException("node has no interface \"" + interface_id->getText() + "\"", ! this->getFilename(), interface_id->getLine(), interface_id->getColumn()); *************** *** 1548,1552 **** + "\" conflicts with previous " "declaration", ! this->uri, id->getLine(), id->getColumn()); --- 1569,1573 ---- + "\" conflicts with previous " "declaration", ! this->getFilename(), id->getLine(), id->getColumn()); *************** *** 1591,1595 **** + "\" already declared for Script " "node", ! this->uri, id->getLine(), id->getColumn()); --- 1612,1616 ---- + "\" already declared for Script " "node", ! this->getFilename(), id->getLine(), id->getColumn()); |