[antlr-interest] Resuming While loop

madison_stjames madison_stjames at yahoo.com
Wed Apr 9 20:20:37 PDT 2003


My parser currently stops processing at the point at which it 
encounters an error in the file being processed. It writes out the 
error to the screen, then quits. A quick look at the code reveals 
why this is happening:

class myParser
{
	public static void Main(string[] args) 
	{
		try 
		{
			T lexer = new T(new CharBuffer(Console.In));
			P parser = new P(lexer);
			parser.startRule();
			bool done = false;
			while ( !done ) 
			{
				Token tok = lexer.nextToken();
				Console.Out.WriteLine("Token: "+tok);
				if ( tok.Type==Token.EOF_TYPE ) {
					done = true;
				}
			}
			Console.Out.WriteLine("done lexing...");
		} 
		catch(Exception e) 
		{
			Console.Error.WriteLine("exception: "+e);

		}

	}
}

What I want to do is modify the main method so that, upon 
encountering an error, the parser will write it out, then continue 
processing the rest of the file.

I have tried several different approaches, all of which have failed.

Suggestions....?

Thanks in Advance!


 

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




More information about the antlr-interest mailing list