From: khartlage Date: Sun, 2 Mar 2003 17:56:26 +0000 (+0000) Subject: improved PHP Scanner X-Git-Url: http://git.phpeclipse.com improved PHP Scanner --- diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/compiler/ITerminalSymbols.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/compiler/ITerminalSymbols.java index 633811c..c77f43c 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/compiler/ITerminalSymbols.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/compiler/ITerminalSymbols.java @@ -21,6 +21,19 @@ package net.sourceforge.phpdt.core.compiler; */ public interface ITerminalSymbols { + public final static String[] PHP_TYPES = + { + "string", + "object", + "bool", + "boolean", + "real", + "double", + "float", + "int", + "integer", + }; + //"array", public final static int TokenNameWHITESPACE = 900, TokenNameCOMMENT_LINE = 901, TokenNameCOMMENT_BLOCK = 902, 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 ea3cd80..8a9f5e1 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 @@ -16,7 +16,6 @@ import java.util.Hashtable; import net.sourceforge.phpdt.core.compiler.*; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import net.sourceforge.phpeclipse.phpeditor.PHPString; -import net.sourceforge.phpeclipse.phpeditor.php.PHPKeywords; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; @@ -25,9 +24,7 @@ import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.ui.texteditor.MarkerUtilities; import test.PHPParserSuperclass; -public class Parser - extends PHPParserSuperclass - implements PHPKeywords, ITerminalSymbols { +public class Parser extends PHPParserSuperclass implements ITerminalSymbols { public static final int ERROR = 2; public static final int WARNING = 1; @@ -2835,26 +2832,26 @@ public class Parser unaryExpression(); } - private void typeName() throws CoreException { - //'string' 'unset' 'array' 'object' - //'bool' 'boolean' - //'real' 'double' 'float' - //'int' 'integer' - String identifier = ""; - if (token == TokenNameIdentifier) { - char[] ident = scanner.getCurrentIdentifierSource(); - identifier = new String(ident); - String str = identifier.toLowerCase(); - getNextToken(); - for (int i = 0; i < PHP_TYPES.length; i++) { - if (PHP_TYPES[i].equals(str)) { - return; - } - } - } - throwSyntaxError( - "Expected type cast '( )'; Got '" + identifier + "'."); - } + // private void typeName() throws CoreException { + // //'string' 'unset' 'array' 'object' + // //'bool' 'boolean' + // //'real' 'double' 'float' + // //'int' 'integer' + // String identifier = ""; + // if (token == TokenNameIdentifier) { + // char[] ident = scanner.getCurrentIdentifierSource(); + // identifier = new String(ident); + // String str = identifier.toLowerCase(); + // getNextToken(); + // for (int i = 0; i < PHP_TYPES.length; i++) { + // if (PHP_TYPES[i].equals(str)) { + // return; + // } + // } + // } + // throwSyntaxError( + // "Expected type cast '( )'; Got '" + identifier + "'."); + // } private void assignExpression() throws CoreException { castExpression(); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPKeywords.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPKeywords.java deleted file mode 100644 index c36c59d..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPKeywords.java +++ /dev/null @@ -1,165 +0,0 @@ -/********************************************************************** -Copyright (c) 2000, 2002 IBM Corp. and others. -All rights reserved. This program and the accompanying materials -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: - IBM Corporation - Initial implementation - Klaus Hartlage - www.eclipseproject.de -**********************************************************************/ -package net.sourceforge.phpeclipse.phpeditor.php; - -import net.sourceforge.phpdt.core.compiler.ITerminalSymbols; - -/** - * PHP keyWords and Token definitions - */ -public interface PHPKeywords extends ITerminalSymbols { - -// public final static String[] PHP_KEYWORS = -// { -// "if", -// "elseif", -// "else", -// "endif", -// "for", -// "endfor", -// "while", -// "endwhile", -// "switch", -// "case", -// "endswitch", -// "break", -// "continue", -// "return", -// "define", -// "include", -// "include_once", -// "require", -// "require_once", -// "function", -// "class", -// "new", -// "do", -// "old_function", -// "default", -// "global", -// "static", -// "foreach", -// "endforeach", -// "extends", -// "empty", -// "array", -// "isset", -// "echo", -// "var", -// "as", -// "print", -// "unset", -// "exit", -// "die", -// "and", -// "or", -// "xor", -// "list", -// "null", -// "false", -// "true" }; - - public final static String[] PHP_TYPES = { "string", "unset", - //"array", - "object", "bool", "boolean", "real", "double", "float", "int", "integer", }; - - // public final static int TokenNameKEYWORD = 1000; - // public final static int TokenNameif = 1001; - // public final static int TokenNameelseif = 1002; - // public final static int TokenNameelse = 1003; - // public final static int TokenNameendif = 1004; - // public final static int TokenNamefor = 1005; - // public final static int TokenNameendfor = 1006; - // public final static int TokenNamewhile = 1007; - // public final static int TokenNameendwhile = 1008; - // public final static int TokenNameswitch = 1009; - // public final static int TokenNamecase = 10010; - // public final static int TokenNameendswitch = 1011; - // public final static int TokenNamebreak = 1012; - // public final static int TokenNamecontinue = 1013; - // public final static int TokenNamereturn = 1014; - // public final static int TokenNamedefine = 1015; - // public final static int TokenNameinclude = 1016; - // public final static int TokenNameinclude_once = 1017; - // public final static int TokenNamerequire = 1018; - // public final static int TokenNamerequire_once = 1019; - // public final static int TokenNamefunction = 1020; - // public final static int TokenNameclass = 1021; - // public final static int TokenNamenew = 1022; - // public final static int TokenNamedo = 1023; - // public final static int TokenNameold_function = 1024; - // public final static int TokenNamedefault = 1025; - // public final static int TokenNameglobal = 1026; - // public final static int TokenNamestatic = 1027; - // public final static int TokenNameforeach = 1028; - // public final static int TokenNameendforeach = 1029; - // public final static int TokenNameextends = 1030; - // // public final static int TokenNameempty = 1031; - // // public final static int TokenNamearray = 1032; - // public final static int TokenNameecho = 1033; - // public final static int TokenNamevar = 1034; - // public final static int TokenNameas = 1035; - // public final static int TokenNameprint = 1036; - // // public final static int TokenNameunset = 1037; - // // public final static int TokenNameexit = 1038; - // // public final static int TokenNamedie = 1039; - // public final static int TokenNameand = 1040; - // public final static int TokenNameor = 1041; - // public final static int TokenNamexor = 1042; - // public final static int TokenNamelist = 1043; - // public final static int TokenNamenull = 1044; - // public final static int TokenNamefalse = 1045; - // public final static int TokenNametrue = 1046; - /* - public final static int[] PHP_KEYWORD_TOKEN = - { - TokenNameif, - TokenNameelseif, - TokenNameelse, - TokenNameendif, - TokenNamefor, - TokenNameendfor, - TokenNamewhile, - TokenNameendwhile, - TokenNameswitch, - TokenNamecase, - TokenNameendswitch, - TokenNamebreak, - TokenNamecontinue, - TokenNamereturn, - TokenNamedefine, - TokenNameinclude, - TokenNameinclude_once, - TokenNamerequire, - TokenNamerequire_once, - TokenNamefunction, - TokenNameclass, - TokenNamenew, - TokenNamedo, - TokenNameold_function, - TokenNamedefault, - TokenNameglobal, - TokenNamestatic, - TokenNameforeach, - TokenNameendforeach, - TokenNameextends, - // TokenNameempty, - // TokenNamearray, - // TokenNameisset, - TokenNameecho, TokenNamevar, TokenNameas, - TokenNameprint, - // TokenNameunset, - // TokenNameexit, TokenNamedie, - // TokenNameand, TokenNameor, TokenNamexor, - TokenNamelist, - TokenNamenull, TokenNamefalse, TokenNametrue };*/ -}