From: <fwi...@us...> - 2008-07-31 20:51:02
|
Revision: 5032 http://jython.svn.sourceforge.net/jython/?rev=5032&view=rev Author: fwierzbicki Date: 2008-07-31 20:50:59 +0000 (Thu, 31 Jul 2008) Log Message: ----------- Tightened up signature of ErrorHandler and added a ListErrorHandler that mimics Antlr default behavior for error handling. Modified Paths: -------------- branches/asm/src/org/python/antlr/ErrorHandler.java branches/asm/src/org/python/antlr/FailFastHandler.java Added Paths: ----------- branches/asm/src/org/python/antlr/ListErrorHandler.java Modified: branches/asm/src/org/python/antlr/ErrorHandler.java =================================================================== --- branches/asm/src/org/python/antlr/ErrorHandler.java 2008-07-31 20:13:12 UTC (rev 5031) +++ branches/asm/src/org/python/antlr/ErrorHandler.java 2008-07-31 20:50:59 UTC (rev 5032) @@ -2,11 +2,12 @@ import org.antlr.runtime.BaseRecognizer; import org.antlr.runtime.IntStream; +import org.antlr.runtime.Lexer; import org.antlr.runtime.RecognitionException; interface ErrorHandler { void reportError(BaseRecognizer br, RecognitionException re); - void recover(BaseRecognizer br, RecognitionException re); void recover(BaseRecognizer br, IntStream input, RecognitionException re); + void recover(Lexer lex, RecognitionException re); boolean isRecoverable(); } Modified: branches/asm/src/org/python/antlr/FailFastHandler.java =================================================================== --- branches/asm/src/org/python/antlr/FailFastHandler.java 2008-07-31 20:13:12 UTC (rev 5031) +++ branches/asm/src/org/python/antlr/FailFastHandler.java 2008-07-31 20:50:59 UTC (rev 5032) @@ -2,6 +2,7 @@ import org.antlr.runtime.BaseRecognizer; import org.antlr.runtime.IntStream; +import org.antlr.runtime.Lexer; import org.antlr.runtime.RecognitionException; public class FailFastHandler implements ErrorHandler { @@ -11,8 +12,8 @@ throw new ParseException(message(br,re), re); } - public void recover(BaseRecognizer br, RecognitionException re) { - throw new ParseException(message(br,re), re); + public void recover(Lexer lex, RecognitionException re) { + throw new ParseException(message(lex,re), re); } public void recover(BaseRecognizer br, IntStream input, RecognitionException re) { Added: branches/asm/src/org/python/antlr/ListErrorHandler.java =================================================================== --- branches/asm/src/org/python/antlr/ListErrorHandler.java (rev 0) +++ branches/asm/src/org/python/antlr/ListErrorHandler.java 2008-07-31 20:50:59 UTC (rev 5032) @@ -0,0 +1,27 @@ +package org.python.antlr; + +import org.antlr.runtime.BaseRecognizer; +import org.antlr.runtime.IntStream; +import org.antlr.runtime.Lexer; +import org.antlr.runtime.RecognitionException; + +public class ListErrorHandler implements ErrorHandler { + private BaseRecognizer recognizer; + + public void reportError(BaseRecognizer br, RecognitionException re) { + br.reportError(re); + } + + public void recover(Lexer lex, RecognitionException re) { + lex.recover(re); + } + + public void recover(BaseRecognizer br, IntStream input, RecognitionException re) { + br.recover(input, re); + } + + public boolean isRecoverable() { + return true; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |