From: <fwi...@us...> - 2009-10-01 20:11:21
|
Revision: 6819 http://jython.svn.sourceforge.net/jython/?rev=6819&view=rev Author: fwierzbicki Date: 2009-10-01 20:11:08 +0000 (Thu, 01 Oct 2009) Log Message: ----------- Remove useless little inner subclasses, which where there just to add a behavior to nextToken() in Python.g -- since we override nextToken() in Python.g anyway, I relocated the functionality there. Modified Paths: -------------- trunk/jython/grammar/Python.g trunk/jython/grammar/PythonPartial.g trunk/jython/src/org/python/antlr/BaseParser.java trunk/jython/src/org/python/core/ParserFacade.java trunk/jython/tests/java/org/python/antlr/PythonPartialTester.java trunk/jython/tests/java/org/python/antlr/PythonTreeTester.java Modified: trunk/jython/grammar/Python.g =================================================================== --- trunk/jython/grammar/Python.g 2009-10-01 01:25:40 UTC (rev 6818) +++ trunk/jython/grammar/Python.g 2009-10-01 20:11:08 UTC (rev 6819) @@ -228,6 +228,7 @@ * remain). */ public Token nextToken() { + startPos = getCharPositionInLine(); while (true) { state.token = null; state.channel = Token.DEFAULT_CHANNEL; Modified: trunk/jython/grammar/PythonPartial.g =================================================================== --- trunk/jython/grammar/PythonPartial.g 2009-10-01 01:25:40 UTC (rev 6818) +++ trunk/jython/grammar/PythonPartial.g 2009-10-01 20:11:08 UTC (rev 6819) @@ -121,6 +121,7 @@ * remain). */ public Token nextToken() { + startPos = getCharPositionInLine(); while (true) { state.token = null; state.channel = Token.DEFAULT_CHANNEL; Modified: trunk/jython/src/org/python/antlr/BaseParser.java =================================================================== --- trunk/jython/src/org/python/antlr/BaseParser.java 2009-10-01 01:25:40 UTC (rev 6818) +++ trunk/jython/src/org/python/antlr/BaseParser.java 2009-10-01 20:11:08 UTC (rev 6819) @@ -31,39 +31,10 @@ this.errorHandler = eh; } - public static class PyLexer extends PythonLexer { - public PyLexer(CharStream lexer, boolean single) { - super(lexer); - this.single = single; - } - - public PyLexer(CharStream lexer) { - this(lexer, false); - } - - - @Override - public Token nextToken() { - startPos = getCharPositionInLine(); - return super.nextToken(); - } - } - - public static class PyPartialLexer extends PythonPartialLexer { - public PyPartialLexer(CharStream lexer) { - super(lexer); - } - - @Override - public Token nextToken() { - startPos = getCharPositionInLine(); - return super.nextToken(); - } - } - private PythonParser setupParser(boolean single) { - PythonLexer lexer = new PyLexer(charStream, single); + PythonLexer lexer = new PythonLexer(charStream); lexer.setErrorHandler(errorHandler); + lexer.single = single; CommonTokenStream tokens = new CommonTokenStream(lexer); PythonTokenSource indentedSource = new PythonTokenSource(tokens, filename, single); tokens = new CommonTokenStream(indentedSource); Modified: trunk/jython/src/org/python/core/ParserFacade.java =================================================================== --- trunk/jython/src/org/python/core/ParserFacade.java 2009-10-01 01:25:40 UTC (rev 6818) +++ trunk/jython/src/org/python/core/ParserFacade.java 2009-10-01 20:11:08 UTC (rev 6819) @@ -232,7 +232,7 @@ try { bufreader.reset(); CharStream cs = new NoCloseReaderStream(bufreader); - lexer = new BaseParser.PyPartialLexer(cs); + lexer = new PythonPartialLexer(cs); CommonTokenStream tokens = new CommonTokenStream(lexer); PythonTokenSource indentedSource = new PythonTokenSource(tokens, filename); tokens = new CommonTokenStream(indentedSource); Modified: trunk/jython/tests/java/org/python/antlr/PythonPartialTester.java =================================================================== --- trunk/jython/tests/java/org/python/antlr/PythonPartialTester.java 2009-10-01 01:25:40 UTC (rev 6818) +++ trunk/jython/tests/java/org/python/antlr/PythonPartialTester.java 2009-10-01 20:11:08 UTC (rev 6819) @@ -14,9 +14,8 @@ try { PythonTree result = null; CharStream input = new ANTLRFileStream(args[0]); - PythonPartialLexer lexer = new BaseParser.PyPartialLexer(input); + PythonPartialLexer lexer = new PythonPartialLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); - //PythonTokenSource indentedSource = new PythonTokenSource(tokens); PythonTokenSource indentedSource = new PythonTokenSource(tokens, "<test>"); tokens = new CommonTokenStream(indentedSource); PythonPartialParser parser = new PythonPartialParser(tokens); Modified: trunk/jython/tests/java/org/python/antlr/PythonTreeTester.java =================================================================== --- trunk/jython/tests/java/org/python/antlr/PythonTreeTester.java 2009-10-01 01:25:40 UTC (rev 6818) +++ trunk/jython/tests/java/org/python/antlr/PythonTreeTester.java 2009-10-01 20:11:08 UTC (rev 6819) @@ -30,7 +30,7 @@ //ErrorHandler eh = new ListErrorHandler(); ErrorHandler eh = new FailFastHandler(); CharStream input = new ANTLRFileStream(args[0]); - PythonLexer lexer = new BaseParser.PyLexer(input); + PythonLexer lexer = new PythonLexer(input); lexer.setErrorHandler(eh); CommonTokenStream tokens = new CommonTokenStream(lexer); PythonTokenSource indentedSource = new PythonTokenSource(tokens, args[0]); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |