From: Edward Mann Date: Sun, 31 Oct 2010 05:18:23 +0000 (+0000) Subject: Putting in quick change to support namespace and const. This change only adds a few... X-Git-Url: http://git.phpeclipse.com?hp=bcd00b0a979c4dbd7d43d13f15997c272f71d32c Putting in quick change to support namespace and const. This change only adds a few ITerminalSymbols and changes the parser & scanner to accept const and namespace. Still need to put in error checking for namespace. --- 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 ae1db34..a7d3644 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 @@ -235,7 +235,7 @@ public interface ITerminalSymbols { public final static int TokenNameswitch = 1009; - public final static int TokenNamecase = 10010; + public final static int TokenNamecase = 1010; public final static int TokenNameendswitch = 1011; @@ -352,7 +352,11 @@ public interface ITerminalSymbols { public final static int TokenNameMETHOD_C = 1073; public final static int TokenNameFUNC_C = 1074; - + + public final static int TokenNameNamespace = 1075; + + public final static int TokenNameForwardSlash = 1076; + // special tokens not normally used in the parser public final static int TokenNamethis_PHP_COMPLETION = 2000; } 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 e6c6133..3d33858 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 @@ -856,6 +856,15 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, getNextToken(); } return statement; + } else if(token == TokenNameconst){ + getNextToken(); + if(token == TokenNameIdentifier){ + getNextToken(); + if(token == TokenNameEQUAL){ + getNextToken(); + } + //throwSyntaxError("'Ed i know your here"); + } } else if (token == TokenNamestatic) { getNextToken(); static_var_list(); @@ -2473,6 +2482,8 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, case TokenNameinclude_once: case TokenNamerequire: case TokenNamerequire_once: + case TokenNameNamespace: + case TokenNameconst: internal_functions_in_yacc(); break; // | '(' expr ')' @@ -4091,9 +4102,32 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, // T_REQUIRE_ONCE expr checkFileName(token); break; + case TokenNameNamespace: + // NAMESPACE expr + checkNameSpaceName(); + break; + case TokenNameconst: + getNextToken(); + expr(); + break; } } - + + /** + * parse and check the namespace name + * @since 1.2.3 + * @param namespaceToken + */ + private void checkNameSpaceName(){ + getNextToken(); + while (true) { + if (token == TokenNameSEMICOLON) { + break; + } + getNextToken(); + } + + } /** * Parse and check the include file name * 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 eeff2c1..5d9f191 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 @@ -1648,6 +1648,8 @@ public class Scanner implements IScanner, ITerminalSymbols { return TokenNameCOLON; case '@': return TokenNameAT; + case '\\': + return TokenNameForwardSlash; case '\'': consumeStringConstant(); return TokenNameStringSingleQuote; @@ -3562,6 +3564,14 @@ public class Scanner implements IScanner, ITerminalSymbols { if ((data[++index] == 'e') && (data[++index] == 'w')) return TokenNamenew; return TokenNameIdentifier; + case 9: + //namespace + if ((data[++index] == 'a') && (data[++index] == 'm') + && (data[++index] == 'e') && (data[++index] == 's') + && (data[++index] == 'p') && (data[++index] == 'a') + && (data[++index] == 'c') && (data[++index] == 'e')) + return TokenNameNamespace; + return TokenNameIdentifier; // case 4 : // if ((data[++index] == 'u') && (data[++index] == 'l') // && (data[++index] == 'l')) @@ -4085,6 +4095,8 @@ public class Scanner implements IScanner, ITerminalSymbols { return "require"; //$NON-NLS-1$ case TokenNamerequire_once: return "require_once"; //$NON-NLS-1$ + case TokenNameNamespace: + return "namespace"; //$NON-NLS-1$ case TokenNamereturn: return "return"; //$NON-NLS-1$ // case TokenNameself: diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/syntax.xml b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/syntax.xml index d8bc290..9f1a1c0 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/syntax.xml +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/syntax.xml @@ -2917,6 +2917,7 @@ +