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 baab0b4..ac77fff 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.jj +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.jj @@ -122,7 +122,8 @@ public final class PHPParser extends PHPParserSuperclass { } public final PHPOutlineInfo parseInfo(final Object parent, final String s) { - currentSegment = new PHPDocument(parent); + phpDocument = new PHPDocument(parent,"_root".toCharArray()); + currentSegment = phpDocument; outlineInfo = new PHPOutlineInfo(parent, currentSegment); final StringReader stream = new StringReader(s); if (jj_input_stream == null) { @@ -132,9 +133,11 @@ public final class PHPParser extends PHPParserSuperclass { init(); try { parse(); - phpDocument = new PHPDocument(null); phpDocument.nodes = new AstNode[nodes.length]; System.arraycopy(nodes,0,phpDocument.nodes,0,nodes.length); + if (PHPeclipsePlugin.DEBUG) { + PHPeclipsePlugin.log(1,phpDocument.toString()); + } } catch (ParseException e) { processParseException(e); } @@ -634,7 +637,7 @@ void PhpBlock() : { phpEchoBlock() | - [ + [ | {try { setMarker(fileToParse, @@ -766,9 +769,8 @@ void ClassBodyDeclaration(ClassDeclaration classDeclaration) : FieldDeclaration field; } { - method = MethodDeclaration() {method.setParent(classDeclaration); - classDeclaration.addMethod(method);} -| field = FieldDeclaration() {classDeclaration.addVariable(field);} + method = MethodDeclaration() {method.setParent(classDeclaration);} +| field = FieldDeclaration() } /** @@ -798,7 +800,7 @@ FieldDeclaration FieldDeclaration() : errorLevel = ERROR; errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; errorEnd = SimpleCharStream.getPosition() + 1; - throw e; + processParseException(e); } {list = new VariableDeclaration[arrayList.size()]; @@ -889,9 +891,9 @@ String Variable(): return token.image.substring(1); } buff = new StringBuffer(token.image); - buff.append('{'); + buff.append("{"); buff.append(expression.toStringExpression()); - buff.append('}'); + buff.append("}"); return buff.toString(); } | @@ -919,15 +921,15 @@ String VariableName(): return token.image; } buff = new StringBuffer(token.image); - buff.append('{'); + buff.append("{"); buff.append(expression.toStringExpression()); - buff.append('}'); + buff.append("}"); return buff.toString(); } | expr = VariableName() { - buff = new StringBuffer('$'); + buff = new StringBuffer("$"); buff.append(expr); return buff.toString(); } @@ -1119,32 +1121,23 @@ ConstantIdentifier Type() : {final int pos;} { {pos = SimpleCharStream.getPosition(); - return new ConstantIdentifier(Types.STRING, - pos,pos-6);} + return new ConstantIdentifier(Types.STRING,pos,pos-6);} | {pos = SimpleCharStream.getPosition(); - return new ConstantIdentifier(Types.BOOL, - pos,pos-4);} + return new ConstantIdentifier(Types.BOOL,pos,pos-4);} | {pos = SimpleCharStream.getPosition(); - return new ConstantIdentifier(Types.BOOLEAN, - pos,pos-7);} + return new ConstantIdentifier(Types.BOOLEAN,pos,pos-7);} | {pos = SimpleCharStream.getPosition(); - return new ConstantIdentifier(Types.REAL, - pos,pos-4);} + return new ConstantIdentifier(Types.REAL,pos,pos-4);} | {pos = SimpleCharStream.getPosition(); - return new ConstantIdentifier(Types.DOUBLE, - pos,pos-5);} + return new ConstantIdentifier(Types.DOUBLE,pos,pos-5);} | {pos = SimpleCharStream.getPosition(); - return new ConstantIdentifier(Types.FLOAT, - pos,pos-5);} + return new ConstantIdentifier(Types.FLOAT,pos,pos-5);} | {pos = SimpleCharStream.getPosition(); - return new ConstantIdentifier(Types.INT, - pos,pos-3);} + return new ConstantIdentifier(Types.INT,pos,pos-3);} | {pos = SimpleCharStream.getPosition(); - return new ConstantIdentifier(Types.INTEGER, - pos,pos-7);} + return new ConstantIdentifier(Types.INTEGER,pos,pos-7);} | {pos = SimpleCharStream.getPosition(); - return new ConstantIdentifier(Types.OBJECT, - pos,pos-6);} + return new ConstantIdentifier(Types.OBJECT,pos,pos-6);} } Expression Expression() : @@ -1756,7 +1749,7 @@ Statement StatementNoBreak() : try { } catch (ParseException e) { - if (e.currentToken.next.kind != 4) { + if (e.currentToken.next.kind != PHPParserConstants.PHPEND) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected"; errorLevel = ERROR; errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; @@ -1831,10 +1824,11 @@ HTMLBlock htmlBlock() : throw e; } { - nbNodes = nodePtr-startIndex - 1; + nbNodes = nodePtr - startIndex; blockNodes = new AstNode[nbNodes]; System.arraycopy(nodes,startIndex,blockNodes,0,nbNodes); - return new HTMLBlock(nodes);} + nodePtr = startIndex; + return new HTMLBlock(blockNodes);} } /** @@ -1970,10 +1964,6 @@ EchoStatement EchoStatement() : )* try { - { - Expression[] exprs = new Expression[expressions.size()]; - expressions.toArray(exprs); - return new EchoStatement(exprs,pos);} } catch (ParseException e) { if (e.currentToken.next.kind != 4) { errorMessage = "';' expected after 'echo' statement"; @@ -1983,6 +1973,9 @@ EchoStatement EchoStatement() : throw e; } } + {Expression[] exprs = new Expression[expressions.size()]; + expressions.toArray(exprs); + return new EchoStatement(exprs,pos);} } GlobalStatement GlobalStatement() : @@ -2102,9 +2095,19 @@ Statement BlockStatement() : final Statement statement; } { - statement = Statement() {return statement;} + try { + statement = Statement() {if (phpDocument == currentSegment) pushOnAstNodes(statement); + return statement;} + } catch (ParseException e) { + errorMessage = "statement expected"; + errorLevel = ERROR; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; + throw e; + } | statement = ClassDeclaration() {return statement;} -| statement = MethodDeclaration() {return statement;} +| statement = MethodDeclaration() {if (phpDocument == currentSegment) pushOnAstNodes(statement); + return statement;} } /**