X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.jj b/net.sourceforge.phpeclipse/src/test/PHPParser.jj index 9d2846a..c1d2e52 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.jj +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.jj @@ -3,7 +3,7 @@ options { LOOKAHEAD = 1; CHOICE_AMBIGUITY_CHECK = 2; OTHER_AMBIGUITY_CHECK = 1; - STATIC = true; + STATIC = false; DEBUG_PARSER = false; DEBUG_LOOKAHEAD = false; DEBUG_TOKEN_MANAGER = false; @@ -101,24 +101,26 @@ public final class PHPParser extends PHPParserSuperclass { PHPParser.fileToParse = fileToParse; } - public static final void phpParserTester(final String strEval) throws ParseException { + public final void phpParserTester(final String strEval) throws ParseException { final StringReader stream = new StringReader(strEval); if (jj_input_stream == null) { jj_input_stream = new SimpleCharStream(stream, 1, 1); + token_source = new PHPParserTokenManager(jj_input_stream); } ReInit(new StringReader(strEval)); init(); phpDocument = new PHPDocument(null,"_root".toCharArray()); currentSegment = phpDocument; outlineInfo = new PHPOutlineInfo(null, currentSegment); - PHPParserTokenManager.SwitchTo(PHPParserTokenManager.PHPPARSING); + token_source.SwitchTo(PHPParserTokenManager.PHPPARSING); phpTest(); } - public static final void htmlParserTester(final File fileName) throws FileNotFoundException, ParseException { + public final void htmlParserTester(final File fileName) throws FileNotFoundException, ParseException { final Reader stream = new FileReader(fileName); if (jj_input_stream == null) { jj_input_stream = new SimpleCharStream(stream, 1, 1); + token_source = new PHPParserTokenManager(jj_input_stream); } ReInit(stream); init(); @@ -128,10 +130,11 @@ public final class PHPParser extends PHPParserSuperclass { phpFile(); } - public static final void htmlParserTester(final String strEval) throws ParseException { + public final void htmlParserTester(final String strEval) throws ParseException { final StringReader stream = new StringReader(strEval); if (jj_input_stream == null) { jj_input_stream = new SimpleCharStream(stream, 1, 1); + token_source = new PHPParserTokenManager(jj_input_stream); } ReInit(stream); init(); @@ -174,6 +177,7 @@ public final class PHPParser extends PHPParserSuperclass { final StringReader stream = new StringReader(s); if (jj_input_stream == null) { jj_input_stream = new SimpleCharStream(stream, 1, 1); + token_source = new PHPParserTokenManager(jj_input_stream); } ReInit(stream); init(); @@ -293,6 +297,7 @@ public final class PHPParser extends PHPParserSuperclass { final StringReader stream = new StringReader(s); if (jj_input_stream == null) { jj_input_stream = new SimpleCharStream(stream, 1, 1); + token_source = new PHPParserTokenManager(jj_input_stream); } ReInit(stream); init(); @@ -328,36 +333,36 @@ public final class PHPParser extends PHPParserSuperclass { /** * Put a new html block in the stack. */ - public static final void createNewHTMLCode() { + public final void createNewHTMLCode() { final int currentPosition = token.sourceStart; if (currentPosition == htmlStart || currentPosition < htmlStart || - currentPosition > SimpleCharStream.currentBuffer.length()) { + currentPosition > jj_input_stream.getCurrentBuffer().length()) { return; } - final String html = SimpleCharStream.currentBuffer.substring(htmlStart, currentPosition); + final String html = jj_input_stream.getCurrentBuffer().substring(htmlStart, currentPosition); pushOnAstNodes(new HTMLCode(html, htmlStart,currentPosition)); } /** Create a new task. */ - public static final void createNewTask(final int todoStart) { - final String todo = SimpleCharStream.currentBuffer.substring(todoStart, - SimpleCharStream.currentBuffer.indexOf("\n", + public final void createNewTask(final int todoStart) { + final String todo = jj_input_stream.getCurrentBuffer().substring(todoStart, + jj_input_stream.getCurrentBuffer().indexOf("\n", todoStart)-1); if (!PARSER_DEBUG) { try { setMarker(fileToParse, todo, - SimpleCharStream.getBeginLine(), + jj_input_stream.getBeginLine(), TASK, - "Line "+SimpleCharStream.getBeginLine()); + "Line "+jj_input_stream.getBeginLine()); } catch (CoreException e) { PHPeclipsePlugin.log(e); } } } - private static final void parse() throws ParseException { + private final void parse() throws ParseException { phpFile(); } } @@ -370,9 +375,9 @@ TOKEN_MGR_DECLS: // CharStream class to set corresponding fields in each Token (which was // also extended with new fields). By default Jack doesn't supply absolute // offsets, just line/column offsets - static void CommonTokenAction(Token t) { - t.sourceStart = input_stream.beginOffset; - t.sourceEnd = input_stream.endOffset; + void CommonTokenAction(Token t) { + t.sourceStart = input_stream.getBeginOffset(); + t.sourceEnd = input_stream.getBeginOffset(); } // CommonTokenAction } // TOKEN_MGR_DECLS @@ -741,11 +746,11 @@ void phpFile() : { try { (PhpBlock())* - {PHPParser.createNewHTMLCode();} + {createNewHTMLCode();} } catch (TokenMgrError e) { PHPeclipsePlugin.log(e); - errorStart = SimpleCharStream.beginOffset; - errorEnd = SimpleCharStream.endOffset; + errorStart = jj_input_stream.getBeginOffset(); + errorEnd = jj_input_stream.getEndOffset(); errorMessage = e.getMessage(); errorLevel = ERROR; throw generateParseException(); @@ -779,7 +784,7 @@ void PhpBlock() : PHPeclipsePlugin.log(e); }} ] - {PHPParser.createNewHTMLCode();} + {createNewHTMLCode();} Php() try { phpEnd = @@ -800,7 +805,7 @@ PHPEchoBlock phpEchoBlock() : final Token token, token2; } { - token = {PHPParser.createNewHTMLCode();} + token = {createNewHTMLCode();} expr = Expression() [ ] token2 = { htmlStart = token2.sourceEnd; @@ -907,7 +912,7 @@ Token token; errorStart = e.currentToken.sourceStart; errorEnd = e.currentToken.sourceEnd; processParseExceptionDebug(e); - return PHPParser.token.sourceEnd; + return this.token.sourceEnd; } } @@ -1165,7 +1170,7 @@ final Expression expr,expr2; expr2 = Expression() {return new ArrayVariableDeclaration(expr,expr2);} ] - {return new ArrayVariableDeclaration(expr,SimpleCharStream.getPosition());} + {return new ArrayVariableDeclaration(expr,jj_input_stream.getPosition());} } ArrayVariableDeclaration[] ArrayInitializer() : @@ -1285,7 +1290,7 @@ int FormalParameters(final ArrayList parameters) : { VariableDeclaration var; final Token token; - Token tok = PHPParser.token; + Token tok = this.token; int end = tok.sourceEnd; } { @@ -1372,7 +1377,7 @@ Expression Expression() : } errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', expression expected"; errorLevel = ERROR; - errorEnd = SimpleCharStream.getPosition(); + errorEnd = jj_input_stream.getPosition(); throw e; } ] @@ -1644,8 +1649,8 @@ Expression MultiplicativeExpression() : if (errorMessage != null) throw e; errorMessage = "unexpected token '"+e.currentToken.next.image+'\''; errorLevel = ERROR; - errorStart = PHPParser.token.sourceStart; - errorEnd = PHPParser.token.sourceEnd; + errorStart = this.token.sourceStart; + errorEnd = this.token.sourceEnd; throw e; } ( @@ -1895,7 +1900,7 @@ ArrayInitializer ArrayDeclarator() : token = vars = ArrayInitializer() {return new ArrayInitializer(vars, token.sourceStart, - PHPParser.token.sourceEnd);} + this.token.sourceEnd);} } Expression ClassIdentifier(): @@ -2021,7 +2026,7 @@ StringLiteral evaluableString() : { AbstractVariable[] vars = new AbstractVariable[list.size()]; list.toArray(vars); - return new StringLiteral(SimpleCharStream.currentBuffer.substring(start.sourceEnd,end.sourceStart), + return new StringLiteral(jj_input_stream.getCurrentBuffer().substring(start.sourceEnd,end.sourceStart), start.sourceStart, end.sourceEnd, vars); @@ -2248,7 +2253,7 @@ HTMLBlock htmlBlock() : (phpEchoBlock())* try { ( | ) - {PHPParser.createNewHTMLCode();} + {createNewHTMLCode();} } catch (ParseException e) { errorMessage = "unexpected end of file , ' try { - {pos = SimpleCharStream.getPosition();} + {pos = jj_input_stream.getPosition();} statement = Statement() - {elseStatement = new Else(statement,pos,SimpleCharStream.getPosition());} + {elseStatement = new Else(statement,pos,jj_input_stream.getPosition());} } catch (ParseException e) { if (errorMessage != null) { throw e; @@ -3034,7 +3039,7 @@ IfStatement IfStatement0(final Expression condition, final int start,final int e elseIfs, elseStatement, pos, - SimpleCharStream.getPosition());} + jj_input_stream.getPosition());} } ElseIf ElseIfStatementColon() : @@ -3103,7 +3108,7 @@ Statement WhileStatement0(final int start, final int end) : { Statement statement; final ArrayList stmts = new ArrayList(); - final int pos = SimpleCharStream.getPosition(); + final int pos = jj_input_stream.getPosition(); } { (statement = Statement() {stmts.add(statement);})* @@ -3131,7 +3136,7 @@ Statement WhileStatement0(final int start, final int end) : { final Statement[] stmtsArray = new Statement[stmts.size()]; stmts.toArray(stmtsArray); - return new Block(stmtsArray,pos,SimpleCharStream.getPosition());} + return new Block(stmtsArray,pos,jj_input_stream.getPosition());} } catch (ParseException e) { errorMessage = "';' expected after 'endwhile' keyword"; errorLevel = ERROR;