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 0eb3056..95618cb 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.jj +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.jj @@ -569,29 +569,29 @@ MORE : /* LITERALS */ TOKEN : { - < INTEGER_LITERAL: + (["l","L"])? | (["l","L"])? | (["l","L"])? > | - < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* > + <#DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* > | - < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ > + <#HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ > | - < #OCTAL_LITERAL: "0" (["0"-"7"])* > + <#OCTAL_LITERAL: "0" (["0"-"7"])* > | - < FLOATING_POINT_LITERAL: + )? (["f","F","d","D"])? | "." (["0"-"9"])+ ()? (["f","F","d","D"])? | (["0"-"9"])+ (["f","F","d","D"])? | (["0"-"9"])+ ()? ["f","F","d","D"] > | - < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ > + <#EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ > | - < STRING_LITERAL: ( | | )> -| < STRING_1: + | | )> +| -| < STRING_2: +| -| < STRING_3: +| ] - identifier = + [reference = ] identifier = formalParameters = FormalParameters() {return new MethodDeclaration(currentSegment, identifier.image.toCharArray(), @@ -1504,9 +1501,7 @@ Expression MultiplicativeExpression() : try { expr = UnaryExpression() } catch (ParseException e) { - if (errorMessage != null) { - throw e; - } + if (errorMessage != null) throw e; errorMessage = "unexpected token '"+e.currentToken.next.image+"'"; errorLevel = ERROR; errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; @@ -1535,8 +1530,7 @@ Expression UnaryExpression() : expr = UnaryExpressionNoPrefix() {return new PrefixedUnaryExpression(expr,OperatorIds.AND,pos);} | - expr = AtUnaryExpression() - {return expr;} + expr = AtUnaryExpression() {return expr;} } Expression AtUnaryExpression() : @@ -1788,7 +1782,7 @@ Literal Literal() : | token = {pos = SimpleCharStream.getPosition(); return new NumberLiteral(token.image.toCharArray(),pos-token.image.length(),pos);} | token = {pos = SimpleCharStream.getPosition(); - return new StringLiteral(token.image.toCharArray(),pos-token.image.length(),pos);} + return new StringLiteral(token.image.toCharArray(),pos-token.image.length());} | {pos = SimpleCharStream.getPosition(); return new TrueLiteral(pos-4,pos);} | {pos = SimpleCharStream.getPosition(); @@ -1799,7 +1793,7 @@ Literal Literal() : FunctionCall Arguments(Expression func) : { -ArgumentDeclaration[] args = null; +Expression[] args = null; } { [ args = ArgumentList() ] @@ -1815,18 +1809,22 @@ ArgumentDeclaration[] args = null; {return new FunctionCall(func,args,SimpleCharStream.getPosition());} } -ArgumentDeclaration[] ArgumentList() : +/** + * An argument list is a list of arguments separated by comma : + * argumentDeclaration() (, argumentDeclaration)* + * @return an array of arguments + */ +Expression[] ArgumentList() : { -ArgumentDeclaration arg; +Expression arg; final ArrayList list = new ArrayList(); -ArgumentDeclaration argument; } { - arg = argumentDeclaration() + arg = Expression() {list.add(arg);} ( 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"; @@ -1837,45 +1835,11 @@ ArgumentDeclaration argument; } )* { - ArgumentDeclaration[] args = new ArgumentDeclaration[list.size()]; - list.toArray(args); - return args;} + Expression[] arguments = new Expression[list.size()]; + list.toArray(arguments); + return arguments;} } -ArgumentDeclaration argumentDeclaration() : -{ - boolean reference = false; - String varName; - Expression initializer = null; - final int pos = SimpleCharStream.getPosition(); -} -{ - [ {reference = true;}] - varName = VariableDeclaratorId() - [ - - 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; - throw e; - } - ] - { - if (initializer == null) { - return new ArgumentDeclaration(varName.toCharArray(), - reference, - pos); - } - return new ArgumentDeclaration(varName.toCharArray(), - reference, - initializer, - pos); - } -} /** * A Statement without break. */