X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.java b/net.sourceforge.phpeclipse/src/test/PHPParser.java index b0edb74..4440696 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.java @@ -39,7 +39,6 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon private static final String PARSE_WARNING_STRING = "Warning"; //$NON-NLS-1$ static PHPOutlineInfo outlineInfo; - public static MethodDeclaration currentFunction; private static boolean assigning; /** The error level of the current ParseException. */ @@ -62,12 +61,6 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon private static AstNode[] nodes; /** The cursor in expression stack. */ private static int nodePtr; - private static VariableDeclaration[] variableDeclarationStack; - private static int variableDeclarationPtr; - private static Statement[] statementStack; - private static int statementPtr; - private static ElseIf[] elseIfStack; - private static int elseIfPtr; public final void setFileToParse(final IFile fileToParse) { this.fileToParse = fileToParse; @@ -86,11 +79,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon */ private static final void init() { nodes = new AstNode[AstStackIncrement]; - statementStack = new Statement[AstStackIncrement]; - elseIfStack = new ElseIf[AstStackIncrement]; nodePtr = -1; - statementPtr = -1; - elseIfPtr = -1; htmlStart = 0; } @@ -111,83 +100,10 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon } } - private static final void pushOnVariableDeclarationStack(VariableDeclaration var) { - try { - variableDeclarationStack[++variableDeclarationPtr] = var; - } catch (IndexOutOfBoundsException e) { - int oldStackLength = variableDeclarationStack.length; - VariableDeclaration[] oldStack = variableDeclarationStack; - variableDeclarationStack = new VariableDeclaration[oldStackLength + AstStackIncrement]; - System.arraycopy(oldStack, 0, variableDeclarationStack, 0, oldStackLength); - variableDeclarationPtr = oldStackLength; - variableDeclarationStack[variableDeclarationPtr] = var; - } - } - - private static final void pushOnStatementStack(Statement statement) { - try { - statementStack[++statementPtr] = statement; - } catch (IndexOutOfBoundsException e) { - int oldStackLength = statementStack.length; - Statement[] oldStack = statementStack; - statementStack = new Statement[oldStackLength + AstStackIncrement]; - System.arraycopy(oldStack, 0, statementStack, 0, oldStackLength); - statementPtr = oldStackLength; - statementStack[statementPtr] = statement; - } - } - - private static final void pushOnElseIfStack(ElseIf elseIf) { - try { - elseIfStack[++elseIfPtr] = elseIf; - } catch (IndexOutOfBoundsException e) { - int oldStackLength = elseIfStack.length; - ElseIf[] oldStack = elseIfStack; - elseIfStack = new ElseIf[oldStackLength + AstStackIncrement]; - System.arraycopy(oldStack, 0, elseIfStack, 0, oldStackLength); - elseIfPtr = oldStackLength; - elseIfStack[elseIfPtr] = elseIf; - } - } - - public static final void phpParserTester(final String strEval) throws CoreException, ParseException { - PHPParserTokenManager.SwitchTo(PHPParserTokenManager.PHPPARSING); - final StringReader stream = new StringReader(strEval); - if (jj_input_stream == null) { - jj_input_stream = new SimpleCharStream(stream, 1, 1); - } - ReInit(new StringReader(strEval)); - init(); - phpTest(); - } - - public static final void htmlParserTester(final File fileName) throws CoreException, ParseException { - try { - final Reader stream = new FileReader(fileName); - if (jj_input_stream == null) { - jj_input_stream = new SimpleCharStream(stream, 1, 1); - } - ReInit(stream); - init(); - phpFile(); - } catch (FileNotFoundException e) { - e.printStackTrace(); //To change body of catch statement use Options | File Templates. - } - } - - public static final void htmlParserTester(final String strEval) throws CoreException, ParseException { - final StringReader stream = new StringReader(strEval); - if (jj_input_stream == null) { - jj_input_stream = new SimpleCharStream(stream, 1, 1); - } - ReInit(stream); - init(); - phpFile(); - } - public final PHPOutlineInfo parseInfo(final Object parent, final String s) { - currentSegment = new PHPDocument(parent); - outlineInfo = new PHPOutlineInfo(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) { jj_input_stream = new SimpleCharStream(stream, 1, 1); @@ -196,9 +112,9 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon init(); try { parse(); - phpDocument = new PHPDocument(null); - phpDocument.nodes = nodes; - PHPeclipsePlugin.log(1,phpDocument.toString()); + phpDocument.nodes = new AstNode[nodes.length]; + System.arraycopy(nodes,0,phpDocument.nodes,0,nodes.length); + phpDocument.toString(); } catch (ParseException e) { processParseException(e); } @@ -214,7 +130,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon if (errorMessage == null) { PHPeclipsePlugin.log(e); errorMessage = "this exception wasn't handled by the parser please tell us how to reproduce it"; - errorStart = jj_input_stream.getPosition(); + errorStart = SimpleCharStream.getPosition(); errorEnd = errorStart + 1; } setMarker(e); @@ -230,8 +146,8 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon if (errorStart == -1) { setMarker(fileToParse, errorMessage, - jj_input_stream.tokenBegin, - jj_input_stream.tokenBegin + e.currentToken.image.length(), + SimpleCharStream.tokenBegin, + SimpleCharStream.tokenBegin + e.currentToken.image.length(), errorLevel, "Line " + e.currentToken.beginLine); } else { @@ -359,7 +275,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon if (currentPosition == htmlStart) { return; } - final char[] chars = SimpleCharStream.currentBuffer.substring(htmlStart,currentPosition).toCharArray(); + final char[] chars = SimpleCharStream.currentBuffer.substring(htmlStart,currentPosition+1).toCharArray(); pushOnAstNodes(new HTMLCode(chars, htmlStart,currentPosition)); } @@ -367,12 +283,6 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon phpFile(); } - static final public void phpTest() throws ParseException { - Php(); - jj_consume_token(0); - PHPParser.createNewHTMLCode(); - } - static final public void phpFile() throws ParseException { try { label_1: @@ -448,7 +358,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon * or */ static final public void PhpBlock() throws ParseException { - final int start = jj_input_stream.getPosition(); + final int start = SimpleCharStream.getPosition(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PHPECHOSTART: phpEchoBlock(); @@ -510,7 +420,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon setMarker(fileToParse, "You should use '' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } break; @@ -628,13 +538,13 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon final int pos; jj_consume_token(CLASS); try { - pos = jj_input_stream.getPosition(); + pos = SimpleCharStream.getPosition(); className = jj_consume_token(IDENTIFIER); } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -645,8 +555,8 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } break; @@ -682,8 +592,8 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image + "', '{' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } label_3: @@ -704,8 +614,8 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', 'var', 'function' or '}' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } } @@ -719,11 +629,10 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case FUNCTION: method = MethodDeclaration(); - classDeclaration.addMethod(method); + method.setParent(classDeclaration); break; case VAR: field = FieldDeclaration(); - classDeclaration.addVariable(field); break; default: jj_la1[8] = jj_gen; @@ -766,22 +675,23 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected after variable declaration"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } list = new VariableDeclaration[arrayList.size()]; arrayList.toArray(list); {if (true) return new FieldDeclaration(list, pos, - SimpleCharStream.getPosition());} + SimpleCharStream.getPosition(), + currentSegment);} throw new Error("Missing return statement in function"); } static final public VariableDeclaration VariableDeclarator() throws ParseException { - final String varName, varValue; + final String varName; Expression initializer = null; - final int pos = jj_input_stream.getPosition(); + final int pos = SimpleCharStream.getPosition(); varName = VariableDeclaratorId(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ASSIGN: @@ -791,8 +701,8 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon } catch (ParseException e) { errorMessage = "Literal expression expected in variable initializer"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } break; @@ -804,7 +714,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon {if (true) return new VariableDeclaration(currentSegment, varName.toCharArray(), pos, - jj_input_stream.getPosition());} + SimpleCharStream.getPosition());} } {if (true) return new VariableDeclaration(currentSegment, varName.toCharArray(), @@ -843,8 +753,8 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon } catch (ParseException e) { errorMessage = "'$' expected for variable identifier"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } throw new Error("Missing return statement in function"); @@ -880,7 +790,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon case DOLLAR: jj_consume_token(DOLLAR); expr = VariableName(); - {if (true) return expr;} + {if (true) return "$" + expr;} break; default: jj_la1[12] = jj_gen; @@ -900,9 +810,9 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon jj_consume_token(LBRACE); expression = Expression(); jj_consume_token(RBRACE); - buff = new StringBuffer('{'); + buff = new StringBuffer("{"); buff.append(expression.toStringExpression()); - buff.append('}'); + buff.append("}"); {if (true) return buff.toString();} break; case IDENTIFIER: @@ -1098,30 +1008,25 @@ Expression expr,expr2; */ static final public MethodDeclaration MethodDeclaration() throws ParseException { final MethodDeclaration functionDeclaration; - Token functionToken; final Block block; - functionToken = jj_consume_token(FUNCTION); + jj_consume_token(FUNCTION); try { functionDeclaration = MethodDeclarator(); outlineInfo.addVariable(new String(functionDeclaration.name)); } catch (ParseException e) { - if (errorMessage != null) { - {if (true) throw e;} - } + if (errorMessage != null) {if (true) throw e;} errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function identifier expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } if (currentSegment != null) { currentSegment.add(functionDeclaration); currentSegment = functionDeclaration; } - currentFunction = functionDeclaration; block = Block(); functionDeclaration.statements = block.statements; - currentFunction = null; if (currentSegment != null) { currentSegment = (OutlineableWithChildren) currentSegment.getParent(); } @@ -1163,8 +1068,6 @@ Expression expr,expr2; * (FormalParameter()) */ static final public Hashtable FormalParameters() throws ParseException { - String expr; - final StringBuffer buff = new StringBuffer("("); VariableDeclaration var; final Hashtable parameters = new Hashtable(); try { @@ -1172,8 +1075,8 @@ Expression expr,expr2; } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', '(' expected after function identifier"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -1206,8 +1109,8 @@ Expression expr,expr2; } catch (ParseException e) { errorMessage = "')' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } {if (true) return parameters;} @@ -1244,55 +1147,55 @@ Expression expr,expr2; jj_consume_token(STRING); pos = SimpleCharStream.getPosition(); {if (true) return new ConstantIdentifier(Types.STRING, - pos,pos-6);} + pos,pos-6);} break; case BOOL: jj_consume_token(BOOL); pos = SimpleCharStream.getPosition(); {if (true) return new ConstantIdentifier(Types.BOOL, - pos,pos-4);} + pos,pos-4);} break; case BOOLEAN: jj_consume_token(BOOLEAN); pos = SimpleCharStream.getPosition(); {if (true) return new ConstantIdentifier(Types.BOOLEAN, - pos,pos-7);} + pos,pos-7);} break; case REAL: jj_consume_token(REAL); pos = SimpleCharStream.getPosition(); {if (true) return new ConstantIdentifier(Types.REAL, - pos,pos-4);} + pos,pos-4);} break; case DOUBLE: jj_consume_token(DOUBLE); pos = SimpleCharStream.getPosition(); {if (true) return new ConstantIdentifier(Types.DOUBLE, - pos,pos-5);} + pos,pos-5);} break; case FLOAT: jj_consume_token(FLOAT); pos = SimpleCharStream.getPosition(); {if (true) return new ConstantIdentifier(Types.FLOAT, - pos,pos-5);} + pos,pos-5);} break; case INT: jj_consume_token(INT); pos = SimpleCharStream.getPosition(); {if (true) return new ConstantIdentifier(Types.INT, - pos,pos-3);} + pos,pos-3);} break; case INTEGER: jj_consume_token(INTEGER); pos = SimpleCharStream.getPosition(); {if (true) return new ConstantIdentifier(Types.INTEGER, - pos,pos-7);} + pos,pos-7);} break; case OBJECT: jj_consume_token(OBJECT); pos = SimpleCharStream.getPosition(); {if (true) return new ConstantIdentifier(Types.OBJECT, - pos,pos-6);} + pos,pos-6);} break; default: jj_la1[25] = jj_gen; @@ -1371,8 +1274,8 @@ Expression expr,expr2; } errorMessage = "expression expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } {if (true) return new VarAssignation(varName.toCharArray(), @@ -1676,8 +1579,8 @@ Expression expr,expr2; } errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', expression expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } expr = new BinaryExpression(expr,expr2,operator); @@ -1815,13 +1718,11 @@ Expression expr,expr2; try { expr = UnaryExpression(); } catch (ParseException e) { - if (errorMessage != null) { - {if (true) throw e;} - } + if (errorMessage != null) {if (true) throw e;} errorMessage = "unexpected token '"+e.currentToken.next.image+"'"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } label_18: @@ -1892,7 +1793,7 @@ Expression expr,expr2; case LPAREN: case DOLLAR_ID: expr = AtUnaryExpression(); - {if (true) return expr;} + {if (true) return expr;} break; default: jj_la1[48] = jj_gen; @@ -2056,8 +1957,8 @@ final int operator; } catch (ParseException e) { errorMessage = "')' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } {if (true) return expr;} @@ -2141,7 +2042,6 @@ final int pos = SimpleCharStream.getPosition(); static final public Expression PrimaryExpression() throws ParseException { final Token identifier; Expression expr; - final StringBuffer buff = new StringBuffer(); final int pos = SimpleCharStream.getPosition(); if (jj_2_5(2)) { identifier = jj_consume_token(IDENTIFIER); @@ -2333,8 +2233,8 @@ final int pos = SimpleCharStream.getPosition(); } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function call or field access expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } {if (true) return new ClassAccess(prefix, @@ -2424,8 +2324,8 @@ final int pos = SimpleCharStream.getPosition(); } catch (ParseException e) { errorMessage = "']' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } {if (true) return new ArrayDeclarator(prefix,expression,SimpleCharStream.getPosition());} @@ -2455,7 +2355,7 @@ final int pos = SimpleCharStream.getPosition(); case STRING_LITERAL: token = jj_consume_token(STRING_LITERAL); pos = SimpleCharStream.getPosition(); - {if (true) return new StringLiteral(token.image.toCharArray(),pos-token.image.length(),pos);} + {if (true) return new StringLiteral(token.image.toCharArray(),pos-token.image.length());} break; case TRUE: jj_consume_token(TRUE); @@ -2481,11 +2381,29 @@ final int pos = SimpleCharStream.getPosition(); } static final public FunctionCall Arguments(Expression func) throws ParseException { -ArgumentDeclaration[] args = null; +Expression[] args = null; jj_consume_token(LPAREN); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ARRAY: + case LIST: + case PRINT: + case NEW: + case NULL: + case TRUE: + case FALSE: + case AT: case DOLLAR: + case BANG: + case INCR: + case DECR: + case PLUS: + case MINUS: case BIT_AND: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case STRING_LITERAL: + case IDENTIFIER: + case LPAREN: case DOLLAR_ID: args = ArgumentList(); break; @@ -2498,19 +2416,23 @@ ArgumentDeclaration[] args = null; } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ')' expected to close the argument list"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } {if (true) return new FunctionCall(func,args,SimpleCharStream.getPosition());} throw new Error("Missing return statement in function"); } - static final public ArgumentDeclaration[] ArgumentList() throws ParseException { -ArgumentDeclaration arg; +/** + * An argument list is a list of arguments separated by comma : + * argumentDeclaration() (, argumentDeclaration)* + * @return an array of arguments + */ + static final public Expression[] ArgumentList() throws ParseException { +Expression arg; final ArrayList list = new ArrayList(); -ArgumentDeclaration argument; - arg = argumentDeclaration(); + arg = Expression(); list.add(arg); label_21: while (true) { @@ -2524,63 +2446,19 @@ ArgumentDeclaration argument; } jj_consume_token(COMMA); try { - arg = argumentDeclaration(); + arg = Expression(); list.add(arg); } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. An expression expected after a comma in argument list"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } } - ArgumentDeclaration[] args = new ArgumentDeclaration[list.size()]; - list.toArray(args); - {if (true) return args;} - throw new Error("Missing return statement in function"); - } - - static final public ArgumentDeclaration argumentDeclaration() throws ParseException { - boolean reference = false; - String varName; - Expression initializer = null; - final int pos = SimpleCharStream.getPosition(); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case BIT_AND: - jj_consume_token(BIT_AND); - reference = true; - break; - default: - jj_la1[71] = jj_gen; - ; - } - varName = VariableDeclaratorId(); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case ASSIGN: - jj_consume_token(ASSIGN); - try { - initializer = VariableInitializer(); - } catch (ParseException e) { - errorMessage = "Literal expression expected in variable initializer"; - errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; - {if (true) throw e;} - } - break; - default: - jj_la1[72] = jj_gen; - ; - } - if (initializer == null) { - {if (true) return new ArgumentDeclaration(varName.toCharArray(), - reference, - pos);} - } - {if (true) return new ArgumentDeclaration(varName.toCharArray(), - reference, - initializer, - pos);} + Expression[] arguments = new Expression[list.size()]; + list.toArray(arguments); + {if (true) return arguments;} throw new Error("Missing return statement in function"); } @@ -2598,8 +2476,8 @@ ArgumentDeclaration argument; if (e.currentToken.next.kind != 4) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } } @@ -2630,8 +2508,8 @@ ArgumentDeclaration argument; } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } {if (true) return statement;} @@ -2682,7 +2560,7 @@ ArgumentDeclaration argument; token = jj_consume_token(AT); break; default: - jj_la1[73] = jj_gen; + jj_la1[71] = jj_gen; ; } statement = IncludeStatement(); @@ -2700,7 +2578,7 @@ ArgumentDeclaration argument; {if (true) return statement;} break; default: - jj_la1[74] = jj_gen; + jj_la1[72] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -2760,7 +2638,7 @@ ArgumentDeclaration argument; {if (true) return statement;} break; default: - jj_la1[75] = jj_gen; + jj_la1[73] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -2782,7 +2660,7 @@ ArgumentDeclaration argument; ; break; default: - jj_la1[76] = jj_gen; + jj_la1[74] = jj_gen; break label_22; } phpEchoBlock(); @@ -2796,18 +2674,18 @@ ArgumentDeclaration argument; jj_consume_token(PHPSTARTSHORT); break; default: - jj_la1[77] = jj_gen; + jj_la1[75] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } catch (ParseException e) { errorMessage = "End of file unexpected, '