From: robekras Date: Sun, 6 Oct 2013 16:29:37 +0000 (+0200) Subject: 1) Fixed issue #872. X-Git-Url: http://secure.phpeclipse.com?hp=5209c4dfb9f900149721bb0f3df969ae4f8f832a 1) Fixed issue #872. Signed-off-by: robekras --- diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java index 37aed9d..8b3f682 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java @@ -950,7 +950,15 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, static_var_list(); if (token == TokenName.SEMICOLON) { getNextToken(); - } else { + } + else if (token == TokenName.PAAMAYIM_NEKUDOTAYIM) { + getNextToken (); + + if (token != TokenName.IDENTIFIER) { + throwSyntaxError("identifier expected after '::'."); + } + } + else { if (token != TokenName.INLINE_HTML) { throwSyntaxError("';' expected after 'static' statement."); } @@ -1066,17 +1074,17 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, if (token != TokenName.LBRACE) { throwSyntaxError("'{' expected in 'try' statement."); } - + getNextToken(); - + if (token != TokenName.RBRACE) { // Process the statement only if there is (possibly) a statement statementList (); - + if (token != TokenName.RBRACE) { throwSyntaxError("'}' expected in 'try' statement."); } } - + getNextToken(); return statement; @@ -3070,7 +3078,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, } } break; - + case TERNARY_SHORT: case PLUS_EQUAL: case MINUS_EQUAL: @@ -3281,7 +3289,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, getNextToken(); expression = new EqualExpression(expression, expr_without_variable (only_variable, initHandler, bColonAllowed), OperatorIds.TERNARY_SHORT); break; - + case QUESTION: getNextToken(); Expression valueIfTrue = expr_without_variable (true, null, true); @@ -3691,7 +3699,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, /** * base_variable_with_function_calls: * base_variable | function_call - * + * * @param lefthandside * @param ignoreVar * @return @@ -3700,7 +3708,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, if (Scanner.TRACE) { System.out.println("TRACE: base_variable_with_function_calls()"); } - + return function_call(lefthandside, ignoreVar); } @@ -3709,28 +3717,28 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, * reference_variable * | simple_indirect_reference reference_variable * | static_member - * + * * @param lefthandside * @return */ private Expression base_variable (boolean lefthandside) { Expression ref = null; - + if (Scanner.TRACE) { System.out.println ("TRACE: base_variable()"); } - + if (token == TokenName.IDENTIFIER) { static_member (); - } + } else { while (token == TokenName.DOLLAR) { getNextToken (); } - + reference_variable (lefthandside, false); } - + return ref; } @@ -3785,7 +3793,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, if (Scanner.TRACE) { System.out.println("TRACE: compound_variable()"); } - + if (token == TokenName.VARIABLE) { if (!lefthandside) { if (!containsVariableSet()) { @@ -3793,9 +3801,9 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, // String(scanner.getCurrentIdentifierSource()) // + " may not have been initialized"); problemReporter.uninitializedLocalVariable ( - new String (scanner.getCurrentIdentifierSource()), + new String (scanner.getCurrentIdentifierSource()), scanner.getCurrentTokenStartPosition(), - scanner.getCurrentTokenEndPosition(), + scanner.getCurrentTokenEndPosition(), referenceContext, compilationUnit.compilationResult); } @@ -3804,33 +3812,33 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, addVariableSet(); } } - - FieldReference ref = new FieldReference (scanner.getCurrentIdentifierSource(), + + FieldReference ref = new FieldReference (scanner.getCurrentIdentifierSource(), scanner.getCurrentTokenStartPosition()); getNextToken(); return ref; - } + } else { // because of simple_indirect_reference while (token == TokenName.DOLLAR) { getNextToken(); } - + if (token != TokenName.LBRACE) { reportSyntaxError("'{' expected after compound variable token '$'."); return null; } - + getNextToken(); expr(); - + if (token != TokenName.RBRACE) { throwSyntaxError("'}' expected after compound variable token '$'."); } - + getNextToken(); } - + return null; } // private void dim_offset() { // // dim_offset: // // /* empty */ @@ -3844,11 +3852,11 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, if (Scanner.TRACE) { System.out.println("TRACE: object_property()"); } - - if ((token == TokenName.VARIABLE) || + + if ((token == TokenName.VARIABLE) || (token == TokenName.DOLLAR)) { variable_without_objects (false, false); - } + } else { object_dim_list(); } @@ -3862,36 +3870,36 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, if (Scanner.TRACE) { System.out.println("TRACE: object_dim_list()"); } - + variable_name(); - + while (true) { if (token == TokenName.LBRACE) { getNextToken(); expr(); - + if (token != TokenName.RBRACE) { throwSyntaxError("'}' expected in object_dim_list."); } - + getNextToken(); - } + } else if (token == TokenName.LBRACKET) { getNextToken(); - + if (token == TokenName.RBRACKET) { getNextToken(); continue; } - + expr(); - + if (token != TokenName.RBRACKET) { throwSyntaxError("']' expected in object_dim_list."); } - + getNextToken(); - } + } else { break; } @@ -3905,17 +3913,17 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, if (Scanner.TRACE) { System.out.println("TRACE: variable_name()"); } - - if ((token == TokenName.IDENTIFIER) || + + if ((token == TokenName.IDENTIFIER) || (token.compareTo (TokenName.KEYWORD) > 0)) { if (token.compareTo (TokenName.KEYWORD) > 0) { // TODO show a warning "Keyword used as variable" ? } - + getNextToken(); - } + } else if ((token == TokenName.OP_AND_OLD) || // If the found token is e.g $var->and - (token == TokenName.OP_OR_OLD) || // or is $var->or + (token == TokenName.OP_OR_OLD) || // or is $var->or (token == TokenName.OP_XOR_OLD)) { // or is $var->xor getNextToken (); // get the next token. Maybe we should issue an warning? } @@ -3923,14 +3931,14 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, if (token != TokenName.LBRACE) { throwSyntaxError("'{' expected in variable name."); } - + getNextToken(); expr(); - + if (token != TokenName.RBRACE) { throwSyntaxError("'}' expected in variable name."); } - + getNextToken(); } } @@ -3948,19 +3956,19 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, } /** - * + * * variable: * base_variable_with_function_calls T_OBJECT_OPERATOR * object_property method_or_not variable_properties * | base_variable_with_function_calls - * + * * @param lefthandside * @param ignoreVar * @return */ private Expression variable (boolean lefthandside, boolean ignoreVar) { Expression ref = base_variable_with_function_calls (lefthandside, ignoreVar); - + if ((token == TokenName.MINUS_GREATER) || (token == TokenName.PAAMAYIM_NEKUDOTAYIM)) { /* I don't know why ref was set to null, but if it is null, the variable will neither be added to the set of variable, @@ -3972,7 +3980,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, method_or_not(); variable_properties(); } - + return ref; } @@ -3991,12 +3999,12 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, if (Scanner.TRACE) { System.out.println("TRACE: variable_property()"); } - + if (token == TokenName.MINUS_GREATER) { getNextToken(); object_property(); method_or_not(); - } + } else { throwSyntaxError("'->' expected in variable_property."); }