Putting in quick change to support namespace and const. This change only adds a few...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / parser / Parser.java
index 47d1390..3d33858 100644 (file)
@@ -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();
@@ -2013,7 +2022,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers,
                        throwSyntaxError("'endif' expected.");
                }
                getNextToken();
-               if (token != TokenNameSEMICOLON) {
+               if (token != TokenNameSEMICOLON && token != TokenNameINLINE_HTML) {
                        reportSyntaxError("';' expected after if-statement.");
                        iState.sourceEnd = scanner.getCurrentTokenStartPosition();
                } else {
@@ -2255,7 +2264,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers,
                                throwSyntaxError("'endswitch' expected.");
                        }
                        getNextToken();
-                       if (token != TokenNameSEMICOLON) {
+                       if (token != TokenNameSEMICOLON && token != TokenNameINLINE_HTML) {
                                throwSyntaxError("';' expected after switch-statement.");
                        }
                        getNextToken();
@@ -2283,7 +2292,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers,
                                throwSyntaxError("'endfor' expected.");
                        }
                        getNextToken();
-                       if (token != TokenNameSEMICOLON) {
+                       if (token != TokenNameSEMICOLON && token != TokenNameINLINE_HTML) {
                                throwSyntaxError("';' expected after for-statement.");
                        }
                        getNextToken();
@@ -2301,7 +2310,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers,
                                throwSyntaxError("'endwhile' expected.");
                        }
                        getNextToken();
-                       if (token != TokenNameSEMICOLON) {
+                       if (token != TokenNameSEMICOLON && token != TokenNameINLINE_HTML) {
                                throwSyntaxError("';' expected after while-statement.");
                        }
                        getNextToken();
@@ -2318,7 +2327,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers,
                                throwSyntaxError("'endforeach' expected.");
                        }
                        getNextToken();
-                       if (token != TokenNameSEMICOLON) {
+                       if (token != TokenNameSEMICOLON && token != TokenNameINLINE_HTML) {
                                throwSyntaxError("';' expected after foreach-statement.");
                        }
                        getNextToken();
@@ -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
         * 
@@ -4170,7 +4204,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers,
                                        if (path == null) {
                                                // SyntaxError: "File: << >> doesn't exist in project."
                                                String[] args = { expression.toStringExpression(),
-                                                               project.getLocation().toString() };
+                                                               project.getFullPath().toString() };
                                                problemReporter.phpIncludeNotExistWarning(args,
                                                                literal.sourceStart, literal.sourceEnd,
                                                                referenceContext,
@@ -4993,11 +5027,12 @@ public class Parser implements ITerminalSymbols, CompilerModifiers,
                // create a package name similar to java package names
                String projectPath = ProjectPrefUtil.getDocumentRoot(file.getProject())
                                .toString();
-               String filePath = file.getRawLocation().toString();
-               String ext = file.getRawLocation().getFileExtension();
-               int fileExtensionLength = ext == null ? 0 : ext.length() + 1;
-               ImportReference impt;
-               char[][] tokens;
+                String filePath = file.getFullPath().toString();
+                
+                String ext = file.getFileExtension();
+                int fileExtensionLength = ext == null ? 0 : ext.length() + 1;
+                ImportReference impt;
+                char[][] tokens;
                if (filePath.startsWith(projectPath)) {
                        tokens = CharOperation.splitOn('/', filePath.toCharArray(),
                                        projectPath.length() + 1, filePath.length()