From b85608dd476fccd22900e2bc8fd3e04e86f8fff6 Mon Sep 17 00:00:00 2001 From: khartlage Date: Tue, 2 Mar 2004 21:08:00 +0000 Subject: [PATCH 1/1] improved parser keywords abstract, final, public, protected, privatem,.. --- .../phpdt/core/compiler/ITerminalSymbols.java | 2 +- .../internal/compiler/DocumentElementParser.java | 5 ---- .../phpdt/internal/compiler/parser/Parser.java | 4 ++- .../phpdt/internal/compiler/parser/Scanner.java | 24 ++++++++++++++---- .../phpdt/internal/compiler/parser/UnitParser.java | 20 +------------- .../sourceforge/phpeclipse/phpeditor/phpsyntax.xml | 26 ++++++++++++++++++- 6 files changed, 49 insertions(+), 32 deletions(-) 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 9dfca8a..120f6b1 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 @@ -150,7 +150,7 @@ public interface ITerminalSymbols { 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 TokenNamedie = 1039; // public final static int TokenNameand = 1040; // public final static int TokenNameor = 1041; // public final static int TokenNamexor = 1042; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/DocumentElementParser.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/DocumentElementParser.java index 079b182..2d6c723 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/DocumentElementParser.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/DocumentElementParser.java @@ -10,7 +10,6 @@ *******************************************************************************/ package net.sourceforge.phpdt.internal.compiler; -import net.sourceforge.phpdt.core.compiler.CharOperation; import net.sourceforge.phpdt.core.compiler.IProblem; import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit; import net.sourceforge.phpdt.internal.compiler.parser.UnitParser; @@ -18,8 +17,6 @@ import net.sourceforge.phpdt.internal.compiler.problem.AbortCompilation; import net.sourceforge.phpdt.internal.compiler.problem.ProblemReporter; import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration; -import org.eclipse.core.runtime.CoreException; - /* * A document element parser extracts structural information @@ -1044,8 +1041,6 @@ public void parseCompilationUnit(ICompilationUnit unit) { scanner.resetTo(0, regionSource.length); scanner.setSource(regionSource); parse(); - } catch (CoreException e) { - e.printStackTrace(); } catch (AbortCompilation ex) { } } 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 9567e32..dceae31 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 @@ -1422,7 +1422,7 @@ public class Parser //extends PHPParserSuperclass // | T_FINAL T_CLASS if (token == TokenNameclass) { getNextToken(); - } else if (token == TokenNamefinal) { + } else if (token == TokenNameabstract) { checkAndSetModifiers(AccAbstract); getNextToken(); if (token != TokenNameclass) { @@ -1435,6 +1435,8 @@ public class Parser //extends PHPParserSuperclass throwSyntaxError("Keyword 'class' expected after keyword 'final'."); } getNextToken(); + } else { + throwSyntaxError("Keyword 'class' 'final' or 'abstract' expected"); } } private void interface_extends_list() { diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java index d7c2618..f870539 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java @@ -2665,17 +2665,13 @@ public class Scanner implements IScanner, ITerminalSymbols { } case 'd' : //define declare default do die + // TODO delete define ==> no keyword ! switch (length) { case 2 : if ((data[++index] == 'o')) return TokenNamedo; else return TokenNameIdentifier; - case 3 : - if ((data[++index] == 'i') && (data[++index] == 'e')) - return TokenNamedie; - else - return TokenNameIdentifier; case 6 : if ((data[++index] == 'e') && (data[++index] == 'f') @@ -3394,6 +3390,10 @@ public class Scanner implements IScanner, ITerminalSymbols { return "Identifier(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ case TokenNameVariable : return "Variable(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ + case TokenNameabstract : + return "abstract"; //$NON-NLS-1$ + case TokenNamearray : + return "array"; //$NON-NLS-1$ case TokenNameas : return "as"; //$NON-NLS-1$ case TokenNamebreak : @@ -3430,6 +3430,8 @@ public class Scanner implements IScanner, ITerminalSymbols { return "extends"; //$NON-NLS-1$ case TokenNamefalse : return "false"; //$NON-NLS-1$ + case TokenNamefinal : + return "final"; //$NON-NLS-1$ case TokenNamefor : return "for"; //$NON-NLS-1$ case TokenNameforeach : @@ -3440,10 +3442,14 @@ public class Scanner implements IScanner, ITerminalSymbols { return "global"; //$NON-NLS-1$ case TokenNameif : return "if"; //$NON-NLS-1$ + case TokenNameimplements : + return "implements"; //$NON-NLS-1$ case TokenNameinclude : return "include"; //$NON-NLS-1$ case TokenNameinclude_once : return "include_once"; //$NON-NLS-1$ + case TokenNameinterface : + return "interface"; //$NON-NLS-1$ case TokenNamelist : return "list"; //$NON-NLS-1$ case TokenNamenew : @@ -3452,6 +3458,12 @@ public class Scanner implements IScanner, ITerminalSymbols { return "null"; //$NON-NLS-1$ case TokenNameprint : return "print"; //$NON-NLS-1$ + case TokenNameprivate : + return "private"; //$NON-NLS-1$ + case TokenNameprotected : + return "protected"; //$NON-NLS-1$ + case TokenNamepublic : + return "public"; //$NON-NLS-1$ case TokenNamerequire : return "require"; //$NON-NLS-1$ case TokenNamerequire_once : @@ -3464,6 +3476,8 @@ public class Scanner implements IScanner, ITerminalSymbols { return "switch"; //$NON-NLS-1$ case TokenNametrue : return "true"; //$NON-NLS-1$ + case TokenNameunset : + return "unset"; //$NON-NLS-1$ case TokenNamevar : return "var"; //$NON-NLS-1$ case TokenNamewhile : diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/UnitParser.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/UnitParser.java index 316c046..f8ec712 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/UnitParser.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/UnitParser.java @@ -7,7 +7,6 @@ import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit; import net.sourceforge.phpdt.internal.compiler.problem.AbortCompilation; import net.sourceforge.phpdt.internal.compiler.problem.ProblemReporter; import net.sourceforge.phpdt.internal.compiler.util.Util; -import net.sourceforge.phpdt.internal.core.BasicCompilationUnit; import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration; import net.sourceforge.phpeclipse.internal.compiler.ast.ConstructorDeclaration; import net.sourceforge.phpeclipse.internal.compiler.ast.FieldDeclaration; @@ -161,8 +160,7 @@ public class UnitParser extends Parser { // storeProblemsFor(((BasicCompilationUnit)sourceUnit).getResource(), compilationResult.getAllProblems()); // } // // jsurfer end - } catch (CoreException e) { - e.printStackTrace(); + } finally { unit = compilationUnit; compilationUnit = null; // reset parser @@ -265,9 +263,7 @@ public class UnitParser extends Parser { parse(); } catch (AbortCompilation ex) { lastAct = ERROR_ACTION; - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + } finally { nestedMethod[nestedType]--; } @@ -330,9 +326,6 @@ public class UnitParser extends Parser { parse(); } catch (AbortCompilation ex) { lastAct = ERROR_ACTION; - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); } finally { nestedMethod[nestedType]--; } @@ -368,9 +361,6 @@ public class UnitParser extends Parser { parse(); } catch (AbortCompilation ex) { lastAct = ERROR_ACTION; - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); } finally { nestedMethod[nestedType]--; } @@ -414,9 +404,6 @@ public class UnitParser extends Parser { parse(); } catch (AbortCompilation ex) { lastAct = ERROR_ACTION; - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); } finally { nestedMethod[nestedType]--; } @@ -456,9 +443,6 @@ public class UnitParser extends Parser { compilationUnit = new CompilationUnitDeclaration(problemReporter, compilationResult, scanner.source.length); /* run automaton */ parse(); - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); } catch (SyntaxError syntaxError) { // } finally { diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpsyntax.xml b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpsyntax.xml index fa5fa0a..8336273 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpsyntax.xml +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpsyntax.xml @@ -371,6 +371,7 @@ If the open fails, the function returns FALSE, otherwise it returns a pointer to + Directory class with properties, handle and class and methods read, rewind and close. @@ -2627,7 +2628,7 @@ Note that this comparison is case sensitive. - + @@ -2651,7 +2652,7 @@ Note that this comparison is case sensitive. - + @@ -2659,6 +2660,27 @@ Note that this comparison is case sensitive. + + + + + + + + + + + + + + + + + + + + + ========================================================= *Below this are the various PHP-specific variable types * ========================================================= -- 1.7.1