[antlr-interest] CPP Error Message redirection

Ric Klaren klaren at cs.utwente.nl
Wed Jun 23 02:23:38 PDT 2004


On Wed, Jun 23, 2004 at 03:21:37AM -0000, jenlhunt2003 wrote:
> What is the best procedure for changing error output from stderr to
> stdout.  Rics code suggests overriding the panic functions in
> TreeParser, but I don't see exactly where to do it.

Those panic ones are unused, they'll get removed in the next version
probably. You need to override reportXXX just grep over the header files
for the parser/charscanner/treeparser to see which ones are defined and
change those.

> I guess it needs
> to be done in the .g file which extends TreeParser, but where does it
> go in so that it winds up in the correct part of the .cpp file?

Basic boilerplate:

header {
  .. includes ..
}

options {
  language = "Cpp";
}

{
	// This gets inserted in the cpp file
   void MyParser::reportWarning(const std::string& s )
	{
		cout << s << endl;
	}
   void MyParser::reportWarning(antlr::RefToken tok, const std::string& s )
	{
		...etc...
	}

}
class MyParser extends Parser;
options {
 ..
}
{
	// get's inserted in hpp
	void reportWarning(const std::string& s);
	void reportWarning( antlr::RefToken tok, const std::string& s );
}

startrule :  ... ;

Cheers,

Ric
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893755  ----
-----+++++*****************************************************+++++++++-------
  Chaos is found in greatest abundance wherever order is being sought.
  --- Terry Pratchet



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list