From: axelcl Date: Mon, 29 Aug 2005 16:33:23 +0000 (+0000) Subject: Added new syntax error "Assignment operator not allowed after identifier..." X-Git-Url: http://secure.phpeclipse.com Added new syntax error "Assignment operator not allowed after identifier..." --- 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 459987a..b7a1353 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 @@ -2,7 +2,7 @@ * Copyright (c) 2002 www.phpeclipse.de All rights reserved. This program and the accompanying material are made available under the * terms of the Common Public License v1.0 which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html - * + * * Contributors: www.phpeclipse.de **********************************************************************************************************************************/ package net.sourceforge.phpdt.internal.compiler.parser; @@ -99,7 +99,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI /** * ClassDeclaration Constructor. - * + * * @param s * @param sess * Description of Parameter @@ -142,7 +142,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI /** * This method will throw the SyntaxError. It will add the good lines and * columns to the Error - * + * * @param error * the error message * @throws SyntaxError @@ -163,7 +163,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI /** * This method will throw the SyntaxError. It will add the good lines and * columns to the Error - * + * * @param error * the error message * @throws SyntaxError @@ -2502,6 +2502,20 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI // | rw_variable T_INC // | rw_variable T_DEC case TokenNameIdentifier: + char[] ident = scanner.getCurrentTokenSource(); + Expression lhsIdentifier = identifier(true, true); + if (lhsIdentifier != null) { + expression = lhsIdentifier; + } + if (token == TokenNameEQUAL || token == TokenNamePLUS_EQUAL + || token == TokenNameMINUS_EQUAL || token == TokenNameMULTIPLY_EQUAL || token == TokenNameDIVIDE_EQUAL + || token == TokenNameDOT_EQUAL || token == TokenNameREMAINDER_EQUAL || token == TokenNameAND_EQUAL + || token == TokenNameOR_EQUAL || token == TokenNameXOR_EQUAL || token == TokenNameRIGHT_SHIFT_EQUAL + || token == TokenNameLEFT_SHIFT_EQUAL) { + String error = "Assignment operator '"+scanner.toStringAction(token)+"' not allowed after identifier '"+new String(ident)+"' (use 'define(...)' to define constants)."; + throwSyntaxError(error); + } + break; case TokenNameVariable: case TokenNameDOLLAR: boolean rememberedVar = false; @@ -3330,6 +3344,14 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI } } + private Expression identifier(boolean lefthandside, boolean ignoreVar) { + // variable: + // base_variable_with_function_calls T_OBJECT_OPERATOR + // object_property method_or_not variable_properties + // | base_variable_with_function_calls + return base_variable_with_function_calls(lefthandside, ignoreVar); + } + private void method_or_not() { // method_or_not: // '(' function_call_parameter_list ')' @@ -3676,7 +3698,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI /** * Parse and check the include file name - * + * * @param includeToken */ private void checkFileName(int includeToken) { @@ -3975,7 +3997,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI // /* remember current scanner position */ // int startPos = scanner.startPosition; // int currentPos = scanner.currentPosition; - // + // // this.checkAndReportBracketAnomalies(problemReporter()); // /* reset scanner where it was */ // scanner.startPosition = startPos; @@ -4561,7 +4583,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI "$_SESSION", "$_SERVER" }; /** - * + * */ private void pushFunctionVariableSet() { HashSet set = new HashSet(); @@ -4600,7 +4622,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI /** * add the current identifier source to the set of assigned variables - * + * * @param set */ private void addVariableSet(HashSet set) { @@ -4611,7 +4633,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI /** * add the current identifier source to the set of assigned variables - * + * */ private void addVariableSet() { HashSet set = peekVariableSet(); @@ -4622,7 +4644,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI /** * add the current identifier source to the set of assigned variables - * + * */ private void addVariableSet(char[] token) { HashSet set = peekVariableSet(); @@ -4635,7 +4657,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI * check if the current identifier source is in the set of assigned * variables Returns true, if no set is defined for the current scanner * position - * + * */ private boolean containsVariableSet() { return containsVariableSet(scanner.getCurrentTokenSource());