mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-19 23:15:24 +02:00
Finished DeclSpecifier for new C++ Parser.
This commit is contained in:
parent
ece695b022
commit
80e8ac3fc6
21 changed files with 1124 additions and 222 deletions
|
@ -40,7 +40,7 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypedefNameSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTUnaryTypeIdExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTUnaryTypeIdExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
@ -261,7 +261,7 @@ public class AST2Tests extends TestCase {
|
||||||
// the declaration for myS
|
// the declaration for myS
|
||||||
IASTSimpleDeclaration decl_myS = (IASTSimpleDeclaration)declstmt_myS.getDeclaration();
|
IASTSimpleDeclaration decl_myS = (IASTSimpleDeclaration)declstmt_myS.getDeclaration();
|
||||||
// the type specifier for myS
|
// the type specifier for myS
|
||||||
IASTTypedefNameSpecifier type_spec_myS = (IASTTypedefNameSpecifier)decl_myS.getDeclSpecifier();
|
IASTNamedTypeSpecifier type_spec_myS = (IASTNamedTypeSpecifier)decl_myS.getDeclSpecifier();
|
||||||
// the type name for myS
|
// the type name for myS
|
||||||
IASTName name_type_myS = type_spec_myS.getName();
|
IASTName name_type_myS = type_spec_myS.getName();
|
||||||
// the declarator for myS
|
// the declarator for myS
|
||||||
|
|
|
@ -27,6 +27,7 @@ public interface IASTCompositeTypeSpecifier extends IASTDeclSpecifier {
|
||||||
public int getKey();
|
public int getKey();
|
||||||
public static final int k_struct = 1;
|
public static final int k_struct = 1;
|
||||||
public static final int k_union = 2;
|
public static final int k_union = 2;
|
||||||
|
public static final int k_last = k_union;
|
||||||
|
|
||||||
|
|
||||||
public void setKey( int key );
|
public void setKey( int key );
|
||||||
|
|
|
@ -17,6 +17,7 @@ public interface IASTElaboratedTypeSpecifier extends IASTDeclSpecifier {
|
||||||
public static final int k_struct = 0;
|
public static final int k_struct = 0;
|
||||||
public static final int k_union = 1;
|
public static final int k_union = 1;
|
||||||
public static final int k_enum = 2;
|
public static final int k_enum = 2;
|
||||||
|
public static final int k_last = k_enum;
|
||||||
|
|
||||||
public int getKind();
|
public int getKind();
|
||||||
public void setKind( int value );
|
public void setKind( int value );
|
||||||
|
|
|
@ -15,7 +15,7 @@ package org.eclipse.cdt.core.dom.ast;
|
||||||
*
|
*
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
*/
|
*/
|
||||||
public interface IASTTypedefNameSpecifier extends IASTDeclSpecifier {
|
public interface IASTNamedTypeSpecifier extends IASTDeclSpecifier {
|
||||||
|
|
||||||
public static final ASTNodeProperty NAME = new ASTNodeProperty( "Name"); //$NON-NLS-1$
|
public static final ASTNodeProperty NAME = new ASTNodeProperty( "Name"); //$NON-NLS-1$
|
||||||
|
|
|
@ -9,12 +9,12 @@
|
||||||
* IBM Rational Software - Initial API and implementation */
|
* IBM Rational Software - Initial API and implementation */
|
||||||
package org.eclipse.cdt.core.dom.ast.c;
|
package org.eclipse.cdt.core.dom.ast.c;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypedefNameSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public interface ICASTTypedefNameSpecifier extends IASTTypedefNameSpecifier,
|
public interface ICASTTypedefNameSpecifier extends IASTNamedTypeSpecifier,
|
||||||
ICASTDeclSpecifier {
|
ICASTDeclSpecifier {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public interface ICPPASTCompositeTypeSpecifier extends IASTCompositeTypeSpecifier,
|
||||||
|
ICPPASTDeclSpecifier {
|
||||||
|
|
||||||
|
public static final int k_class = IASTCompositeTypeSpecifier.k_last + 1;
|
||||||
|
public static final int k_last = k_class;
|
||||||
|
|
||||||
|
public static final ASTNodeProperty VISIBILITY_LABEL = new ASTNodeProperty( "Visibility Label"); //$NON-NLS-1$
|
||||||
|
public static final ASTNodeProperty BASE_SPECIFIER = new ASTNodeProperty( "Base Specifier"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
public static interface ICPPASTBaseSpecifier extends IASTNode
|
||||||
|
{
|
||||||
|
public boolean isVirtual();
|
||||||
|
public void setVirtual( boolean value );
|
||||||
|
|
||||||
|
public static final int v_public = 1;
|
||||||
|
public static final int v_protected = 2;
|
||||||
|
public static final int v_private = 3;
|
||||||
|
|
||||||
|
public int getVisibility();
|
||||||
|
public void setVisibility( int visibility );
|
||||||
|
|
||||||
|
public static final ASTNodeProperty NAME = new ASTNodeProperty( "BaseSpec Name"); //$NON-NLS-1$
|
||||||
|
public IASTName getName();
|
||||||
|
public void setName( IASTName name );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List getBaseSpecifiers();
|
||||||
|
public void addBaseSpecifier( ICPPASTBaseSpecifier baseSpec );
|
||||||
|
|
||||||
|
}
|
|
@ -23,5 +23,12 @@ public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier {
|
||||||
|
|
||||||
// A declaration in C++ can be a friend declaration
|
// A declaration in C++ can be a friend declaration
|
||||||
public boolean isFriend();
|
public boolean isFriend();
|
||||||
|
public void setFriend( boolean value );
|
||||||
|
|
||||||
|
public boolean isVirtual();
|
||||||
|
public void setVirtual( boolean value );
|
||||||
|
|
||||||
|
public boolean isExplicit();
|
||||||
|
public void setExplicit( boolean value );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public interface ICPPASTElaboratedTypeSpecifier extends
|
||||||
|
IASTElaboratedTypeSpecifier, ICPPASTDeclSpecifier {
|
||||||
|
|
||||||
|
public static final int k_class = IASTElaboratedTypeSpecifier.k_last + 1;
|
||||||
|
public static final int k_last = k_class;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public interface ICPPASTNamedTypeSpecifier extends IASTNamedTypeSpecifier, ICPPASTDeclSpecifier {
|
||||||
|
|
||||||
|
public boolean isTypename();
|
||||||
|
public void setIsTypename( boolean value );
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public interface ICPPASTVisiblityLabel extends IASTDeclaration {
|
||||||
|
|
||||||
|
public static final int v_public = 1;
|
||||||
|
public static final int v_protected = 2;
|
||||||
|
public static final int v_private = 3;
|
||||||
|
|
||||||
|
public int getVisibility();
|
||||||
|
public void setVisibility( int visibility );
|
||||||
|
|
||||||
|
}
|
|
@ -43,6 +43,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.c.ICASTEnumerationSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
|
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTTypeIdExpression;
|
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTTypeIdExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTUnaryExpression;
|
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTUnaryExpression;
|
||||||
|
@ -65,6 +66,7 @@ import org.eclipse.cdt.internal.core.parser2.c.CASTContinueStatement;
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTDeclarationStatement;
|
import org.eclipse.cdt.internal.core.parser2.c.CASTDeclarationStatement;
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTDefaultStatement;
|
import org.eclipse.cdt.internal.core.parser2.c.CASTDefaultStatement;
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTDoStatement;
|
import org.eclipse.cdt.internal.core.parser2.c.CASTDoStatement;
|
||||||
|
import org.eclipse.cdt.internal.core.parser2.c.CASTEnumerationSpecifier;
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTExpressionStatement;
|
import org.eclipse.cdt.internal.core.parser2.c.CASTExpressionStatement;
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTForStatement;
|
import org.eclipse.cdt.internal.core.parser2.c.CASTForStatement;
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTGotoStatement;
|
import org.eclipse.cdt.internal.core.parser2.c.CASTGotoStatement;
|
||||||
|
@ -1058,14 +1060,14 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
* enumerator-definition enumerator-list , enumerator-definition
|
* enumerator-definition enumerator-list , enumerator-definition
|
||||||
* enumerator-definition: enumerator enumerator = constant-expression
|
* enumerator-definition: enumerator enumerator = constant-expression
|
||||||
* enumerator: identifier
|
* enumerator: identifier
|
||||||
*
|
|
||||||
* @param owner
|
* @param owner
|
||||||
* IParserCallback object that represents the declaration that
|
* IParserCallback object that represents the declaration that
|
||||||
* owns this type specifier.
|
* owns this type specifier.
|
||||||
|
*
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
* request a backtrack
|
* request a backtrack
|
||||||
*/
|
*/
|
||||||
protected IASTEnumerationSpecifier enumSpecifier(DeclarationWrapper sdw)
|
protected ICASTEnumerationSpecifier enumSpecifier()
|
||||||
throws BacktrackException, EndOfFileException {
|
throws BacktrackException, EndOfFileException {
|
||||||
IToken mark = mark();
|
IToken mark = mark();
|
||||||
IASTName name = null;
|
IASTName name = null;
|
||||||
|
@ -1077,7 +1079,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
name = createName();
|
name = createName();
|
||||||
if (LT(1) == IToken.tLBRACE) {
|
if (LT(1) == IToken.tLBRACE) {
|
||||||
|
|
||||||
IASTEnumerationSpecifier result = createEnumerationSpecifier();
|
ICASTEnumerationSpecifier result = (ICASTEnumerationSpecifier) createEnumerationSpecifier();
|
||||||
((ASTNode)result).setOffset( startOffset );
|
((ASTNode)result).setOffset( startOffset );
|
||||||
result.setName( name );
|
result.setName( name );
|
||||||
name.setParent( result );
|
name.setParent( result );
|
||||||
|
@ -1158,11 +1160,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
*/
|
*/
|
||||||
protected abstract IASTEnumerator createEnumerator();
|
protected abstract IASTEnumerator createEnumerator();
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
protected abstract IASTEnumerationSpecifier createEnumerationSpecifier();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param token
|
* @param token
|
||||||
* @return
|
* @return
|
||||||
|
@ -1592,4 +1589,8 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
return new CASTASMDeclaration();
|
return new CASTASMDeclaration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected IASTEnumerationSpecifier createEnumerationSpecifier() {
|
||||||
|
return new CASTEnumerationSpecifier();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -24,7 +24,6 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
|
||||||
|
@ -47,7 +46,7 @@ import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypedefNameSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTUnaryTypeIdExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTUnaryTypeIdExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
||||||
|
@ -1310,7 +1309,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
}
|
}
|
||||||
case IToken.t_enum:
|
case IToken.t_enum:
|
||||||
try {
|
try {
|
||||||
enumSpec = (ICASTEnumerationSpecifier) enumSpecifier(null);
|
enumSpec = enumSpecifier();
|
||||||
flags.setEncounteredTypename(true);
|
flags.setEncounteredTypename(true);
|
||||||
break;
|
break;
|
||||||
} catch (BacktrackException bt) {
|
} catch (BacktrackException bt) {
|
||||||
|
@ -1376,7 +1375,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
IASTName name = createName( identifier );
|
IASTName name = createName( identifier );
|
||||||
declSpec.setName( name );
|
declSpec.setName( name );
|
||||||
name.setParent( declSpec );
|
name.setParent( declSpec );
|
||||||
name.setPropertyInParent( IASTTypedefNameSpecifier.NAME );
|
name.setPropertyInParent( IASTNamedTypeSpecifier.NAME );
|
||||||
return declSpec;
|
return declSpec;
|
||||||
}
|
}
|
||||||
ICASTSimpleDeclSpecifier declSpec = createSimpleTypeSpecifier();
|
ICASTSimpleDeclSpecifier declSpec = createSimpleTypeSpecifier();
|
||||||
|
@ -1982,11 +1981,4 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return new CASTEnumerator();
|
return new CASTEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createEnumerationSpecifier()
|
|
||||||
*/
|
|
||||||
protected IASTEnumerationSpecifier createEnumerationSpecifier() {
|
|
||||||
return new CASTEnumerationSpecifier();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,127 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser2.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTBaseDeclSpecifier extends CPPASTNode implements
|
||||||
|
ICPPASTDeclSpecifier {
|
||||||
|
|
||||||
|
private boolean friend;
|
||||||
|
private boolean inline;
|
||||||
|
private boolean volatil;
|
||||||
|
private boolean isConst;
|
||||||
|
private int sc;
|
||||||
|
private boolean virtual;
|
||||||
|
private boolean explicit;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier#isFriend()
|
||||||
|
*/
|
||||||
|
public boolean isFriend() {
|
||||||
|
return friend;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier#getStorageClass()
|
||||||
|
*/
|
||||||
|
public int getStorageClass() {
|
||||||
|
return sc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier#setStorageClass(int)
|
||||||
|
*/
|
||||||
|
public void setStorageClass(int storageClass) {
|
||||||
|
sc = storageClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier#isConst()
|
||||||
|
*/
|
||||||
|
public boolean isConst() {
|
||||||
|
return isConst;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier#setConst(boolean)
|
||||||
|
*/
|
||||||
|
public void setConst(boolean value) {
|
||||||
|
isConst = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier#isVolatile()
|
||||||
|
*/
|
||||||
|
public boolean isVolatile() {
|
||||||
|
return volatil;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier#setVolatile(boolean)
|
||||||
|
*/
|
||||||
|
public void setVolatile(boolean value) {
|
||||||
|
volatil = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier#isInline()
|
||||||
|
*/
|
||||||
|
public boolean isInline() {
|
||||||
|
return inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier#setInline(boolean)
|
||||||
|
*/
|
||||||
|
public void setInline(boolean value) {
|
||||||
|
this.inline = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier#setIsFriend(boolean)
|
||||||
|
*/
|
||||||
|
public void setFriend(boolean value) {
|
||||||
|
friend = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier#isVirtual()
|
||||||
|
*/
|
||||||
|
public boolean isVirtual() {
|
||||||
|
return virtual;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier#setVirtual(boolean)
|
||||||
|
*/
|
||||||
|
public void setVirtual(boolean value) {
|
||||||
|
virtual = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier#isExplicit()
|
||||||
|
*/
|
||||||
|
public boolean isExplicit() {
|
||||||
|
return explicit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier#setExplicit(boolean)
|
||||||
|
*/
|
||||||
|
public void setExplicit(boolean value) {
|
||||||
|
this.explicit = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser2.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTBaseSpecifier extends CPPASTNode implements
|
||||||
|
ICPPASTBaseSpecifier {
|
||||||
|
|
||||||
|
private boolean isVirtual;
|
||||||
|
private int visibility;
|
||||||
|
private IASTName name;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier#isVirtual()
|
||||||
|
*/
|
||||||
|
public boolean isVirtual() {
|
||||||
|
return isVirtual;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier#setVirtual(boolean)
|
||||||
|
*/
|
||||||
|
public void setVirtual(boolean value) {
|
||||||
|
isVirtual = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier#getVisibility()
|
||||||
|
*/
|
||||||
|
public int getVisibility() {
|
||||||
|
return visibility;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier#setVisibility(int)
|
||||||
|
*/
|
||||||
|
public void setVisibility(int visibility) {
|
||||||
|
this.visibility = visibility;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier#getName()
|
||||||
|
*/
|
||||||
|
public IASTName getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier#setName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||||
|
*/
|
||||||
|
public void setName(IASTName name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,150 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser2.cpp;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
|
||||||
|
implements ICPPASTCompositeTypeSpecifier {
|
||||||
|
|
||||||
|
private int k;
|
||||||
|
private IASTName n;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier#getBaseSpecifiers()
|
||||||
|
*/
|
||||||
|
public List getBaseSpecifiers() {
|
||||||
|
if( baseSpecs == null ) return Collections.EMPTY_LIST;
|
||||||
|
removeNullBaseSpecs();
|
||||||
|
return Arrays.asList( baseSpecs );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier#addBaseSpecifier(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier)
|
||||||
|
*/
|
||||||
|
public void addBaseSpecifier(ICPPASTBaseSpecifier baseSpec) {
|
||||||
|
if( baseSpecs == null )
|
||||||
|
{
|
||||||
|
baseSpecs = new ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier[ DEFAULT_DECLARATIONS_LIST_SIZE ];
|
||||||
|
currentIndex2 = 0;
|
||||||
|
}
|
||||||
|
if( declarations.length == currentIndex )
|
||||||
|
{
|
||||||
|
ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier [] old = baseSpecs;
|
||||||
|
baseSpecs = new ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier[ old.length * 2 ];
|
||||||
|
for( int i = 0; i < old.length; ++i )
|
||||||
|
baseSpecs[i] = old[i];
|
||||||
|
}
|
||||||
|
baseSpecs[ currentIndex2++ ] = baseSpec;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier#getKey()
|
||||||
|
*/
|
||||||
|
public int getKey() {
|
||||||
|
return k;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier#setKey(int)
|
||||||
|
*/
|
||||||
|
public void setKey(int key) {
|
||||||
|
k = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier#getName()
|
||||||
|
*/
|
||||||
|
public IASTName getName() {
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier#setName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||||
|
*/
|
||||||
|
public void setName(IASTName name) {
|
||||||
|
this.n = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier#getMembers()
|
||||||
|
*/
|
||||||
|
public List getMembers() {
|
||||||
|
if( declarations == null ) return Collections.EMPTY_LIST;
|
||||||
|
removeNullDeclarations();
|
||||||
|
return Arrays.asList( declarations );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier#addMemberDeclaration(org.eclipse.cdt.core.dom.ast.IASTDeclaration)
|
||||||
|
*/
|
||||||
|
public void addMemberDeclaration(IASTDeclaration declaration) {
|
||||||
|
if( declarations == null )
|
||||||
|
{
|
||||||
|
declarations = new IASTDeclaration[ DEFAULT_DECLARATIONS_LIST_SIZE ];
|
||||||
|
currentIndex = 0;
|
||||||
|
}
|
||||||
|
if( declarations.length == currentIndex )
|
||||||
|
{
|
||||||
|
IASTDeclaration [] old = declarations;
|
||||||
|
declarations = new IASTDeclaration[ old.length * 2 ];
|
||||||
|
for( int i = 0; i < old.length; ++i )
|
||||||
|
declarations[i] = old[i];
|
||||||
|
}
|
||||||
|
declarations[ currentIndex++ ] = declaration;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeNullDeclarations() {
|
||||||
|
int nullCount = 0;
|
||||||
|
for( int i = 0; i < declarations.length; ++i )
|
||||||
|
if( declarations[i] == null )
|
||||||
|
++nullCount;
|
||||||
|
if( nullCount == 0 ) return;
|
||||||
|
IASTDeclaration [] old = declarations;
|
||||||
|
int newSize = old.length - nullCount;
|
||||||
|
declarations = new IASTDeclaration[ newSize ];
|
||||||
|
for( int i = 0; i < newSize; ++i )
|
||||||
|
declarations[i] = old[i];
|
||||||
|
currentIndex = newSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int currentIndex = 0;
|
||||||
|
private IASTDeclaration [] declarations = null;
|
||||||
|
private static final int DEFAULT_DECLARATIONS_LIST_SIZE = 4;
|
||||||
|
|
||||||
|
private void removeNullBaseSpecs() {
|
||||||
|
int nullCount = 0;
|
||||||
|
for( int i = 0; i < baseSpecs.length; ++i )
|
||||||
|
if( baseSpecs[i] == null )
|
||||||
|
++nullCount;
|
||||||
|
if( nullCount == 0 ) return;
|
||||||
|
ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier [] old = baseSpecs;
|
||||||
|
int newSize = old.length - nullCount;
|
||||||
|
baseSpecs = new ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier[ newSize ];
|
||||||
|
for( int i = 0; i < newSize; ++i )
|
||||||
|
baseSpecs[i] = old[i];
|
||||||
|
currentIndex2 = newSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int currentIndex2 = 0;
|
||||||
|
private ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier [] baseSpecs = null;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser2.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTElaboratedTypeSpecifier extends CPPASTBaseDeclSpecifier
|
||||||
|
implements ICPPASTElaboratedTypeSpecifier {
|
||||||
|
|
||||||
|
private int kind;
|
||||||
|
private IASTName name;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier#getKind()
|
||||||
|
*/
|
||||||
|
public int getKind() {
|
||||||
|
return kind;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier#setKind(int)
|
||||||
|
*/
|
||||||
|
public void setKind(int value) {
|
||||||
|
this.kind = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier#getName()
|
||||||
|
*/
|
||||||
|
public IASTName getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier#setName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||||
|
*/
|
||||||
|
public void setName(IASTName name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,90 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser2.cpp;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTEnumerationSpecifier extends CPPASTBaseDeclSpecifier
|
||||||
|
implements IASTEnumerationSpecifier, ICPPASTDeclSpecifier {
|
||||||
|
|
||||||
|
private IASTName name;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier#addEnumerator(org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator)
|
||||||
|
*/
|
||||||
|
public void addEnumerator(IASTEnumerator enumerator) {
|
||||||
|
if( enumerators == null )
|
||||||
|
{
|
||||||
|
enumerators = new IASTEnumerator[ DEFAULT_ENUMERATORS_LIST_SIZE ];
|
||||||
|
currentIndex = 0;
|
||||||
|
}
|
||||||
|
if( enumerators.length == currentIndex )
|
||||||
|
{
|
||||||
|
IASTEnumerator [] old = enumerators;
|
||||||
|
enumerators = new IASTEnumerator[ old.length * 2 ];
|
||||||
|
for( int i = 0; i < old.length; ++i )
|
||||||
|
enumerators[i] = old[i];
|
||||||
|
}
|
||||||
|
enumerators[ currentIndex++ ] = enumerator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier#getEnumerators()
|
||||||
|
*/
|
||||||
|
public List getEnumerators() {
|
||||||
|
if( enumerators == null ) return Collections.EMPTY_LIST;
|
||||||
|
removeNullEnumerators();
|
||||||
|
return Arrays.asList( enumerators );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeNullEnumerators() {
|
||||||
|
int nullCount = 0;
|
||||||
|
for( int i = 0; i < enumerators.length; ++i )
|
||||||
|
if( enumerators[i] == null )
|
||||||
|
++nullCount;
|
||||||
|
if( nullCount == 0 ) return;
|
||||||
|
IASTEnumerator [] old = enumerators;
|
||||||
|
int newSize = old.length - nullCount;
|
||||||
|
enumerators = new IASTEnumerator[ newSize ];
|
||||||
|
for( int i = 0; i < newSize; ++i )
|
||||||
|
enumerators[i] = old[i];
|
||||||
|
currentIndex = newSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int currentIndex = 0;
|
||||||
|
private IASTEnumerator [] enumerators = null;
|
||||||
|
private static final int DEFAULT_ENUMERATORS_LIST_SIZE = 4;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier#setName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||||
|
*/
|
||||||
|
public void setName(IASTName name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier#getName()
|
||||||
|
*/
|
||||||
|
public IASTName getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser2.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTNamedTypeSpecifier extends CPPASTBaseDeclSpecifier implements
|
||||||
|
ICPPASTNamedTypeSpecifier {
|
||||||
|
|
||||||
|
private boolean typename;
|
||||||
|
private IASTName name;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier#isTypename()
|
||||||
|
*/
|
||||||
|
public boolean isTypename() {
|
||||||
|
return typename;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier#setIsTypename(boolean)
|
||||||
|
*/
|
||||||
|
public void setIsTypename(boolean value) {
|
||||||
|
typename = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier#getName()
|
||||||
|
*/
|
||||||
|
public IASTName getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier#setName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||||
|
*/
|
||||||
|
public void setName(IASTName name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,97 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser2.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier
|
||||||
|
implements ICPPASTSimpleDeclSpecifier {
|
||||||
|
|
||||||
|
private int type;
|
||||||
|
private boolean isSigned;
|
||||||
|
private boolean isUnsigned;
|
||||||
|
private boolean isShort;
|
||||||
|
private boolean isLong;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier#getType()
|
||||||
|
*/
|
||||||
|
public int getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier#setType(int)
|
||||||
|
*/
|
||||||
|
public void setType(int type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier#isSigned()
|
||||||
|
*/
|
||||||
|
public boolean isSigned() {
|
||||||
|
return isSigned;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier#isUnsigned()
|
||||||
|
*/
|
||||||
|
public boolean isUnsigned() {
|
||||||
|
return isUnsigned;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier#isShort()
|
||||||
|
*/
|
||||||
|
public boolean isShort() {
|
||||||
|
return isShort;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier#isLong()
|
||||||
|
*/
|
||||||
|
public boolean isLong() {
|
||||||
|
return isLong;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier#setSigned(boolean)
|
||||||
|
*/
|
||||||
|
public void setSigned(boolean value) {
|
||||||
|
isSigned = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier#setUnsigned(boolean)
|
||||||
|
*/
|
||||||
|
public void setUnsigned(boolean value) {
|
||||||
|
isUnsigned = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier#setLong(boolean)
|
||||||
|
*/
|
||||||
|
public void setLong(boolean value) {
|
||||||
|
isLong = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier#setShort(boolean)
|
||||||
|
*/
|
||||||
|
public void setShort(boolean value) {
|
||||||
|
isShort = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser2.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisiblityLabel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTVisibilityLabel extends CPPASTNode implements
|
||||||
|
ICPPASTVisiblityLabel {
|
||||||
|
|
||||||
|
private int visibility;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisiblityLabel#getVisibility()
|
||||||
|
*/
|
||||||
|
public int getVisibility() {
|
||||||
|
return visibility;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisiblityLabel#setVisibility(int)
|
||||||
|
*/
|
||||||
|
public void setVisibility(int visibility) {
|
||||||
|
this.visibility = visibility;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -14,23 +14,29 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceAlias;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceAlias;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
|
||||||
|
@ -43,7 +49,10 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisiblityLabel;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
|
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation;
|
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.BacktrackException;
|
import org.eclipse.cdt.core.parser.BacktrackException;
|
||||||
|
@ -69,7 +78,6 @@ import org.eclipse.cdt.internal.core.parser2.c.CASTBinaryExpression;
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTCompoundStatement;
|
import org.eclipse.cdt.internal.core.parser2.c.CASTCompoundStatement;
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTCompoundStatementExpression;
|
import org.eclipse.cdt.internal.core.parser2.c.CASTCompoundStatementExpression;
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTConditionalExpression;
|
import org.eclipse.cdt.internal.core.parser2.c.CASTConditionalExpression;
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTEnumerationSpecifier;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTEnumerator;
|
import org.eclipse.cdt.internal.core.parser2.c.CASTEnumerator;
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTExpressionList;
|
import org.eclipse.cdt.internal.core.parser2.c.CASTExpressionList;
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTName;
|
import org.eclipse.cdt.internal.core.parser2.c.CASTName;
|
||||||
|
@ -2138,7 +2146,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private ICPPASTUsingDeclaration createUsingDeclaration() {
|
protected ICPPASTUsingDeclaration createUsingDeclaration() {
|
||||||
return new CPPASTUsingDeclaration();
|
return new CPPASTUsingDeclaration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2209,7 +2217,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private ICPPASTLinkageSpecification createLinkageSpecification() {
|
protected ICPPASTLinkageSpecification createLinkageSpecification() {
|
||||||
return new CPPASTLinkageSpecification();
|
return new CPPASTLinkageSpecification();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2723,6 +2731,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected IASTName createName(ITokenDuple duple) {
|
protected IASTName createName(ITokenDuple duple) {
|
||||||
|
if( duple == null ) return createName();
|
||||||
if( duple.getSegmentCount() != 1 ) return createQualifiedName( duple );
|
if( duple.getSegmentCount() != 1 ) return createQualifiedName( duple );
|
||||||
CASTName name = new CASTName( duple.toCharArray() );
|
CASTName name = new CASTName( duple.toCharArray() );
|
||||||
name.setOffset( duple.getStartOffset());
|
name.setOffset( duple.getStartOffset());
|
||||||
|
@ -3097,16 +3106,21 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
*/
|
*/
|
||||||
protected ICPPASTDeclSpecifier declSpecifierSeq(boolean parm, boolean tryConstructor) throws BacktrackException,
|
protected ICPPASTDeclSpecifier declSpecifierSeq(boolean parm, boolean tryConstructor) throws BacktrackException,
|
||||||
EndOfFileException {
|
EndOfFileException {
|
||||||
|
IToken firstToken = LA(1);
|
||||||
Flags flags = new Flags(parm, tryConstructor);
|
Flags flags = new Flags(parm, tryConstructor);
|
||||||
|
|
||||||
boolean isInline, isVirtual, isExplicit, isFriend;
|
boolean isInline= false, isVirtual= false, isExplicit= false, isFriend= false;
|
||||||
boolean isConst, isVolatile, isRestrict;
|
boolean isConst = false, isVolatile= false, isRestrict= false;
|
||||||
boolean isLong, isShort, isUnsigned, isSigned;
|
boolean isLong= false, isShort= false, isUnsigned= false, isSigned= false;
|
||||||
boolean isTypename;
|
boolean isTypename= false;
|
||||||
|
|
||||||
int storageClass = IASTDeclSpecifier.sc_unspecified;
|
int storageClass = IASTDeclSpecifier.sc_unspecified;
|
||||||
int simpleType = IASTSimpleDeclSpecifier.t_unspecified;
|
int simpleType = IASTSimpleDeclSpecifier.t_unspecified;
|
||||||
ITokenDuple duple = null;
|
ITokenDuple duple = null;
|
||||||
|
|
||||||
|
ICPPASTCompositeTypeSpecifier classSpec = null;
|
||||||
|
ICPPASTElaboratedTypeSpecifier elabSpec = null;
|
||||||
|
IASTEnumerationSpecifier enumSpec = null;
|
||||||
declSpecifiers: for (;;) {
|
declSpecifiers: for (;;) {
|
||||||
switch (LT(1)) {
|
switch (LT(1)) {
|
||||||
case IToken.t_inline:
|
case IToken.t_inline:
|
||||||
|
@ -3262,28 +3276,27 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
case IToken.t_struct:
|
case IToken.t_struct:
|
||||||
case IToken.t_union:
|
case IToken.t_union:
|
||||||
try {
|
try {
|
||||||
classSpecifier(null);
|
classSpec = classSpecifier();
|
||||||
flags.setEncounteredTypename(true);
|
flags.setEncounteredTypename(true);
|
||||||
break;
|
break;
|
||||||
} catch (BacktrackException bt) {
|
} catch (BacktrackException bt) {
|
||||||
elaboratedTypeSpecifier(null);
|
elabSpec = elaboratedTypeSpecifier();
|
||||||
flags.setEncounteredTypename(true);
|
flags.setEncounteredTypename(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IToken.t_enum:
|
case IToken.t_enum:
|
||||||
try {
|
try {
|
||||||
enumSpecifier(null);
|
enumSpec = enumSpecifier();
|
||||||
flags.setEncounteredTypename(true);
|
flags.setEncounteredTypename(true);
|
||||||
break;
|
break;
|
||||||
} catch (BacktrackException bt) {
|
} catch (BacktrackException bt) {
|
||||||
// this is an elaborated class specifier
|
// this is an elaborated class specifier
|
||||||
elaboratedTypeSpecifier(null);
|
elabSpec = elaboratedTypeSpecifier();
|
||||||
flags.setEncounteredTypename(true);
|
flags.setEncounteredTypename(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if (supportTypeOfUnaries && LT(1) == IGCCToken.t_typeof) {
|
if (supportTypeOfUnaries && LT(1) == IGCCToken.t_typeof) {
|
||||||
IToken start = LA(1);
|
|
||||||
Object expression = unaryTypeofExpression();
|
Object expression = unaryTypeofExpression();
|
||||||
if (expression != null) {
|
if (expression != null) {
|
||||||
flags.setEncounteredTypename(true);
|
flags.setEncounteredTypename(true);
|
||||||
|
@ -3292,35 +3305,129 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
break declSpecifiers;
|
break declSpecifiers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
|
if( elabSpec != null )
|
||||||
|
{
|
||||||
|
elabSpec.setConst( isConst );
|
||||||
|
elabSpec.setVolatile( isVolatile );
|
||||||
|
if( elabSpec instanceof IGPPASTDeclSpecifier )
|
||||||
|
((IGPPASTDeclSpecifier)elabSpec).setRestrict( isRestrict );
|
||||||
|
elabSpec.setFriend( isFriend );
|
||||||
|
elabSpec.setInline( isInline );
|
||||||
|
elabSpec.setStorageClass( storageClass );
|
||||||
|
elabSpec.setVirtual( isVirtual );
|
||||||
|
elabSpec.setExplicit( isExplicit );
|
||||||
|
return elabSpec;
|
||||||
|
}
|
||||||
|
if( enumSpec != null )
|
||||||
|
{
|
||||||
|
enumSpec.setConst( isConst );
|
||||||
|
enumSpec.setVolatile( isVolatile );
|
||||||
|
if( enumSpec instanceof IGPPASTDeclSpecifier )
|
||||||
|
((IGPPASTDeclSpecifier)enumSpec).setRestrict( isRestrict );
|
||||||
|
((ICPPASTDeclSpecifier)enumSpec).setFriend( isFriend );
|
||||||
|
((ICPPASTDeclSpecifier)enumSpec).setVirtual( isVirtual );
|
||||||
|
((ICPPASTDeclSpecifier)enumSpec).setExplicit( isExplicit );
|
||||||
|
enumSpec.setInline( isInline );
|
||||||
|
enumSpec.setStorageClass( storageClass );
|
||||||
|
return elabSpec;
|
||||||
|
}
|
||||||
|
if( classSpec != null )
|
||||||
|
{
|
||||||
|
classSpec.setConst( isConst );
|
||||||
|
classSpec.setVolatile( isVolatile );
|
||||||
|
if( classSpec instanceof IGPPASTDeclSpecifier )
|
||||||
|
((IGPPASTDeclSpecifier)classSpec).setRestrict( isRestrict );
|
||||||
|
classSpec.setFriend( isFriend );
|
||||||
|
classSpec.setInline( isInline );
|
||||||
|
classSpec.setStorageClass( storageClass );
|
||||||
|
classSpec.setVirtual( isVirtual );
|
||||||
|
classSpec.setExplicit( isExplicit );
|
||||||
|
return classSpec;
|
||||||
|
}
|
||||||
|
if( duple != null )
|
||||||
|
{
|
||||||
|
ICPPASTNamedTypeSpecifier nameSpec = createNamedTypeSpecifier();
|
||||||
|
nameSpec.setIsTypename( isTypename );
|
||||||
|
IASTName name = createName( duple );
|
||||||
|
nameSpec.setName( name );
|
||||||
|
name.setParent( nameSpec );
|
||||||
|
name.setPropertyInParent( IASTNamedTypeSpecifier.NAME );
|
||||||
|
|
||||||
|
nameSpec.setConst( isConst );
|
||||||
|
nameSpec.setVolatile( isVolatile );
|
||||||
|
if( nameSpec instanceof IGPPASTDeclSpecifier )
|
||||||
|
((IGPPASTDeclSpecifier)nameSpec).setRestrict( isRestrict );
|
||||||
|
nameSpec.setFriend( isFriend );
|
||||||
|
nameSpec.setInline( isInline );
|
||||||
|
nameSpec.setStorageClass( storageClass );
|
||||||
|
nameSpec.setVirtual( isVirtual );
|
||||||
|
nameSpec.setExplicit( isExplicit );
|
||||||
|
return nameSpec;
|
||||||
|
}
|
||||||
|
ICPPASTSimpleDeclSpecifier simpleDeclSpec = createSimpleDeclSpecifier();
|
||||||
|
((CPPASTNode)simpleDeclSpec).setOffset( firstToken.getOffset() );
|
||||||
|
simpleDeclSpec.setConst( isConst );
|
||||||
|
simpleDeclSpec.setVolatile( isVolatile );
|
||||||
|
if( simpleDeclSpec instanceof IGPPASTDeclSpecifier )
|
||||||
|
((IGPPASTDeclSpecifier)simpleDeclSpec).setRestrict( isRestrict );
|
||||||
|
|
||||||
|
simpleDeclSpec.setFriend( isFriend );
|
||||||
|
simpleDeclSpec.setInline( isInline );
|
||||||
|
simpleDeclSpec.setStorageClass( storageClass );
|
||||||
|
simpleDeclSpec.setVirtual( isVirtual );
|
||||||
|
simpleDeclSpec.setExplicit( isExplicit );
|
||||||
|
|
||||||
|
simpleDeclSpec.setType( simpleType );
|
||||||
|
simpleDeclSpec.setLong( isLong );
|
||||||
|
simpleDeclSpec.setShort( isShort );
|
||||||
|
simpleDeclSpec.setUnsigned( isUnsigned );
|
||||||
|
simpleDeclSpec.setSigned( isSigned );
|
||||||
|
|
||||||
|
return simpleDeclSpec;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected ICPPASTSimpleDeclSpecifier createSimpleDeclSpecifier() {
|
||||||
|
return new CPPASTSimpleDeclSpecifier();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected ICPPASTNamedTypeSpecifier createNamedTypeSpecifier() {
|
||||||
|
return new CPPASTNamedTypeSpecifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse an elaborated type specifier.
|
* Parse an elaborated type specifier.
|
||||||
*
|
|
||||||
* @param decl
|
* @param decl
|
||||||
* Declaration which owns the elaborated type
|
* Declaration which owns the elaborated type
|
||||||
|
* @return TODO
|
||||||
|
*
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
* request a backtrack
|
* request a backtrack
|
||||||
*/
|
*/
|
||||||
protected void elaboratedTypeSpecifier(DeclarationWrapper sdw)
|
protected ICPPASTElaboratedTypeSpecifier elaboratedTypeSpecifier()
|
||||||
throws BacktrackException, EndOfFileException {
|
throws BacktrackException, EndOfFileException {
|
||||||
// this is an elaborated class specifier
|
// this is an elaborated class specifier
|
||||||
IToken t = consume();
|
IToken t = consume();
|
||||||
Object eck = null;
|
int eck = 0;
|
||||||
|
|
||||||
switch (t.getType()) {
|
switch (t.getType()) {
|
||||||
case IToken.t_class:
|
case IToken.t_class:
|
||||||
eck = null; //ASTClassKind.CLASS;
|
eck = ICPPASTElaboratedTypeSpecifier.k_class;
|
||||||
break;
|
break;
|
||||||
case IToken.t_struct:
|
case IToken.t_struct:
|
||||||
eck = null; //ASTClassKind.STRUCT;
|
eck = IASTElaboratedTypeSpecifier.k_struct;
|
||||||
break;
|
break;
|
||||||
case IToken.t_union:
|
case IToken.t_union:
|
||||||
eck = null; //ASTClassKind.UNION;
|
eck = IASTElaboratedTypeSpecifier.k_union;
|
||||||
break;
|
break;
|
||||||
case IToken.t_enum:
|
case IToken.t_enum:
|
||||||
eck = null; //ASTClassKind.ENUM;
|
eck = IASTElaboratedTypeSpecifier.k_enum;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
backup(t);
|
backup(t);
|
||||||
|
@ -3328,34 +3435,20 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
t.getFilename());
|
t.getFilename());
|
||||||
}
|
}
|
||||||
|
|
||||||
ITokenDuple d = name();
|
IASTName name = createName( name() );
|
||||||
Object elaboratedTypeSpec = null;
|
|
||||||
final boolean isForewardDecl = (LT(1) == IToken.tSEMI);
|
|
||||||
|
|
||||||
try {
|
ICPPASTElaboratedTypeSpecifier elaboratedTypeSpec = createElaboratedTypeSpecifier();
|
||||||
elaboratedTypeSpec = null; /*
|
((CPPASTNode)elaboratedTypeSpec).setOffset( t.getOffset() );
|
||||||
* astFactory.createElaboratedTypeSpecifier(sdw
|
elaboratedTypeSpec.setKind( eck );
|
||||||
* .getScope(), eck, d, t.getOffset(),
|
elaboratedTypeSpec.setName( name );
|
||||||
* t.getLineNumber(), d
|
return elaboratedTypeSpec;
|
||||||
* .getLastToken().getEndOffset(),
|
}
|
||||||
* d.getLastToken() .getLineNumber(),
|
|
||||||
* isForewardDecl, sdw.isFriend()); }
|
|
||||||
* catch (ASTSemanticException e) {
|
|
||||||
* throwBacktrack(e.getProblem());
|
|
||||||
*/
|
|
||||||
} catch (Exception e) {
|
|
||||||
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0;
|
|
||||||
logException(
|
|
||||||
"elaboratedTypeSpecifier:createElaboratedTypeSpecifier", e); //$NON-NLS-1$
|
|
||||||
throwBacktrack(t.getOffset(), endOffset, t.getLineNumber(), t
|
|
||||||
.getFilename());
|
|
||||||
}
|
|
||||||
sdw.setTypeSpecifier(elaboratedTypeSpec);
|
|
||||||
|
|
||||||
if (isForewardDecl) {
|
/**
|
||||||
// ((IASTElaboratedTypeSpecifier) elaboratedTypeSpec).acceptElement(
|
* @return
|
||||||
// requestor);
|
*/
|
||||||
}
|
protected ICPPASTElaboratedTypeSpecifier createElaboratedTypeSpecifier() {
|
||||||
|
return new CPPASTElaboratedTypeSpecifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3776,18 +3869,17 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
*
|
*
|
||||||
* classSpecifier : classKey name (baseClause)? "{" (memberSpecification)*
|
* classSpecifier : classKey name (baseClause)? "{" (memberSpecification)*
|
||||||
* "}"
|
* "}"
|
||||||
*
|
|
||||||
* @param owner
|
* @param owner
|
||||||
* IParserCallback object that represents the declaration that
|
* IParserCallback object that represents the declaration that
|
||||||
* owns this classSpecifier
|
* owns this classSpecifier
|
||||||
|
*
|
||||||
|
* @return TODO
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
* request a backtrack
|
* request a backtrack
|
||||||
*/
|
*/
|
||||||
protected void classSpecifier(DeclarationWrapper sdw)
|
protected ICPPASTCompositeTypeSpecifier classSpecifier()
|
||||||
throws BacktrackException, EndOfFileException {
|
throws BacktrackException, EndOfFileException {
|
||||||
Object nameType = null; //ClassNameType.IDENTIFIER;
|
int classKind = 0;
|
||||||
Object classKind = null;
|
|
||||||
Object access = null; //ASTAccessVisibility.PUBLIC;
|
|
||||||
IToken classKey = null;
|
IToken classKey = null;
|
||||||
IToken mark = mark();
|
IToken mark = mark();
|
||||||
|
|
||||||
|
@ -3795,55 +3887,41 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
switch (LT(1)) {
|
switch (LT(1)) {
|
||||||
case IToken.t_class:
|
case IToken.t_class:
|
||||||
classKey = consume();
|
classKey = consume();
|
||||||
classKind = null; //ASTClassKind.CLASS;
|
classKind = ICPPASTCompositeTypeSpecifier.k_class;
|
||||||
access = null; //ASTAccessVisibility.PRIVATE;
|
|
||||||
break;
|
break;
|
||||||
case IToken.t_struct:
|
case IToken.t_struct:
|
||||||
classKey = consume();
|
classKey = consume();
|
||||||
classKind = null; //ASTClassKind.STRUCT;
|
classKind = IASTCompositeTypeSpecifier.k_struct;
|
||||||
break;
|
break;
|
||||||
case IToken.t_union:
|
case IToken.t_union:
|
||||||
classKey = consume();
|
classKey = consume();
|
||||||
classKind = null; //ASTClassKind.UNION;
|
classKind = IASTCompositeTypeSpecifier.k_union;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throwBacktrack(mark.getOffset(), mark.getEndOffset(), mark
|
throwBacktrack(mark.getOffset(), mark.getEndOffset(), mark
|
||||||
.getLineNumber(), mark.getFilename());
|
.getLineNumber(), mark.getFilename());
|
||||||
}
|
}
|
||||||
|
|
||||||
ITokenDuple duple = null;
|
IASTName name = null;
|
||||||
|
|
||||||
// class name
|
// class name
|
||||||
if (LT(1) == IToken.tIDENTIFIER)
|
if (LT(1) == IToken.tIDENTIFIER)
|
||||||
duple = name();
|
name = createName( name() );
|
||||||
if (duple != null && !duple.isIdentifier())
|
else
|
||||||
nameType = null; //ClassNameType.TEMPLATE;
|
name = createName();
|
||||||
|
|
||||||
if (LT(1) != IToken.tCOLON && LT(1) != IToken.tLBRACE) {
|
if (LT(1) != IToken.tCOLON && LT(1) != IToken.tLBRACE) {
|
||||||
IToken errorPoint = LA(1);
|
IToken errorPoint = LA(1);
|
||||||
backup(mark);
|
backup(mark);
|
||||||
throwBacktrack(errorPoint.getOffset(), errorPoint.getEndOffset(),
|
throwBacktrack(errorPoint.getOffset(), errorPoint.getEndOffset(),
|
||||||
errorPoint.getLineNumber(), errorPoint.getFilename());
|
errorPoint.getLineNumber(), errorPoint.getFilename());
|
||||||
}
|
}
|
||||||
Object astClassSpecifier = null;
|
|
||||||
|
|
||||||
try {
|
ICPPASTCompositeTypeSpecifier astClassSpecifier = createClassSpecifier();
|
||||||
astClassSpecifier = null; /*astFactory.createClassSpecifier(sdw.getScope(),
|
((CPPASTNode)astClassSpecifier).setOffset( classKey.getOffset() );
|
||||||
duple, classKind, nameType, access, classKey.getOffset(),
|
astClassSpecifier.setKey( classKind );
|
||||||
classKey.getLineNumber(), duple == null ? classKey
|
astClassSpecifier.setName( name );
|
||||||
.getOffset() : duple.getFirstToken().getOffset(),
|
|
||||||
duple == null ? classKey.getEndOffset() : duple
|
|
||||||
.getFirstToken().getEndOffset(), duple == null
|
|
||||||
? classKey.getLineNumber()
|
|
||||||
: duple.getFirstToken().getLineNumber(), classKey.getFilename());
|
|
||||||
} catch (ASTSemanticException e) {
|
|
||||||
throwBacktrack(e.getProblem()); */
|
|
||||||
} catch (Exception e) {
|
|
||||||
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0;
|
|
||||||
logException("classSpecifier:createClassSpecifier", e); //$NON-NLS-1$
|
|
||||||
throwBacktrack(mark.getOffset(), endOffset, mark.getLineNumber(),
|
|
||||||
mark.getFilename());
|
|
||||||
}
|
|
||||||
sdw.setTypeSpecifier(astClassSpecifier);
|
|
||||||
// base clause
|
// base clause
|
||||||
if (LT(1) == IToken.tCOLON) {
|
if (LT(1) == IToken.tCOLON) {
|
||||||
baseSpecifier(astClassSpecifier);
|
baseSpecifier(astClassSpecifier);
|
||||||
|
@ -3851,62 +3929,77 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
if (LT(1) == IToken.tLBRACE) {
|
if (LT(1) == IToken.tLBRACE) {
|
||||||
consume(IToken.tLBRACE);
|
consume(IToken.tLBRACE);
|
||||||
// astClassSpecifier.enterScope(requestor);
|
|
||||||
|
|
||||||
try {
|
cleanupLastToken();
|
||||||
cleanupLastToken();
|
memberDeclarationLoop: while (LT(1) != IToken.tRBRACE) {
|
||||||
memberDeclarationLoop: while (LT(1) != IToken.tRBRACE) {
|
int checkToken = LA(1).hashCode();
|
||||||
int checkToken = LA(1).hashCode();
|
switch (LT(1)) {
|
||||||
switch (LT(1)) {
|
case IToken.t_public:
|
||||||
case IToken.t_public:
|
case IToken.t_protected:
|
||||||
consume();
|
case IToken.t_private:
|
||||||
consume(IToken.tCOLON);
|
IToken key = consume();
|
||||||
// astClassSpecifier
|
consume(IToken.tCOLON);
|
||||||
// .setCurrentVisibility(ASTAccessVisibility.PUBLIC);
|
ICPPASTVisiblityLabel label = createVisibilityLabel();
|
||||||
break;
|
((CPPASTNode)label).setOffset( key.getOffset() );
|
||||||
case IToken.t_protected:
|
label.setVisibility( token2Visibility( key.getType() ));
|
||||||
consume();
|
astClassSpecifier.addMemberDeclaration( label );
|
||||||
consume(IToken.tCOLON);
|
label.setParent( astClassSpecifier );
|
||||||
// astClassSpecifier
|
label.setPropertyInParent( ICPPASTCompositeTypeSpecifier.VISIBILITY_LABEL );
|
||||||
// .setCurrentVisibility(ASTAccessVisibility.PROTECTED);
|
break;
|
||||||
break;
|
case IToken.tRBRACE:
|
||||||
|
consume(IToken.tRBRACE);
|
||||||
case IToken.t_private:
|
break memberDeclarationLoop;
|
||||||
consume();
|
default:
|
||||||
consume(IToken.tCOLON);
|
try {
|
||||||
// astClassSpecifier
|
IASTDeclaration d = declaration();
|
||||||
// .setCurrentVisibility(ASTAccessVisibility.PRIVATE);
|
astClassSpecifier.addMemberDeclaration( d );
|
||||||
break;
|
d.setParent( astClassSpecifier );
|
||||||
case IToken.tRBRACE:
|
d.setPropertyInParent( IASTCompositeTypeSpecifier.MEMBER_DECLARATION );
|
||||||
consume(IToken.tRBRACE);
|
} catch (BacktrackException bt) {
|
||||||
break memberDeclarationLoop;
|
if (checkToken == LA(1).hashCode())
|
||||||
default:
|
failParseWithErrorHandling();
|
||||||
try {
|
|
||||||
declaration();
|
|
||||||
} catch (BacktrackException bt) {
|
|
||||||
if (checkToken == LA(1).hashCode())
|
|
||||||
failParseWithErrorHandling();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (checkToken == LA(1).hashCode())
|
|
||||||
failParseWithErrorHandling();
|
|
||||||
}
|
}
|
||||||
// consume the }
|
if (checkToken == LA(1).hashCode())
|
||||||
IToken lt = consume(IToken.tRBRACE);
|
failParseWithErrorHandling();
|
||||||
// astClassSpecifier.setEndingOffsetAndLineNumber(lt
|
|
||||||
// .getEndOffset(), lt.getLineNumber());
|
|
||||||
// try {
|
|
||||||
// astFactory.signalEndOfClassSpecifier(astClassSpecifier);
|
|
||||||
// } catch (Exception e1) {
|
|
||||||
// logException("classSpecifier:signalEndOfClassSpecifier", e1); //$NON-NLS-1$
|
|
||||||
// throwBacktrack(lt.getOffset(), lt.getEndOffset(), lt.getLineNumber(), lt.getFilename());
|
|
||||||
// }
|
|
||||||
|
|
||||||
} finally {
|
|
||||||
// astClassSpecifier.exitScope(requestor);
|
|
||||||
}
|
}
|
||||||
|
// consume the }
|
||||||
|
consume(IToken.tRBRACE);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return astClassSpecifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected ICPPASTCompositeTypeSpecifier createClassSpecifier() {
|
||||||
|
return new CPPASTCompositeTypeSpecifier();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected ICPPASTVisiblityLabel createVisibilityLabel() {
|
||||||
|
return new CPPASTVisibilityLabel();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected int token2Visibility(int type) {
|
||||||
|
switch( type )
|
||||||
|
{
|
||||||
|
case IToken.t_public:
|
||||||
|
return ICPPASTVisiblityLabel.v_public;
|
||||||
|
case IToken.t_protected:
|
||||||
|
return ICPPASTVisiblityLabel.v_protected;
|
||||||
|
case IToken.t_private:
|
||||||
|
return ICPPASTVisiblityLabel.v_private;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3922,96 +4015,102 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* @param classSpecOwner
|
* @param classSpecOwner
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
*/
|
*/
|
||||||
protected void baseSpecifier(Object astClassSpec)
|
protected void baseSpecifier(ICPPASTCompositeTypeSpecifier astClassSpec)
|
||||||
throws EndOfFileException, BacktrackException {
|
throws EndOfFileException, BacktrackException {
|
||||||
IToken la = LA(1);
|
|
||||||
char[] fn = la.getFilename();
|
|
||||||
int startingOffset = la.getOffset();
|
|
||||||
int line = la.getLineNumber();
|
|
||||||
la = null;
|
|
||||||
consume(IToken.tCOLON);
|
consume(IToken.tCOLON);
|
||||||
|
|
||||||
boolean isVirtual = false;
|
boolean isVirtual = false;
|
||||||
Object visibility = null; //ASTAccessVisibility.PUBLIC;
|
int visibility = 0; //ASTAccessVisibility.PUBLIC;
|
||||||
ITokenDuple nameDuple = null;
|
IASTName name = null;
|
||||||
|
IToken firstToken = null;
|
||||||
ArrayList bases = null;
|
|
||||||
|
|
||||||
baseSpecifierLoop: for (;;) {
|
baseSpecifierLoop: for (;;) {
|
||||||
switch (LT(1)) {
|
switch (LT(1)) {
|
||||||
case IToken.t_virtual:
|
case IToken.t_virtual:
|
||||||
consume(IToken.t_virtual);
|
if( firstToken == null )
|
||||||
|
firstToken = consume(IToken.t_virtual);
|
||||||
|
else
|
||||||
|
consume(IToken.t_virtual);
|
||||||
isVirtual = true;
|
isVirtual = true;
|
||||||
break;
|
break;
|
||||||
case IToken.t_public:
|
case IToken.t_public:
|
||||||
consume();
|
visibility = ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier.v_public;
|
||||||
break;
|
if( firstToken == null )
|
||||||
|
firstToken = consume();
|
||||||
|
else
|
||||||
|
consume();
|
||||||
|
break;
|
||||||
case IToken.t_protected:
|
case IToken.t_protected:
|
||||||
consume();
|
visibility = ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier.v_protected;
|
||||||
visibility = null; //ASTAccessVisibility.PROTECTED;
|
if( firstToken == null )
|
||||||
break;
|
firstToken = consume();
|
||||||
|
else
|
||||||
|
consume();
|
||||||
|
break;
|
||||||
case IToken.t_private:
|
case IToken.t_private:
|
||||||
visibility = null; //ASTAccessVisibility.PRIVATE;
|
visibility = ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier.v_private;
|
||||||
consume();
|
if( firstToken == null )
|
||||||
|
firstToken = consume();
|
||||||
|
else
|
||||||
|
consume();
|
||||||
break;
|
break;
|
||||||
case IToken.tCOLONCOLON:
|
case IToken.tCOLONCOLON:
|
||||||
case IToken.tIDENTIFIER:
|
case IToken.tIDENTIFIER:
|
||||||
//to get templates right we need to use the class as the scope
|
//to get templates right we need to use the class as the scope
|
||||||
nameDuple = name();
|
name = createName( name() );
|
||||||
break;
|
break;
|
||||||
case IToken.tCOMMA:
|
case IToken.tCOMMA:
|
||||||
//because we are using the class as the scope to get the name, we need to postpone adding the base
|
if( name == null )
|
||||||
//specifiers until after we have all the nameDuples
|
name = createName();
|
||||||
if (bases == null) {
|
ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier baseSpec = createBaseSpecifier();
|
||||||
bases = new ArrayList(4);
|
if( firstToken != null )
|
||||||
}
|
((CPPASTNode)baseSpec).setOffset( firstToken.getOffset() );
|
||||||
bases.add(new Object[] {
|
baseSpec.setVirtual( isVirtual );
|
||||||
isVirtual ? Boolean.TRUE : Boolean.FALSE, visibility,
|
baseSpec.setVisibility( visibility );
|
||||||
nameDuple });
|
baseSpec.setName( name );
|
||||||
|
name.setParent( baseSpec );
|
||||||
|
name.setPropertyInParent(ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier.NAME );
|
||||||
|
|
||||||
|
astClassSpec.addBaseSpecifier( baseSpec );
|
||||||
|
baseSpec.setParent( astClassSpec );
|
||||||
|
baseSpec.setPropertyInParent( ICPPASTCompositeTypeSpecifier.BASE_SPECIFIER );
|
||||||
|
|
||||||
isVirtual = false;
|
isVirtual = false;
|
||||||
visibility = null; //ASTAccessVisibility.PUBLIC;
|
visibility = 0;
|
||||||
nameDuple = null;
|
name = null;
|
||||||
|
firstToken = null;
|
||||||
consume();
|
consume();
|
||||||
continue baseSpecifierLoop;
|
continue baseSpecifierLoop;
|
||||||
|
case IToken.tLBRACE:
|
||||||
|
if( name == null )
|
||||||
|
name = createName();
|
||||||
|
baseSpec = createBaseSpecifier();
|
||||||
|
if( firstToken != null )
|
||||||
|
((CPPASTNode)baseSpec).setOffset( firstToken.getOffset() );
|
||||||
|
baseSpec.setVirtual( isVirtual );
|
||||||
|
baseSpec.setVisibility( visibility );
|
||||||
|
baseSpec.setName( name );
|
||||||
|
name.setParent( baseSpec );
|
||||||
|
name.setPropertyInParent(ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier.NAME );
|
||||||
|
|
||||||
|
astClassSpec.addBaseSpecifier( baseSpec );
|
||||||
|
baseSpec.setParent( astClassSpec );
|
||||||
|
baseSpec.setPropertyInParent( ICPPASTCompositeTypeSpecifier.BASE_SPECIFIER );
|
||||||
|
//fall through
|
||||||
default:
|
default:
|
||||||
break baseSpecifierLoop;
|
break baseSpecifierLoop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
if (bases != null) {
|
|
||||||
int size = bases.size();
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
Object[] data = (Object[]) bases.get(i);
|
|
||||||
// try {
|
|
||||||
// astFactory.addBaseSpecifier( astClassSpec,
|
|
||||||
// ((Boolean)data[0]).booleanValue(),
|
|
||||||
// (ASTAccessVisibility) data[1],
|
|
||||||
// (ITokenDuple)data[2] );
|
|
||||||
// } catch (ASTSemanticException e1) {
|
|
||||||
// failParse( e1.getProblem() );
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// astFactory.addBaseSpecifier(
|
|
||||||
// astClassSpec,
|
|
||||||
// isVirtual,
|
|
||||||
// visibility,
|
|
||||||
// nameDuple );
|
|
||||||
// }
|
|
||||||
// catch (ASTSemanticException e)
|
|
||||||
// {
|
|
||||||
// failParse( e.getProblem() );
|
|
||||||
} catch (Exception e) {
|
|
||||||
int endOffset = (lastToken != null) ? lastToken.getEndOffset() : 0;
|
|
||||||
logException("baseSpecifier_2::addBaseSpecifier", e); //$NON-NLS-1$
|
|
||||||
throwBacktrack(startingOffset, endOffset, line, fn);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private ICPPASTBaseSpecifier createBaseSpecifier() {
|
||||||
|
return new CPPASTBaseSpecifier();
|
||||||
|
}
|
||||||
|
|
||||||
protected void catchHandlerSequence()
|
protected void catchHandlerSequence()
|
||||||
throws EndOfFileException, BacktrackException {
|
throws EndOfFileException, BacktrackException {
|
||||||
if (LT(1) != IToken.t_catch) {
|
if (LT(1) != IToken.t_catch) {
|
||||||
|
@ -4251,13 +4350,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return new CASTEnumerator();
|
return new CASTEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createEnumerationSpecifier()
|
|
||||||
*/
|
|
||||||
protected IASTEnumerationSpecifier createEnumerationSpecifier() {
|
|
||||||
return new CASTEnumerationSpecifier();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#buildTypeIdExpression(int, org.eclipse.cdt.core.dom.ast.IASTTypeId, int)
|
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#buildTypeIdExpression(int, org.eclipse.cdt.core.dom.ast.IASTTypeId, int)
|
||||||
*/
|
*/
|
||||||
|
@ -4266,5 +4358,12 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createEnumerationSpecifier()
|
||||||
|
*/
|
||||||
|
protected IASTEnumerationSpecifier createEnumerationSpecifier() {
|
||||||
|
return new CPPASTEnumerationSpecifier();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue