1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Patch for John Camelon:

- see ChangeLogs
This commit is contained in:
Doug Schaefer 2003-03-12 15:35:41 +00:00
parent 539ff21074
commit ef11178134
8 changed files with 114 additions and 34 deletions

View file

@ -4,7 +4,7 @@ package org.eclipse.cdt.internal.core.dom;
import org.eclipse.cdt.core.dom.IScope;
import org.eclipse.cdt.internal.core.parser.IParserCallback;
import org.eclipse.cdt.internal.core.parser.Token;
import org.eclipse.cdt.internal.core.parser.util.*;
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
import org.eclipse.cdt.internal.core.parser.util.Name;
/**
@ -76,7 +76,7 @@ public class DOMBuilder implements IParserCallback
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#declaratorBegin()
*/
public Object declaratorBegin(Object container) {
DeclarationSpecifier.Container decl = (DeclarationSpecifier.Container )container;
DeclSpecifier.Container decl = (DeclSpecifier.Container )container;
Declarator declarator = new Declarator(decl);
decl.addDeclarator(declarator);
return declarator;
@ -99,17 +99,19 @@ public class DOMBuilder implements IParserCallback
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#declSpecifier(org.eclipse.cdt.internal.core.newparser.Token)
*/
public void simpleDeclSpecifier(Object Container, Token specifier) {
DeclarationSpecifier.Container decl = (DeclarationSpecifier.Container)Container;
DeclarationSpecifier declSpec = decl.getDeclSpecifier();
DeclSpecifier.Container decl = (DeclSpecifier.Container)Container;
DeclSpecifier declSpec = decl.getDeclSpecifier();
if( declSpec == null )
{
declSpec = new DeclarationSpecifier();
declSpec = new DeclSpecifier();
decl.setDeclSpecifier( declSpec );
}
declSpec.setType( specifier );
}
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#expressionOperator(org.eclipse.cdt.internal.core.newparser.Token)
*/
@ -256,11 +258,23 @@ public class DOMBuilder implements IParserCallback
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#declaratorAbort(java.lang.Object, java.lang.Object)
*/
public void declaratorAbort(Object container, Object declarator) {
DeclarationSpecifier.Container decl = (DeclarationSpecifier.Container )container;
DeclSpecifier.Container decl = (DeclSpecifier.Container )container;
Declarator toBeRemoved = (Declarator)declarator;
decl.removeDeclarator( toBeRemoved );
currName = null;
toBeRemoved = null;
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#expressionBegin(java.lang.Object)
*/
public Object expressionBegin(Object container) {
return null;
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#expressionEnd(java.lang.Object)
*/
public void expressionEnd(Object expression) {
}
}

View file

@ -1,22 +1,22 @@
package org.eclipse.cdt.internal.core.dom;
import org.eclipse.cdt.internal.core.parser.util.*;
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
import org.eclipse.cdt.internal.core.parser.util.Name;
public class Declarator {
public Declarator(DeclarationSpecifier.Container declaration) {
public Declarator(DeclSpecifier.Container declaration) {
this.declaration = declaration;
}
private DeclarationSpecifier.Container declaration;
private DeclSpecifier.Container declaration;
/**
* Returns the declaration.
* @return SimpleDeclaration
*/
public DeclarationSpecifier.Container getDeclaration() {
public DeclSpecifier.Container getDeclaration() {
return declaration;
}

View file

@ -3,7 +3,8 @@ package org.eclipse.cdt.internal.core.dom;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.cdt.internal.core.parser.util.*;
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
/**
* @author jcamelon
@ -13,16 +14,16 @@ import org.eclipse.cdt.internal.core.parser.util.*;
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
public class ParameterDeclaration extends Declaration implements DeclarationSpecifier.Container {
public class ParameterDeclaration extends Declaration implements DeclSpecifier.Container {
DeclarationSpecifier declSpec = null;
DeclSpecifier declSpec = null;
/**
* @see org.eclipse.cdt.internal.core.dom.DeclarationSpecifier.CElementWrapper#getDeclSpecifier()
*/
public DeclarationSpecifier getDeclSpecifier() {
public DeclSpecifier getDeclSpecifier() {
if( declSpec == null )
declSpec = new DeclarationSpecifier();
declSpec = new DeclSpecifier();
return declSpec;
}
@ -30,7 +31,7 @@ public class ParameterDeclaration extends Declaration implements DeclarationSpec
/**
* @see org.eclipse.cdt.internal.core.dom.DeclarationSpecifier.CElementWrapper#setDeclSpecifier(org.eclipse.cdt.internal.core.dom.DeclarationSpecifier)
*/
public void setDeclSpecifier(DeclarationSpecifier in) {
public void setDeclSpecifier(DeclSpecifier in) {
declSpec = in;
}
private List declarators = new LinkedList();

View file

@ -3,20 +3,20 @@ package org.eclipse.cdt.internal.core.dom;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.cdt.internal.core.parser.util.*;
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
public class SimpleDeclaration extends Declaration implements DeclarationSpecifier.Container{
public class SimpleDeclaration extends Declaration implements DeclSpecifier.Container {
private DeclarationSpecifier declSpec = null;
private DeclSpecifier declSpec = null;
public DeclarationSpecifier getDeclSpecifier()
public DeclSpecifier getDeclSpecifier()
{
if( declSpec == null )
declSpec = new DeclarationSpecifier();
declSpec = new DeclSpecifier();
return declSpec;
}
public void setDeclSpecifier( DeclarationSpecifier in )
public void setDeclSpecifier( DeclSpecifier in )
{
declSpec = in;
}
@ -40,7 +40,7 @@ public class SimpleDeclaration extends Declaration implements DeclarationSpecifi
* @param typeSpecifier The typeSpecifier to set
*/
public void setTypeSpecifier(TypeSpecifier typeSpecifier) {
getDeclSpecifier().setType(DeclarationSpecifier.t_type);
getDeclSpecifier().setType(DeclSpecifier.t_type);
this.typeSpecifier = typeSpecifier;
}

View file

@ -0,0 +1,48 @@
2003-03-11 John Camelon
added ChangeLog to parser directory
updated IParserCallback (and all implementors) for expressions
removed inheritance relationship between ExpressionEvaluator and NullParserCallback
removed redundant assignmentOperator() calls in Parser::initDeclarator
removed class util.DeclarationSpecifier, merged Container interface into util.DeclSpecifier
organized imports on the parser folder
* dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java
* dom/org/eclipse/cdt/internal/core/dom/Declarator.java
* dom/org/eclipse/cdt/internal/core/dom/ParameterDeclaration.java
* dom/org/eclipse/cdt/internal/core/dom/SimpleDeclaration.java
* parser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java
* parser/org/eclipse/cdt/internal/core/model/Parameter.java
* parser/org/eclipse/cdt/internal/core/model/SimpleDeclarationWrapper.java
* parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java
* parser/org/eclipse/cdt/internal/core/parser/IParserCallback.java
* parser/org/eclipse/cdt/internal/core/parser/NullParserCallback.java
* parser/org/eclipse/cdt/internal/core/parser/Parser.java
* parser/org/eclipse/cdt/internal/core/parser/util/DeclSpecifier.java
2003-03-10 John Camelon
added in support for detecting and reporting circular inclusions
added optimization by caching inclusion directories
added macro pasting capabilities
updated inclusion searching algorithm for local inclusions
2003-03-07 John Camelon
fixed initDeclarators for the outline view.
2003-03-06 Doug Schaefer
Some minor fixes to get constructors/destructors parsing as well as some minor clean up and robustness.
2003-03-06 John Camelon
added quickParse heuristic to Scanner for handling #if conditionals to avoid throwing
ScannerExceptions on undefined preprocessor symbols
added minimal enum support to Parser (though not to DOM or CModel)
2003-03-06 Andrew Niefer
Implementation of Namespaces & using directives in new parser's symbol table
2003-03-05 Doug Schaefer
Some minor fixes to the parser.
2003-03-04 Doug Schaefer
Added Parser in the "parser" source folder in cdt.core
Preference in the C/C++ preference page to enable/disable use of the new parser (disabled by default)
Start on the DOM which we are using to test the parser (source folder "dom")
Start on a new Model Builder for creating CElements using the new parser (currently in source folder "parser")

View file

@ -1,3 +1,19 @@
2003-03-11 John Camelon
Updated DOMTests for core.internal.parser change of merging DeclarationSpecifier and DeclSpecifier
Organized imports
* parser/org/eclipse/cdt/core/parser/tests/DOMTests.java
* parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java
2003-03-10 John Camelon
Added macro pasting tests
2003-03-06 Andrew Niefer
Added tests for exercising Namespaces & using directives in new parser's symbol table
2003-03-04 Doug Schaefer
This is a pretty big patch, but it is the merge of the NewParser1 branch into the HEAD branch. lder "parser")
JUnit tests for testing various pieces (source folder "parser" in cdt.ui.tests.
2003-01-29 Peter Graves
Fixed the warnings when accessing static methods

View file

@ -17,7 +17,7 @@ import org.eclipse.cdt.internal.core.dom.SimpleDeclaration;
import org.eclipse.cdt.internal.core.dom.TranslationUnit;
import org.eclipse.cdt.internal.core.parser.Parser;
import org.eclipse.cdt.internal.core.parser.ParserException;
import org.eclipse.cdt.internal.core.parser.util.DeclarationSpecifier;
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
import org.eclipse.cdt.internal.core.parser.util.Name;
/**
@ -52,7 +52,7 @@ public class DOMTests extends TestCase {
SimpleDeclaration declaration = (SimpleDeclaration)declarations.get(0);
// Make sure it is only an int
assertEquals(DeclarationSpecifier.t_int, declaration.getDeclSpecifier().getDeclSpecifierSeq());
assertEquals(DeclSpecifier.t_int, declaration.getDeclSpecifier().getDeclSpecifierSeq());
// Get the declarator and check its name
List declarators = declaration.getDeclarators();
@ -125,7 +125,7 @@ public class DOMTests extends TestCase {
declaration = (SimpleDeclaration)declarations.get(0);
// Make sure it's an int
assertEquals(DeclarationSpecifier.t_int, declaration.getDeclSpecifier().getDeclSpecifierSeq());
assertEquals(DeclSpecifier.t_int, declaration.getDeclSpecifier().getDeclSpecifierSeq());
// Get the declarator and check it's name
List declarators = declaration.getDeclarators();
@ -184,7 +184,7 @@ public class DOMTests extends TestCase {
declaration = (SimpleDeclaration)declarations.get(0);
// Make sure it's an int
assertEquals(DeclarationSpecifier.t_int, declaration.getDeclSpecifier().getDeclSpecifierSeq());
assertEquals(DeclSpecifier.t_int, declaration.getDeclSpecifier().getDeclSpecifierSeq());
// Get the declarator and check it's name
List declarators = declaration.getDeclarators();
@ -198,7 +198,7 @@ public class DOMTests extends TestCase {
declaration = (SimpleDeclaration)declarations.get(1);
// Make sure it's an float
assertEquals(DeclarationSpecifier.t_float, declaration.getDeclSpecifier().getDeclSpecifierSeq());
assertEquals(DeclSpecifier.t_float, declaration.getDeclSpecifier().getDeclSpecifierSeq());
declarators = declaration.getDeclarators();
assertEquals( 3, declarators.size() );
name = ((Declarator)declarators.get(0)).getName();
@ -225,7 +225,7 @@ public class DOMTests extends TestCase {
List declarations = translationUnit.getDeclarations();
assertEquals(1, declarations.size());
SimpleDeclaration simpleDeclaration = (SimpleDeclaration)declarations.get(0);
assertEquals( simpleDeclaration.getDeclSpecifier().getType(), DeclarationSpecifier.t_void );
assertEquals( simpleDeclaration.getDeclSpecifier().getType(), DeclSpecifier.t_void );
List declarators = simpleDeclaration.getDeclarators();
assertEquals( 1, declarators.size() );
Declarator functionDeclarator = (Declarator)declarators.get( 0 );
@ -235,7 +235,7 @@ public class DOMTests extends TestCase {
List parameterDecls = pdc.getDeclarations();
assertEquals( 1, parameterDecls.size() );
ParameterDeclaration parm1 = (ParameterDeclaration)parameterDecls.get( 0 );
assertEquals( DeclarationSpecifier.t_void, parm1.getDeclSpecifier().getType() );
assertEquals( DeclSpecifier.t_void, parm1.getDeclSpecifier().getType() );
List parm1Decls = parm1.getDeclarators();
assertEquals( 1, parm1Decls.size() );
Declarator parm1Declarator = (Declarator) parm1Decls.get(0);
@ -261,7 +261,7 @@ public class DOMTests extends TestCase {
List classDeclarations = classSpec.getDeclarations();
assertEquals( classDeclarations.size(), 1 );
SimpleDeclaration simpleDeclaration = (SimpleDeclaration)classDeclarations.get(0);
assertEquals( simpleDeclaration.getDeclSpecifier().getType(), DeclarationSpecifier.t_int );
assertEquals( simpleDeclaration.getDeclSpecifier().getType(), DeclSpecifier.t_int );
List simpleDeclarators = simpleDeclaration.getDeclarators();
assertEquals( simpleDeclarators.size(), 2 );
Declarator methodDeclarator = (Declarator)simpleDeclarators.get(0);
@ -271,7 +271,7 @@ public class DOMTests extends TestCase {
List parameterDeclarations = pdc.getDeclarations();
assertEquals( 1, parameterDeclarations.size() );
ParameterDeclaration parm1Declaration = (ParameterDeclaration)parameterDeclarations.get(0);
assertEquals( DeclarationSpecifier.t_double, parm1Declaration.getDeclSpecifier().getType() );
assertEquals( DeclSpecifier.t_double, parm1Declaration.getDeclSpecifier().getType() );
List parm1Declarators = parm1Declaration.getDeclarators();
assertEquals( parm1Declarators.size(), 1 );
Declarator parm1Declarator = (Declarator)parm1Declarators.get(0);

View file

@ -11,10 +11,11 @@
package org.eclipse.cdt.core.parser.tests;
import junit.framework.TestCase;
import java.util.Iterator;
import java.util.Map;
import junit.framework.TestCase;
import org.eclipse.cdt.internal.core.parser.Declaration;
import org.eclipse.cdt.internal.core.parser.ParserSymbolTable;
import org.eclipse.cdt.internal.core.parser.ParserSymbolTableException;