mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=49167.<BR> Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=39676.<BR>
This commit is contained in:
parent
2be2d0afed
commit
27ceac6cb6
19 changed files with 277 additions and 34 deletions
|
@ -2219,5 +2219,15 @@ public class QuickParseASTTests extends BaseASTTest
|
|||
Iterator i = parse( "class __decl main{ int main; };", true, false ).getDeclarations();
|
||||
assertFalse( i.hasNext() );
|
||||
}
|
||||
|
||||
|
||||
public void testBug57652() throws Exception
|
||||
{
|
||||
parse("struct file_operations driver_fops = { open: device_open, release: device_release };", true, true, ParserLanguage.C ).getDeclarations();
|
||||
}
|
||||
|
||||
public void testBug39676_tough() throws Exception
|
||||
{
|
||||
parse( "int widths[] = { [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 };", true, true, ParserLanguage.C );
|
||||
}
|
||||
|
||||
}
|
|
@ -44,7 +44,7 @@ public class ParserFactory {
|
|||
public static IASTFactory createASTFactory( IFilenameProvider provider, ParserMode mode, ParserLanguage language )
|
||||
{
|
||||
if( mode == ParserMode.QUICK_PARSE )
|
||||
return new QuickParseASTFactory();
|
||||
return new QuickParseASTFactory(extensionFactory.createASTExtension( mode ));
|
||||
else if( mode == ParserMode.EXPRESSION_PARSE )
|
||||
return new ExpressionParseASTFactory( extensionFactory.createASTExtension( mode ));
|
||||
else
|
||||
|
|
|
@ -22,6 +22,7 @@ public interface IASTDesignator
|
|||
{
|
||||
public static final DesignatorKind FIELD = new DesignatorKind( 0 );
|
||||
public static final DesignatorKind SUBSCRIPT = new DesignatorKind( 1 );
|
||||
protected static final int LAST_KIND = 1;
|
||||
/**
|
||||
* @param enumValue
|
||||
*/
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package org.eclipse.cdt.core.parser.ast;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
|
@ -206,7 +207,7 @@ public interface IASTFactory
|
|||
|
||||
public IASTField createField( IASTScope scope, ITokenDuple name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, int startingOffset, int startingLine, int nameOffset, int nameEndOffset, int nameLine, IASTExpression constructorExpression, ASTAccessVisibility visibility) throws ASTSemanticException;
|
||||
|
||||
public IASTDesignator createDesignator( IASTDesignator.DesignatorKind kind, IASTExpression constantExpression, IToken fieldIdentifier );
|
||||
public IASTDesignator createDesignator( IASTDesignator.DesignatorKind kind, IASTExpression constantExpression, IToken fieldIdentifier, Map extensionParms );
|
||||
|
||||
public IASTParameterDeclaration createParameterDeclaration( boolean isConst, boolean isVolatile, IASTTypeSpecifier getTypeSpecifier, List pointerOperators, List arrayModifiers, List parameters, ASTPointerOperator pointerOp, String parameterName, IASTInitializerClause initializerClause, int startingOffset, int startingLine, int nameOffset, int nameEndOffset, int nameLine, int endingOffset, int endingLine ) ;
|
||||
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation */
|
||||
|
||||
package org.eclipse.cdt.core.parser.ast.gcc;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDesignator;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IASTGCCDesignator extends IASTDesignator {
|
||||
|
||||
public static class DesignatorKind extends IASTDesignator.DesignatorKind
|
||||
{
|
||||
public static final DesignatorKind SUBSCRIPT_RANGE = new DesignatorKind(LAST_KIND + 1 );
|
||||
|
||||
/**
|
||||
* @param enumValue
|
||||
*/
|
||||
protected DesignatorKind(int enumValue) {
|
||||
super(enumValue);
|
||||
}
|
||||
}
|
||||
|
||||
public static final String SECOND_EXRESSION = "SUBSCRIPT2 EXPRESSION"; //$NON-NLS-1$
|
||||
public IASTExpression arraySubscriptExpression2();
|
||||
}
|
|
@ -32,5 +32,6 @@ public interface IASTGCCSimpleTypeSpecifier extends IASTSimpleTypeSpecifier {
|
|||
|
||||
}
|
||||
|
||||
public static final String TYPEOF_EXRESSION = "TYPEOF EXPRESSION"; //$NON-NLS-1$
|
||||
public IASTExpression getTypeOfExpression();
|
||||
}
|
||||
|
|
|
@ -11,8 +11,11 @@
|
|||
package org.eclipse.cdt.core.parser.extension;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDesignator;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
||||
|
@ -60,5 +63,8 @@ public interface IASTFactoryExtension {
|
|||
boolean isLong,
|
||||
boolean isSigned,
|
||||
boolean isUnsigned, boolean isTypename, boolean isComplex, boolean isImaginary, boolean isGlobal, Hashtable extensionParms );
|
||||
|
||||
public boolean overrideCreateDesignatorMethod( IASTDesignator.DesignatorKind kind );
|
||||
public IASTDesignator createDesignator( IASTDesignator.DesignatorKind kind, IASTExpression constantExpression, IToken fieldIdentifier, Map extensionParms );
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.core.parser.extension;
|
|||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDesignator;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||
|
@ -55,4 +56,15 @@ public interface IParserExtension {
|
|||
* @return TODO
|
||||
*/
|
||||
public IDeclSpecifierExtensionResult parseDeclSpecifierSequence(IParserData parser, Parser.Flags flags, DeclarationWrapper sdw, CompletionKind kind, Key key );
|
||||
/**
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
public boolean canHandleCDesignatorInitializer(int tokenType);
|
||||
/**
|
||||
* @param parserData
|
||||
* @param scope TODO
|
||||
* @return
|
||||
*/
|
||||
public IASTDesignator parseDesignator(IParserData parserData, IASTScope scope);
|
||||
}
|
||||
|
|
|
@ -2904,4 +2904,13 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
|||
public final ParserLanguage getParserLanguage() {
|
||||
return language;
|
||||
}
|
||||
/**
|
||||
* Parse an identifier.
|
||||
*
|
||||
* @throws BacktrackException request a backtrack
|
||||
*/
|
||||
public IToken identifier() throws EndOfFileException, BacktrackException {
|
||||
IToken first = consume(IToken.tIDENTIFIER); // throws backtrack if its not that
|
||||
return first;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package org.eclipse.cdt.internal.core.parser;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.parser.BacktrackException;
|
||||
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||
|
@ -21,10 +22,12 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
|||
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDesignator;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||
import org.eclipse.cdt.core.parser.ast.gcc.IASTGCCDesignator;
|
||||
import org.eclipse.cdt.core.parser.ast.gcc.IASTGCCExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.gcc.IASTGCCSimpleTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
||||
|
@ -262,7 +265,7 @@ public class GCCParserExtension implements IParserExtension {
|
|||
sdw.setSimpleType( IASTGCCSimpleTypeSpecifier.Type.TYPEOF );
|
||||
flags.setEncounteredRawType(true);
|
||||
Hashtable params = new Hashtable();
|
||||
params.put( ASTGCCSimpleTypeSpecifier.TYPEOF_EXRESSION, typeOfExpression );
|
||||
params.put( IASTGCCSimpleTypeSpecifier.TYPEOF_EXRESSION, typeOfExpression );
|
||||
sdw.setExtensionParameter( ASTGCCSimpleTypeSpecifier.TYPEOF_EXRESSION, typeOfExpression );
|
||||
return new GCCDeclSpecifierExtensionResult( startingPoint, data.getLastToken(), flags, params );
|
||||
}
|
||||
|
@ -393,4 +396,61 @@ public class GCCParserExtension implements IParserExtension {
|
|||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.extension.IParserExtension#canHandleCDesignatorInitializer(int)
|
||||
*/
|
||||
public boolean canHandleCDesignatorInitializer(int tokenType) {
|
||||
switch( tokenType )
|
||||
{
|
||||
case IToken.tIDENTIFIER:
|
||||
case IToken.tLBRACKET:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.extension.IParserExtension#parseDesignator(org.eclipse.cdt.internal.core.parser.IParserData)
|
||||
*/
|
||||
public IASTDesignator parseDesignator(IParserData parserData, IASTScope scope) {
|
||||
IToken startingPoint = null;
|
||||
try {
|
||||
startingPoint = parserData.mark();
|
||||
} catch (EndOfFileException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if( parserData.LT(1) == IToken.tIDENTIFIER )
|
||||
{
|
||||
IToken identifier = parserData.identifier();
|
||||
parserData.consume( IToken.tCOLON );
|
||||
return parserData.getAstFactory().createDesignator( IASTDesignator.DesignatorKind.FIELD, null, identifier, null );
|
||||
}
|
||||
if( parserData.LT(1) == IToken.tLBRACKET )
|
||||
{
|
||||
parserData.consume( IToken.tLBRACKET );
|
||||
IASTExpression constantExpression1 = parserData.expression( scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION );
|
||||
parserData.consume( IToken.tELLIPSIS );
|
||||
IASTExpression constantExpression2 = parserData.expression( scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION );
|
||||
parserData.consume(IToken.tRBRACKET );
|
||||
Map extensionParms = new Hashtable();
|
||||
extensionParms.put( IASTGCCDesignator.SECOND_EXRESSION, constantExpression2 );
|
||||
return parserData.getAstFactory().createDesignator( IASTGCCDesignator.DesignatorKind.SUBSCRIPT_RANGE, constantExpression1, null, extensionParms );
|
||||
|
||||
}
|
||||
}
|
||||
catch( EndOfFileException eof )
|
||||
{
|
||||
}
|
||||
catch( BacktrackException bt )
|
||||
{
|
||||
}
|
||||
parserData.backup( startingPoint );
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IParserData {
|
||||
public interface IParserData extends IExpressionParser {
|
||||
/**
|
||||
* @return Returns the astFactory.
|
||||
*/
|
||||
|
@ -113,4 +113,6 @@ public interface IParserData {
|
|||
* @return
|
||||
*/
|
||||
public IASTExpression shiftExpression(IASTScope scope, CompletionKind kind, Key key) throws BacktrackException, EndOfFileException;
|
||||
|
||||
public IToken identifier() throws EndOfFileException, BacktrackException;
|
||||
}
|
|
@ -1755,16 +1755,6 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
if( isForewardDecl )
|
||||
((IASTElaboratedTypeSpecifier)elaboratedTypeSpec).acceptElement( requestor );
|
||||
}
|
||||
/**
|
||||
* Parse an identifier.
|
||||
*
|
||||
* @throws BacktrackException request a backtrack
|
||||
*/
|
||||
protected IToken identifier() throws EndOfFileException, BacktrackException
|
||||
{
|
||||
IToken first = consume(IToken.tIDENTIFIER); // throws backtrack if its not that
|
||||
return first;
|
||||
}
|
||||
/**
|
||||
* Parses the initDeclarator construct of the ANSI C++ spec.
|
||||
*
|
||||
|
@ -1845,15 +1835,17 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
{
|
||||
if (LT(1) == IToken.tLBRACE)
|
||||
{
|
||||
consume(IToken.tLBRACE);
|
||||
IToken mark = consume(IToken.tLBRACE);
|
||||
List initializerList = new ArrayList();
|
||||
for (;;)
|
||||
{
|
||||
IToken checkToken = LA(1);
|
||||
// required at least one initializer list
|
||||
// get designator list
|
||||
List newDesignators = designatorList(scope);
|
||||
if( newDesignators.size() != 0 )
|
||||
consume( IToken.tASSIGN );
|
||||
if( LT(1) == IToken.tASSIGN )
|
||||
consume( IToken.tASSIGN );
|
||||
IASTInitializerClause initializer =
|
||||
cInitializerClause(scope, newDesignators );
|
||||
initializerList.add(initializer);
|
||||
|
@ -1865,6 +1857,11 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
consume(IToken.tCOMMA);
|
||||
if (LT(1) == IToken.tRBRACE)
|
||||
break;
|
||||
if( checkToken == LA(1))
|
||||
{
|
||||
backup( mark );
|
||||
throw backtrack;
|
||||
}
|
||||
// otherwise, its another initializer in the list
|
||||
}
|
||||
// consume the closing brace
|
||||
|
@ -2010,17 +2007,37 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
}
|
||||
else if( LT(1) == IToken.tLBRACKET )
|
||||
{
|
||||
consume( IToken.tLBRACKET );
|
||||
IToken mark = consume( IToken.tLBRACKET );
|
||||
constantExpression = expression( scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.EXPRESSION );
|
||||
if( LT(1) != IToken.tRBRACKET )
|
||||
{
|
||||
backup( mark );
|
||||
if( extension.canHandleCDesignatorInitializer( LT(1)))
|
||||
{
|
||||
IASTDesignator d = extension.parseDesignator( this, scope );
|
||||
if( d != null )
|
||||
designatorList.add( d );
|
||||
break;
|
||||
}
|
||||
}
|
||||
consume( IToken.tRBRACKET );
|
||||
kind = IASTDesignator.DesignatorKind.SUBSCRIPT;
|
||||
}
|
||||
|
||||
IASTDesignator d =
|
||||
astFactory.createDesignator( kind, constantExpression, id );
|
||||
astFactory.createDesignator( kind, constantExpression, id, null );
|
||||
designatorList.add( d );
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( extension.canHandleCDesignatorInitializer( LT(1)))
|
||||
{
|
||||
IASTDesignator d = extension.parseDesignator( this, scope );
|
||||
if( d != null )
|
||||
designatorList.add( d );
|
||||
}
|
||||
}
|
||||
return designatorList;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package org.eclipse.cdt.internal.core.parser.ast;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
|
@ -24,6 +25,7 @@ import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTMacro;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDesignator.DesignatorKind;
|
||||
import org.eclipse.cdt.core.parser.extension.IASTFactoryExtension;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -32,6 +34,11 @@ import org.eclipse.cdt.core.parser.ast.IASTDesignator.DesignatorKind;
|
|||
*/
|
||||
public class BaseASTFactory {
|
||||
|
||||
public BaseASTFactory( IASTFactoryExtension extension )
|
||||
{
|
||||
this.extension = extension;
|
||||
}
|
||||
|
||||
protected IParserLogService logService;
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -60,8 +67,10 @@ public class BaseASTFactory {
|
|||
return new ASTArrayModifier( exp );
|
||||
}
|
||||
|
||||
public IASTDesignator createDesignator(DesignatorKind kind, IASTExpression constantExpression, IToken fieldIdentifier)
|
||||
public IASTDesignator createDesignator(DesignatorKind kind, IASTExpression constantExpression, IToken fieldIdentifier, Map extensionParms)
|
||||
{
|
||||
if( extension.overrideCreateDesignatorMethod( kind ))
|
||||
return extension.createDesignator( kind, constantExpression, fieldIdentifier, extensionParms );
|
||||
return new ASTDesignator( kind, constantExpression,
|
||||
fieldIdentifier == null ? "" : fieldIdentifier.getImage(), //$NON-NLS-1$
|
||||
fieldIdentifier == null ? -1 : fieldIdentifier.getOffset() );
|
||||
|
@ -71,5 +80,7 @@ public class BaseASTFactory {
|
|||
logService = log;
|
||||
}
|
||||
|
||||
protected final IASTFactoryExtension extension;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -13,16 +13,21 @@ package org.eclipse.cdt.internal.core.parser.ast;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDesignator;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDesignator.DesignatorKind;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
||||
import org.eclipse.cdt.core.parser.ast.gcc.IASTGCCDesignator;
|
||||
import org.eclipse.cdt.core.parser.ast.gcc.IASTGCCExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.gcc.IASTGCCSimpleTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.extension.IASTFactoryExtension;
|
||||
|
@ -30,6 +35,7 @@ import org.eclipse.cdt.internal.core.parser.ast.complete.ASTExpression;
|
|||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTTypeId;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.complete.gcc.ASTGCCSimpleTypeSpecifier;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.expression.gcc.ASTGCCExpression;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.gcc.ASTGCCDesignator;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
|
||||
|
@ -86,14 +92,18 @@ public class GCCASTExtension implements IASTFactoryExtension {
|
|||
public TypeInfo getExpressionResultType(Kind kind, IASTExpression lhs, IASTExpression rhs, IASTTypeId typeId) {
|
||||
TypeInfo info = null;
|
||||
if( kind == IASTGCCExpression.Kind.UNARY_ALIGNOF_TYPEID ||
|
||||
kind == IASTGCCExpression.Kind.UNARY_ALIGNOF_UNARYEXPRESSION ||
|
||||
kind == IASTGCCExpression.Kind.RELATIONAL_MAX ||
|
||||
kind == IASTGCCExpression.Kind.RELATIONAL_MIN )
|
||||
kind == IASTGCCExpression.Kind.UNARY_ALIGNOF_UNARYEXPRESSION )
|
||||
{
|
||||
info = new TypeInfo();
|
||||
info.setType(TypeInfo.t_int);
|
||||
info.setBit(true, TypeInfo.isUnsigned);
|
||||
}
|
||||
else if( kind == IASTGCCExpression.Kind.RELATIONAL_MAX ||
|
||||
kind == IASTGCCExpression.Kind.RELATIONAL_MIN )
|
||||
{
|
||||
if( lhs instanceof ASTExpression )
|
||||
info = new TypeInfo( ((ASTExpression)lhs).getResultType().getResult() );
|
||||
}
|
||||
else if( kind == IASTGCCExpression.Kind.UNARY_TYPEOF_TYPEID )
|
||||
{
|
||||
if( typeId instanceof ASTTypeId )
|
||||
|
@ -131,4 +141,19 @@ public class GCCASTExtension implements IASTFactoryExtension {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.extension.IASTFactoryExtension#overrideCreateDesignatorMethod(org.eclipse.cdt.core.parser.ast.IASTDesignator.DesignatorKind)
|
||||
*/
|
||||
public boolean overrideCreateDesignatorMethod(DesignatorKind kind) {
|
||||
if( kind == IASTGCCDesignator.DesignatorKind.SUBSCRIPT_RANGE )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.extension.IASTFactoryExtension#createDesignator(org.eclipse.cdt.core.parser.ast.IASTDesignator.DesignatorKind, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.IToken, java.util.Map)
|
||||
*/
|
||||
public IASTDesignator createDesignator(DesignatorKind kind, IASTExpression constantExpression, IToken fieldIdentifier, Map extensionParms) {
|
||||
IASTExpression secondExpression = (IASTExpression) extensionParms.get( IASTGCCDesignator.SECOND_EXRESSION );
|
||||
return new ASTGCCDesignator( kind, constantExpression, EMPTY_STRING, -1, secondExpression );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,7 +113,6 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
private final static List SUBSCRIPT;
|
||||
private final static IProblemFactory problemFactory = new ASTProblemFactory();
|
||||
private final IFilenameProvider fileProvider;
|
||||
private final IASTFactoryExtension extension;
|
||||
|
||||
static
|
||||
{
|
||||
|
@ -136,10 +135,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
|
||||
public CompleteParseASTFactory( IFilenameProvider filenameProvider, ParserLanguage language, ParserMode mode, IASTFactoryExtension extension )
|
||||
{
|
||||
super();
|
||||
super(extension);
|
||||
pst = new ParserSymbolTable( language, mode );
|
||||
fileProvider = filenameProvider;
|
||||
this.extension = extension;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1091,7 +1089,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
ASTExpression astExpression = (ASTExpression) rhs;
|
||||
Iterator refs = astExpression.getReferences().iterator();
|
||||
String idExpression = astExpression.getIdExpression();
|
||||
if( !idExpression.equals( ""))
|
||||
if( !idExpression.equals( "")) //$NON-NLS-1$
|
||||
{
|
||||
while( refs.hasNext() )
|
||||
{
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
|||
*/
|
||||
public class ASTGCCSimpleTypeSpecifier extends ASTSimpleTypeSpecifier implements IASTGCCSimpleTypeSpecifier {
|
||||
|
||||
public static final String TYPEOF_EXRESSION = "TYPEOF EXPRESSION"; //$NON-NLS-1$
|
||||
private final IASTExpression expression;
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.parser.ast.expression;
|
|||
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
|
@ -75,13 +76,11 @@ public class ExpressionParseASTFactory extends BaseASTFactory implements IASTFac
|
|||
|
||||
|
||||
|
||||
private final IASTFactoryExtension extension;
|
||||
|
||||
/**
|
||||
* @param factory
|
||||
*/
|
||||
public ExpressionParseASTFactory( IASTFactoryExtension extension ) {
|
||||
this.extension = extension;
|
||||
super( extension );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -672,7 +671,7 @@ public class ExpressionParseASTFactory extends BaseASTFactory implements IASTFac
|
|||
public IASTDesignator createDesignator(
|
||||
DesignatorKind kind,
|
||||
IASTExpression constantExpression,
|
||||
IToken fieldIdentifier) {
|
||||
IToken fieldIdentifier, Map extensionParms) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation */
|
||||
|
||||
package org.eclipse.cdt.internal.core.parser.ast.gcc;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDesignator;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.parser.ast.gcc.IASTGCCDesignator;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.ASTDesignator;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ASTGCCDesignator extends ASTDesignator
|
||||
implements
|
||||
IASTGCCDesignator {
|
||||
private final IASTExpression secondExpression;
|
||||
|
||||
/**
|
||||
* @param kind
|
||||
* @param constantExpression
|
||||
* @param fieldName
|
||||
* @param fieldOffset
|
||||
*/
|
||||
public ASTGCCDesignator(IASTDesignator.DesignatorKind kind, IASTExpression constantExpression, String fieldName, int fieldOffset, IASTExpression secondSubscriptExpression) {
|
||||
super(kind, constantExpression, fieldName, fieldOffset);
|
||||
secondExpression = secondSubscriptExpression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.gcc.IASTGCCDesignator#arraySubscriptExpression2()
|
||||
*/
|
||||
public IASTExpression arraySubscriptExpression2() {
|
||||
return secondExpression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||
*/
|
||||
public void acceptElement(ISourceElementRequestor requestor)
|
||||
{
|
||||
super.acceptElement( requestor );
|
||||
if( secondExpression != null )
|
||||
secondExpression.acceptElement(requestor);
|
||||
}
|
||||
}
|
|
@ -58,6 +58,7 @@ import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
||||
import org.eclipse.cdt.core.parser.extension.IASTFactoryExtension;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.expression.ASTExpression;
|
||||
|
||||
|
@ -71,9 +72,9 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
|||
private static final boolean CREATE_EXCESS_CONSTRUCTS = true;
|
||||
|
||||
|
||||
public QuickParseASTFactory( )
|
||||
public QuickParseASTFactory( IASTFactoryExtension extension )
|
||||
{
|
||||
super();
|
||||
super(extension);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
Loading…
Add table
Reference in a new issue