mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Add support for long longs.
This commit is contained in:
parent
f516c46c67
commit
dbc642b6b4
10 changed files with 131 additions and 6 deletions
|
@ -718,5 +718,10 @@ public class AST2Tests extends AST2BaseTest {
|
|||
buffer.append( "int f( X x );"); //$NON-NLS-1$
|
||||
parse( buffer.toString(), ParserLanguage.C );
|
||||
}
|
||||
|
||||
public void testLongLong() throws ParserException
|
||||
{
|
||||
parse( "long long x;\n", ParserLanguage.C ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,10 @@ public interface ICASTSimpleDeclSpecifier extends IASTSimpleDeclSpecifier, ICAST
|
|||
public static final int t_Bool = IASTSimpleDeclSpecifier.t_last + 1;
|
||||
public static final int t_Complex = IASTSimpleDeclSpecifier.t_last + 2;
|
||||
public static final int t_Imaginary = IASTSimpleDeclSpecifier.t_last + 3;
|
||||
|
||||
public boolean isLongLong();
|
||||
public void setLongLong( boolean value );
|
||||
|
||||
public static final int t_last = t_Imaginary;
|
||||
|
||||
}
|
||||
|
|
|
@ -21,5 +21,8 @@ public interface IGPPASTSimpleDeclSpecifier extends IGPPASTDeclSpecifier,
|
|||
public static final int t_Complex = ICPPASTSimpleDeclSpecifier.t_last + 1;
|
||||
public static final int t_Imaginary = ICPPASTSimpleDeclSpecifier.t_last + 2;
|
||||
public static final int t_last = t_Imaginary;
|
||||
|
||||
public boolean isLongLong();
|
||||
public void setLongLong( boolean value );
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
|
|||
private boolean isUnsigned;
|
||||
private boolean isShort;
|
||||
private boolean isLong;
|
||||
private boolean longlong;
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -93,4 +94,18 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
|
|||
isSigned = value;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier#isLongLong()
|
||||
*/
|
||||
public boolean isLongLong() {
|
||||
return longlong;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier#setLongLong(boolean)
|
||||
*/
|
||||
public void setLongLong(boolean value) {
|
||||
longlong = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1134,7 +1134,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
int storageClass = IASTDeclSpecifier.sc_unspecified;
|
||||
boolean isInline = false;
|
||||
boolean isConst = false, isRestrict = false, isVolatile = false;
|
||||
boolean isShort = false, isLong = false, isUnsigned = false, isIdentifier = false, isSigned = false;
|
||||
boolean isShort = false, isLong = false, isUnsigned = false, isIdentifier = false, isSigned = false, isLongLong = false;
|
||||
int simpleType = IASTSimpleDeclSpecifier.t_unspecified;
|
||||
IToken identifier = null;
|
||||
IASTCompositeTypeSpecifier structSpec = null;
|
||||
|
@ -1209,7 +1209,13 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
case IToken.t_long:
|
||||
flags.setEncounteredRawType(true);
|
||||
consume();
|
||||
isLong = true;
|
||||
if( isLong )
|
||||
{
|
||||
isLongLong = true;
|
||||
isLong = false;
|
||||
}
|
||||
else
|
||||
isLong = true;
|
||||
break;
|
||||
case IToken.t_float:
|
||||
flags.setEncounteredRawType(true);
|
||||
|
@ -1360,6 +1366,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
|
||||
declSpec.setType(simpleType);
|
||||
declSpec.setLong(isLong);
|
||||
declSpec.setLongLong( isLongLong );
|
||||
declSpec.setUnsigned(isUnsigned);
|
||||
declSpec.setSigned(isSigned);
|
||||
declSpec.setShort(isShort);
|
||||
|
|
|
@ -71,5 +71,12 @@ public class ANSICPPParserExtensionConfiguration implements
|
|||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#supportLongLongs()
|
||||
*/
|
||||
public boolean supportLongLongs() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -71,4 +71,11 @@ public class GNUCPPParserExtensionConfiguration implements
|
|||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#supportLongLongs()
|
||||
*/
|
||||
public boolean supportLongLongs() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1700,12 +1700,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
private final boolean supportMinAndMaxOperators;
|
||||
private final boolean supportComplex;
|
||||
private final boolean supportRestrict;
|
||||
|
||||
private final boolean supportLongLong;
|
||||
|
||||
private static final int DEFAULT_PARM_LIST_SIZE = 4;
|
||||
private static final int DEFAULT_DECLARATOR_LIST_SIZE = 4;
|
||||
private static final int DEFAULT_POINTEROPS_LIST_SIZE = 4;
|
||||
private static final int DEFAULT_SIZE_EXCEPTIONS_LIST = 2;
|
||||
private static final int DEFAULT_CONSTRUCTOR_CHAIN_LIST_SIZE = 4;
|
||||
|
||||
|
||||
/**
|
||||
* This is the standard cosntructor that we expect the Parser to be
|
||||
|
@ -1725,6 +1727,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
supportMinAndMaxOperators = config.supportMinAndMaxOperators();
|
||||
supportRestrict = config.supportRestrictKeyword();
|
||||
supportComplex = config.supportComplexNumbers();
|
||||
supportLongLong = config.supportLongLongs();
|
||||
}
|
||||
|
||||
|
||||
|
@ -2739,7 +2742,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
|
||||
boolean isInline= false, isVirtual= false, isExplicit= false, isFriend= false;
|
||||
boolean isConst = false, isVolatile= false, isRestrict= false;
|
||||
boolean isLong= false, isShort= false, isUnsigned= false, isSigned= false;
|
||||
boolean isLong= false, isShort= false, isUnsigned= false, isSigned= false, isLongLong = false;
|
||||
boolean isTypename= false;
|
||||
|
||||
int storageClass = IASTDeclSpecifier.sc_unspecified;
|
||||
|
@ -2824,7 +2827,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
consume();
|
||||
break;
|
||||
case IToken.t_long:
|
||||
isLong = true;
|
||||
if( isLong && supportLongLong )
|
||||
{
|
||||
isLong = false;
|
||||
isLongLong = true;
|
||||
}
|
||||
else
|
||||
isLong = true;
|
||||
flags.setEncounteredRawType(true);
|
||||
consume();
|
||||
break;
|
||||
|
@ -2998,7 +3007,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
nameSpec.setExplicit( isExplicit );
|
||||
return nameSpec;
|
||||
}
|
||||
ICPPASTSimpleDeclSpecifier simpleDeclSpec = createSimpleDeclSpecifier();
|
||||
ICPPASTSimpleDeclSpecifier simpleDeclSpec = null;
|
||||
if( isLongLong )
|
||||
{
|
||||
simpleDeclSpec = createGPPSimpleDeclSpecifier();
|
||||
((IGPPASTSimpleDeclSpecifier)simpleDeclSpec).setLongLong( isLongLong );
|
||||
}
|
||||
else
|
||||
simpleDeclSpec = createSimpleDeclSpecifier();
|
||||
((ASTNode)simpleDeclSpec).setOffset( firstToken.getOffset() );
|
||||
simpleDeclSpec.setConst( isConst );
|
||||
simpleDeclSpec.setVolatile( isVolatile );
|
||||
|
@ -3020,6 +3036,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
return simpleDeclSpec;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
private ICPPASTSimpleDeclSpecifier createGPPSimpleDeclSpecifier() {
|
||||
return new GPPASTSimpleDeclSpecifier();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
|
|
|
@ -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.gnu.cpp.IGPPASTSimpleDeclSpecifier;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class GPPASTSimpleDeclSpecifier extends CPPASTSimpleDeclSpecifier
|
||||
implements IGPPASTSimpleDeclSpecifier {
|
||||
|
||||
private boolean longLong;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier#isLongLong()
|
||||
*/
|
||||
public boolean isLongLong() {
|
||||
return longLong;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier#setLongLong(boolean)
|
||||
*/
|
||||
public void setLongLong(boolean value) {
|
||||
longLong = value;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTDeclSpecifier#isRestrict()
|
||||
*/
|
||||
public boolean isRestrict() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTDeclSpecifier#setRestrict(boolean)
|
||||
*/
|
||||
public void setRestrict(boolean value) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -27,5 +27,6 @@ public interface ICPPParserExtensionConfiguration {
|
|||
public boolean supportStatementsInExpressions();
|
||||
public boolean supportComplexNumbers();
|
||||
public boolean supportRestrictKeyword();
|
||||
public boolean supportLongLongs();
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue