Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Camelon2003-06-12 15:59:26 +0000
committerJohn Camelon2003-06-12 15:59:26 +0000
commit3d373aa26c0df41a99f52e968ccfc58550b5981f (patch)
tree60642ea6b38fc45cbb7df3d12df269a766bf8cac
parent533e159dd6a3681c4e44ecaa51999ed3687aabca (diff)
downloadorg.eclipse.cdt-3d373aa26c0df41a99f52e968ccfc58550b5981f.tar.gz
org.eclipse.cdt-3d373aa26c0df41a99f52e968ccfc58550b5981f.tar.xz
org.eclipse.cdt-3d373aa26c0df41a99f52e968ccfc58550b5981f.zip
ASTFactory updates.
-rw-r--r--core/org.eclipse.cdt.core/parser/ChangeLog3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java115
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ParserFactory.java30
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Token.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/BaseASTFactory.java21
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTFactory.java42
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTASMDefinition.java (renamed from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/ASTASMDefinition.java)2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTClassSpecifier.java (renamed from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/ASTClassSpecifier.java)2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTCompilationUnit.java (renamed from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/ASTCompilationUnit.java)2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTLinkageSpecification.java (renamed from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/ASTLinkageSpecification.java)2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTNamespaceDefinition.java (renamed from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/ASTNamespaceDefinition.java)2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/BaseIterator.java (renamed from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/BaseIterator.java)3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java133
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTASMDefinition.java (renamed from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTASMDefinition.java)3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTClassSpecifier.java (renamed from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTClassSpecifier.java)2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTCompilationUnit.java (renamed from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTCompilationUnit.java)3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTLinkageSpecification.java (renamed from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTLinkageSpecification.java)2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTNamespaceDefinition.java (renamed from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTNamespaceDefinition.java)2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTScope.java (renamed from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTScope.java)2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IPSTContainerExtension.java (renamed from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IPSTContainerExtension.java)2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IPSTSymbolExtension.java (renamed from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IPSTSymbolExtension.java)2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ScopeIterator.java (renamed from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/ScopeIterator.java)2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java70
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ISymbol.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java2
-rw-r--r--core/org.eclipse.cdt.ui.tests/ChangeLog3
-rw-r--r--core/org.eclipse.cdt.ui.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java4
27 files changed, 350 insertions, 110 deletions
diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog b/core/org.eclipse.cdt.core/parser/ChangeLog
index f9a4cc74db2..c4c0e1ac11e 100644
--- a/core/org.eclipse.cdt.core/parser/ChangeLog
+++ b/core/org.eclipse.cdt.core/parser/ChangeLog
@@ -1,3 +1,6 @@
+2003-06-12 John Camelon
+ Introduction of ASTFactory strategy, some restructuring of packages and interfaces.
+
2003-06-10 John Camelon
Futher pursuit of the golden hammer, symbol table integration.
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java
index d0a29f26a42..0813f0e6854 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java
@@ -14,25 +14,17 @@ package org.eclipse.cdt.internal.core.parser;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringReader;
-import java.util.Iterator;
import org.eclipse.cdt.core.parser.IParser;
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
import org.eclipse.cdt.internal.core.model.Util;
-import org.eclipse.cdt.internal.core.parser.ast.ASTASMDefinition;
-import org.eclipse.cdt.internal.core.parser.ast.ASTCompilationUnit;
-import org.eclipse.cdt.internal.core.parser.ast.ASTLinkageSpecification;
-import org.eclipse.cdt.internal.core.parser.ast.ASTNamespaceDefinition;
-import org.eclipse.cdt.internal.core.parser.ast.IASTASMDefinition;
-import org.eclipse.cdt.internal.core.parser.ast.IASTCompilationUnit;
-import org.eclipse.cdt.internal.core.parser.ast.IASTLinkageSpecification;
-import org.eclipse.cdt.internal.core.parser.ast.IASTNamespaceDefinition;
-import org.eclipse.cdt.internal.core.parser.ast.IASTScope;
-import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
-import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
-import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
-import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTableException;
+import org.eclipse.cdt.internal.core.parser.ast.IASTFactory;
+import org.eclipse.cdt.internal.core.parser.ast.full.IASTASMDefinition;
+import org.eclipse.cdt.internal.core.parser.ast.full.IASTCompilationUnit;
+import org.eclipse.cdt.internal.core.parser.ast.full.IASTLinkageSpecification;
+import org.eclipse.cdt.internal.core.parser.ast.full.IASTNamespaceDefinition;
+import org.eclipse.cdt.internal.core.parser.ast.full.IASTScope;
/**
* This is our first implementation of the IParser interface, serving as a parser for
@@ -50,8 +42,8 @@ public class Parser implements IParser {
private boolean quickParse = false; // are we doing the high-level parse, or an in depth parse?
private boolean parsePassed = true; // did the parse pass?
private boolean cppNature = true; // true for C++, false for C
- private ISourceElementRequestor requestor = null; // new callback mechanism
- private ParserSymbolTable pst = new ParserSymbolTable(); // symbol table
+ private ISourceElementRequestor requestor = null; // new callback mechanism
+ private IASTFactory astFactory = ParserFactory.createASTFactory( false );
/**
* This is the single entry point for setting parsePassed to
@@ -81,6 +73,7 @@ public class Parser implements IParser {
if( c instanceof ISourceElementRequestor )
setRequestor( (ISourceElementRequestor)c );
quickParse = quick;
+ astFactory = ParserFactory.createASTFactory( quick );
scanner.setQuickScan(quick);
scanner.setCallback(c);
}
@@ -182,7 +175,7 @@ c, quickParse);
Object translationUnit = null;
try{ translationUnit = callback.translationUnitBegin();} catch( Exception e ) {}
- IASTCompilationUnit compilationUnit = new ASTCompilationUnit( pst.getCompilationUnit() );
+ IASTCompilationUnit compilationUnit = astFactory.createCompilationUnit();
requestor.enterCompilationUnit( compilationUnit );
Token lastBacktrack = null;
@@ -223,6 +216,9 @@ c, quickParse);
requestor.exitCompilationUnit( compilationUnit );
}
+
+
+
/**
* This function is called whenever we encounter and error that we cannot backtrack out of and we
* still wish to try and continue on with the parse to do a best-effort parse for our client.
@@ -291,45 +287,7 @@ c, quickParse);
consume( Token.tSEMI );
try{ callback.usingDirectiveEnd( directive );} catch( Exception e ) {}
- Iterator iter = duple.iterator();
- Token t1 = (Token)iter.next();
- IContainerSymbol symbol = null;
-
- if( t1.getType() == Token.tCOLONCOLON )
- symbol = pst.getCompilationUnit();
- else
- {
- try
- {
- symbol = (IContainerSymbol)scope.getContainerSymbol().Lookup( t1.getImage() );
- }
- catch( ParserSymbolTableException pste )
- {
- handlePSTException( pste );
- }
- }
-
- while( iter.hasNext() )
- {
- Token t = (Token)iter.next();
- if( t.getType() == Token.tCOLONCOLON ) continue;
- try
- {
- symbol = symbol.LookupNestedNameSpecifier( t.getImage() );
- }
- catch( ParserSymbolTableException pste )
- {
- handlePSTException( pste );
- }
- }
-
- try {
- scope.getContainerSymbol().addUsingDirective( symbol );
- } catch (ParserSymbolTableException pste) {
- handlePSTException( pste );
- }
-
- IASTUsingDirective astUD = new ASTUsingDirective( duple.toString() );
+ IASTUsingDirective astUD = astFactory.createUsingDirective(scope, duple);
requestor.acceptUsingDirective( astUD );
return;
}
@@ -375,13 +333,6 @@ c, quickParse);
}
}
}
-
- /**
- * @param pste
- */
- private void handlePSTException(ParserSymbolTableException pste) throws Backtrack {
- throw backtrack;
- }
/**
@@ -409,8 +360,7 @@ c, quickParse);
{
consume(Token.tLBRACE);
- IContainerSymbol symbol = pst.newContainerSymbol("", ParserSymbolTable.TypeInfo.t_linkage );
- IASTLinkageSpecification linkage = new ASTLinkageSpecification( symbol, spec.getImage() );
+ IASTLinkageSpecification linkage = astFactory.createLinkageSpecification(spec.getImage());
requestor.enterLinkageSpecification( linkage );
@@ -444,8 +394,7 @@ c, quickParse);
else // single declaration
{
- IContainerSymbol symbol = pst.newContainerSymbol("", ParserSymbolTable.TypeInfo.t_linkage );
- IASTLinkageSpecification linkage = new ASTLinkageSpecification( symbol, spec.getImage() );
+ IASTLinkageSpecification linkage = astFactory.createLinkageSpecification( spec.getImage() );
requestor.enterLinkageSpecification( linkage );
@@ -454,6 +403,7 @@ c, quickParse);
requestor.exitLinkageSpecification( linkage );
}
}
+
/**
*
@@ -653,20 +603,8 @@ c, quickParse);
consume( Token.tRPAREN );
Token last = consume( Token.tSEMI );
- IContainerSymbol containerSymbol = (IContainerSymbol)scope.getSymbol();
-
- ISymbol asmSymbol = pst.newSymbol( "", ParserSymbolTable.TypeInfo.t_asm );
- IASTASMDefinition asmDefinition = new ASTASMDefinition( asmSymbol, assembly );
- asmSymbol.setASTNode( asmDefinition );
-
- try {
- containerSymbol.addSymbol(asmSymbol);
- } catch (ParserSymbolTableException e1) {
- //?
- }
-
- asmDefinition.setStartingOffset( first.getOffset() );
- asmDefinition.setEndingOffset( last.getOffset() + 1 );
+ IASTASMDefinition asmDefinition =
+ astFactory.createASMDefinition(scope, assembly, first.getOffset(), last.getEndOffset());
// if we made it this far, then we have all we need
// do the callback
@@ -734,14 +672,9 @@ c, quickParse);
{
consume();
- IContainerSymbol namespaceSymbol = null;
-
- String name = identifier == null ? "" : identifier.getImage();
- pst.newContainerSymbol( name, ParserSymbolTable.TypeInfo.t_namespace );
- IASTNamespaceDefinition namespaceDefinition = new ASTNamespaceDefinition( namespaceSymbol, name );
- namespaceDefinition.setStartingOffset( first.getOffset() );
- if( identifier != null )
- namespaceDefinition.setNameOffset( identifier.getOffset() );
+ IASTNamespaceDefinition namespaceDefinition =
+ astFactory.createNamespaceDefinition(first.getOffset(), identifier.getImage(),
+ ( identifier == null ? 0 : identifier.getOffset()) );
requestor.enterNamespaceDefinition( namespaceDefinition );
@@ -781,9 +714,9 @@ c, quickParse);
throw backtrack;
}
}
-
-
+
+
/**
* Serves as the catch-all for all complicated declarations, including function-definitions.
*
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ParserFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ParserFactory.java
new file mode 100644
index 00000000000..2ecfd6b075b
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ParserFactory.java
@@ -0,0 +1,30 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser;
+
+import org.eclipse.cdt.internal.core.parser.ast.IASTFactory;
+import org.eclipse.cdt.internal.core.parser.ast.full.FullParseASTFactory;
+import org.eclipse.cdt.internal.core.parser.ast.quick.QuickParseASTFactory;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ParserFactory {
+
+ public static IASTFactory createASTFactory( boolean quickParse )
+ {
+ if( quickParse )
+ return new QuickParseASTFactory();
+ else
+ return new FullParseASTFactory();
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Token.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Token.java
index ee3fd3bbc70..38d93c32eb6 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Token.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Token.java
@@ -43,6 +43,8 @@ public class Token {
public int offset;
public int getOffset() { return offset; }
public int getLength() { return image.length(); }
+ public int getEndOffset() { return getOffset() + getLength(); }
+
public int getDelta( Token other )
{
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/BaseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/BaseASTFactory.java
new file mode 100644
index 00000000000..4fc1dd3420e
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/BaseASTFactory.java
@@ -0,0 +1,21 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast;
+
+
+/**
+ * @author jcamelon
+ *
+ */
+public class BaseASTFactory {
+
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTFactory.java
new file mode 100644
index 00000000000..ba1600e6158
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTFactory.java
@@ -0,0 +1,42 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast;
+
+import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
+import org.eclipse.cdt.internal.core.parser.TokenDuple;
+import org.eclipse.cdt.internal.core.parser.Parser.Backtrack;
+import org.eclipse.cdt.internal.core.parser.ast.full.IASTASMDefinition;
+import org.eclipse.cdt.internal.core.parser.ast.full.IASTCompilationUnit;
+import org.eclipse.cdt.internal.core.parser.ast.full.IASTLinkageSpecification;
+import org.eclipse.cdt.internal.core.parser.ast.full.IASTNamespaceDefinition;
+import org.eclipse.cdt.internal.core.parser.ast.full.IASTScope;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTFactory {
+ public abstract IASTUsingDirective createUsingDirective(
+ IASTScope scope,
+ TokenDuple duple)
+ throws Backtrack;
+ public abstract IASTASMDefinition createASMDefinition(
+ IASTScope scope,
+ String assembly,
+ int first,
+ int last);
+ public abstract IASTNamespaceDefinition createNamespaceDefinition(
+ int first,
+ String identifier,
+ int nameOffset);
+ public abstract IASTCompilationUnit createCompilationUnit();
+ public abstract IASTLinkageSpecification createLinkageSpecification(String spec);
+} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/ASTASMDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTASMDefinition.java
index 789d5f00a10..6ef1c9020b1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/ASTASMDefinition.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTASMDefinition.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
-package org.eclipse.cdt.internal.core.parser.ast;
+package org.eclipse.cdt.internal.core.parser.ast.full;
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/ASTClassSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTClassSpecifier.java
index 69e16c21bf7..32ebf53e03f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/ASTClassSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTClassSpecifier.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
-package org.eclipse.cdt.internal.core.parser.ast;
+package org.eclipse.cdt.internal.core.parser.ast.full;
import java.util.Iterator;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/ASTCompilationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTCompilationUnit.java
index 7f9e73f2e06..a2750c38a35 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/ASTCompilationUnit.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTCompilationUnit.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
-package org.eclipse.cdt.internal.core.parser.ast;
+package org.eclipse.cdt.internal.core.parser.ast.full;
import java.util.Iterator;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/ASTLinkageSpecification.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTLinkageSpecification.java
index 45a935139e5..5ba5c4549f2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/ASTLinkageSpecification.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTLinkageSpecification.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
-package org.eclipse.cdt.internal.core.parser.ast;
+package org.eclipse.cdt.internal.core.parser.ast.full;
import java.util.Iterator;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/ASTNamespaceDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTNamespaceDefinition.java
index 831cc62c618..df5ccb91722 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/ASTNamespaceDefinition.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTNamespaceDefinition.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
-package org.eclipse.cdt.internal.core.parser.ast;
+package org.eclipse.cdt.internal.core.parser.ast.full;
import java.util.Iterator;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/BaseIterator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/BaseIterator.java
index 04421ac042f..ccc278b65e1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/BaseIterator.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/BaseIterator.java
@@ -8,11 +8,12 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
-package org.eclipse.cdt.internal.core.parser.ast;
+package org.eclipse.cdt.internal.core.parser.ast.full;
import java.util.Iterator;
import java.util.List;
+import org.eclipse.cdt.internal.core.parser.ast.ASTBaseSpecifier;
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
/**
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java
new file mode 100644
index 00000000000..1d54bbc781b
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java
@@ -0,0 +1,133 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.full;
+
+import java.util.Iterator;
+
+import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
+import org.eclipse.cdt.internal.core.parser.ASTUsingDirective;
+import org.eclipse.cdt.internal.core.parser.Token;
+import org.eclipse.cdt.internal.core.parser.TokenDuple;
+import org.eclipse.cdt.internal.core.parser.Parser.Backtrack;
+import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
+import org.eclipse.cdt.internal.core.parser.ast.IASTFactory;
+import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
+import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
+import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
+import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTableException;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class FullParseASTFactory extends BaseASTFactory implements IASTFactory {
+
+ private ParserSymbolTable pst = new ParserSymbolTable(); // symbol table
+
+ public IASTUsingDirective createUsingDirective(
+ IASTScope scope,
+ TokenDuple duple)
+ throws Backtrack {
+ Iterator iter = duple.iterator();
+ Token t1 = (Token)iter.next();
+ IContainerSymbol symbol = null;
+
+ if( t1.getType() == Token.tCOLONCOLON )
+ symbol = pst.getCompilationUnit();
+ else
+ {
+ try
+ {
+ symbol = (IContainerSymbol)scope.getContainerSymbol().Lookup( t1.getImage() );
+ }
+ catch( ParserSymbolTableException pste )
+ {
+ handlePSTException( pste );
+ }
+ }
+
+ while( iter.hasNext() )
+ {
+ Token t = (Token)iter.next();
+ if( t.getType() == Token.tCOLONCOLON ) continue;
+ try
+ {
+ symbol = symbol.LookupNestedNameSpecifier( t.getImage() );
+ }
+ catch( ParserSymbolTableException pste )
+ {
+ handlePSTException( pste );
+ }
+ }
+
+ try {
+ scope.getContainerSymbol().addUsingDirective( symbol );
+ } catch (ParserSymbolTableException pste) {
+ handlePSTException( pste );
+ }
+
+ IASTUsingDirective astUD = new ASTUsingDirective( duple.toString() );
+ return astUD;
+ }
+
+ public IASTASMDefinition createASMDefinition(
+ IASTScope scope,
+ String assembly,
+ int first,
+ int last) {
+ IContainerSymbol containerSymbol = (IContainerSymbol)scope.getSymbol();
+ ISymbol asmSymbol = pst.newSymbol( "", ParserSymbolTable.TypeInfo.t_asm );
+ IASTASMDefinition asmDefinition = new ASTASMDefinition( asmSymbol, assembly );
+ asmSymbol.setASTNode( asmDefinition );
+
+ try {
+ containerSymbol.addSymbol(asmSymbol);
+ } catch (ParserSymbolTableException e1) {
+ //?
+ }
+
+ asmDefinition.setStartingOffset( first );
+ asmDefinition.setEndingOffset( last );
+ return asmDefinition;
+ }
+
+ public IASTNamespaceDefinition createNamespaceDefinition(
+ int first,
+ String identifier,
+ int nameOffset ) {
+ IContainerSymbol namespaceSymbol = null;
+
+ pst.newContainerSymbol( identifier, ParserSymbolTable.TypeInfo.t_namespace );
+ IASTNamespaceDefinition namespaceDefinition = new ASTNamespaceDefinition( namespaceSymbol, identifier );
+ namespaceDefinition.setStartingOffset( first );
+ if( identifier != "" )
+ namespaceDefinition.setNameOffset( nameOffset );
+ return namespaceDefinition;
+ }
+
+ public IASTCompilationUnit createCompilationUnit() {
+ IASTCompilationUnit compilationUnit = new ASTCompilationUnit( pst.getCompilationUnit() );
+ return compilationUnit;
+ }
+
+ public IASTLinkageSpecification createLinkageSpecification(String spec) {
+ IContainerSymbol symbol = pst.newContainerSymbol("", ParserSymbolTable.TypeInfo.t_linkage );
+ IASTLinkageSpecification linkage = new ASTLinkageSpecification( symbol, spec);
+ return linkage;
+ }
+
+ /**
+ * @param pste
+ */
+ private void handlePSTException(ParserSymbolTableException pste) throws Backtrack {
+ throw new Backtrack();
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTASMDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTASMDefinition.java
index b9bb216b6f5..a81074dd0f4 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTASMDefinition.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTASMDefinition.java
@@ -8,7 +8,8 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
-package org.eclipse.cdt.internal.core.parser.ast;
+package org.eclipse.cdt.internal.core.parser.ast.full;
+
/**
* @author jcamelon
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTClassSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTClassSpecifier.java
index e380a7f70ff..71bfe6629d1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTClassSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTClassSpecifier.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
-package org.eclipse.cdt.internal.core.parser.ast;
+package org.eclipse.cdt.internal.core.parser.ast.full;
import org.eclipse.cdt.core.parser.ast.IASTScope;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTCompilationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTCompilationUnit.java
index 04a8771e5a9..24270372d6c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTCompilationUnit.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTCompilationUnit.java
@@ -8,7 +8,8 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
-package org.eclipse.cdt.internal.core.parser.ast;
+package org.eclipse.cdt.internal.core.parser.ast.full;
+
/**
* @author jcamelon
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTLinkageSpecification.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTLinkageSpecification.java
index eb74ce896fe..cbf6f88e88b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTLinkageSpecification.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTLinkageSpecification.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
-package org.eclipse.cdt.internal.core.parser.ast;
+package org.eclipse.cdt.internal.core.parser.ast.full;
/**
* @author jcamelon
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTNamespaceDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTNamespaceDefinition.java
index c10af41133e..f5cca31a822 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTNamespaceDefinition.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTNamespaceDefinition.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
-package org.eclipse.cdt.internal.core.parser.ast;
+package org.eclipse.cdt.internal.core.parser.ast.full;
/**
* @author jcamelon
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTScope.java
index 3a61ddd0e8f..3435aabc039 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IASTScope.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTScope.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
-package org.eclipse.cdt.internal.core.parser.ast;
+package org.eclipse.cdt.internal.core.parser.ast.full;
/**
* @author jcamelon
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IPSTContainerExtension.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IPSTContainerExtension.java
index 00f80f00130..446eb013ab7 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IPSTContainerExtension.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IPSTContainerExtension.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
-package org.eclipse.cdt.internal.core.parser.ast;
+package org.eclipse.cdt.internal.core.parser.ast.full;
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IPSTSymbolExtension.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IPSTSymbolExtension.java
index ad2ade7a8c8..f5a9a376202 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/IPSTSymbolExtension.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IPSTSymbolExtension.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
-package org.eclipse.cdt.internal.core.parser.ast;
+package org.eclipse.cdt.internal.core.parser.ast.full;
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/ScopeIterator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ScopeIterator.java
index a055f34b4d4..8ba4babb69d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/ScopeIterator.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ScopeIterator.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
-package org.eclipse.cdt.internal.core.parser.ast;
+package org.eclipse.cdt.internal.core.parser.ast.full;
import java.util.Iterator;
import java.util.Map;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java
new file mode 100644
index 00000000000..b1d222e75f5
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java
@@ -0,0 +1,70 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.quick;
+
+import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
+import org.eclipse.cdt.internal.core.parser.TokenDuple;
+import org.eclipse.cdt.internal.core.parser.Parser.Backtrack;
+import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
+import org.eclipse.cdt.internal.core.parser.ast.IASTFactory;
+import org.eclipse.cdt.internal.core.parser.ast.full.IASTASMDefinition;
+import org.eclipse.cdt.internal.core.parser.ast.full.IASTCompilationUnit;
+import org.eclipse.cdt.internal.core.parser.ast.full.IASTLinkageSpecification;
+import org.eclipse.cdt.internal.core.parser.ast.full.IASTNamespaceDefinition;
+import org.eclipse.cdt.internal.core.parser.ast.full.IASTScope;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.IASTFactory#createUsingDirective(org.eclipse.cdt.internal.core.parser.ast.IASTScope, org.eclipse.cdt.internal.core.parser.TokenDuple)
+ */
+ public IASTUsingDirective createUsingDirective(IASTScope scope, TokenDuple duple) throws Backtrack {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.IASTFactory#createASMDefinition(org.eclipse.cdt.internal.core.parser.ast.IASTScope, java.lang.String, int, int)
+ */
+ public IASTASMDefinition createASMDefinition(IASTScope scope, String assembly, int first, int last) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.IASTFactory#createNamespaceDefinition(int, java.lang.String, int)
+ */
+ public IASTNamespaceDefinition createNamespaceDefinition(int first, String identifier, int nameOffset) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.IASTFactory#createCompilationUnit()
+ */
+ public IASTCompilationUnit createCompilationUnit() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.IASTFactory#createLinkageSpecification(java.lang.String)
+ */
+ public IASTLinkageSpecification createLinkageSpecification(String spec) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ISymbol.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ISymbol.java
index 5fe54b39902..8ed22b9d929 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ISymbol.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ISymbol.java
@@ -13,7 +13,7 @@ package org.eclipse.cdt.internal.core.parser.pst;
import java.util.HashMap;
import java.util.LinkedList;
-import org.eclipse.cdt.internal.core.parser.ast.IPSTSymbolExtension;
+import org.eclipse.cdt.internal.core.parser.ast.full.IPSTSymbolExtension;
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TemplateInstance;
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TypeInfo;
/**
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java
index 85a78a81bb7..e20953044f7 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java
@@ -23,7 +23,7 @@ import java.util.Map;
import java.util.Set;
import org.eclipse.cdt.core.parser.ast.AccessVisibility;
-import org.eclipse.cdt.internal.core.parser.ast.IPSTSymbolExtension;
+import org.eclipse.cdt.internal.core.parser.ast.full.IPSTSymbolExtension;
/**
* @author aniefer
diff --git a/core/org.eclipse.cdt.ui.tests/ChangeLog b/core/org.eclipse.cdt.ui.tests/ChangeLog
index b65bf74826a..5fec003558b 100644
--- a/core/org.eclipse.cdt.ui.tests/ChangeLog
+++ b/core/org.eclipse.cdt.ui.tests/ChangeLog
@@ -1,3 +1,6 @@
+2003-06-12 John Camelon
+ Introduction of ASTFactory strategy, some restructuring of packages and interfaces.
+
2003-06-10 John Camelon
Futher pursuit of the golden hammer, symbol table integration.
diff --git a/core/org.eclipse.cdt.ui.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java b/core/org.eclipse.cdt.ui.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java
index dab0473b3f2..c192ff814ba 100644
--- a/core/org.eclipse.cdt.ui.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java
+++ b/core/org.eclipse.cdt.ui.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java
@@ -18,8 +18,8 @@ import java.util.Map;
import junit.framework.TestCase;
import org.eclipse.cdt.core.parser.ast.AccessVisibility;
-import org.eclipse.cdt.internal.core.parser.ast.ASTCompilationUnit;
-import org.eclipse.cdt.internal.core.parser.ast.IASTCompilationUnit;
+import org.eclipse.cdt.internal.core.parser.ast.full.ASTCompilationUnit;
+import org.eclipse.cdt.internal.core.parser.ast.full.IASTCompilationUnit;
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
import org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol;
import org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol;

Back to the top