mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Only 3 QuickParse2Tests failing.
This commit is contained in:
parent
dbc642b6b4
commit
0069e2dae3
5 changed files with 84 additions and 24 deletions
|
@ -407,6 +407,7 @@ public class QuickParser2Tests extends TestCase {
|
|||
}
|
||||
|
||||
public void testBug36766and36769C() throws Exception {
|
||||
//TODO - requires CPPVisitor
|
||||
Writer code = new StringWriter();
|
||||
code.write("template <class _CharT, class _Alloc>\n"); //$NON-NLS-1$
|
||||
code.write("_Rope_char_ref_proxy<_CharT, _Alloc>&\n"); //$NON-NLS-1$
|
||||
|
@ -417,6 +418,7 @@ public class QuickParser2Tests extends TestCase {
|
|||
}
|
||||
|
||||
public void testBug36766and36769D() throws Exception {
|
||||
//TODO - requires CPPVisitor
|
||||
Writer code = new StringWriter();
|
||||
code.write("template <class _CharT, class _Alloc>\n"); //$NON-NLS-1$
|
||||
code.write("rope<_CharT, _Alloc>::~rope()\n"); //$NON-NLS-1$
|
||||
|
@ -750,6 +752,7 @@ public class QuickParser2Tests extends TestCase {
|
|||
}
|
||||
|
||||
public void testConstructorChain() throws Exception {
|
||||
//TODO - requires CPPVisitor in order to reduce ambiguities
|
||||
parse( "TrafficLight_Actor::TrafficLight_Actor( RTController * rtg_rts, RTActorRef * rtg_ref ) : RTActor( rtg_rts, rtg_ref ), myId( 0 ) {}"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
@ -809,8 +812,7 @@ public class QuickParser2Tests extends TestCase {
|
|||
code.write("#define CMD_GET \"g\"\n"); //$NON-NLS-1$
|
||||
code.write("#define CMD_ACTION \"a\"\n"); //$NON-NLS-1$
|
||||
code.write("#define CMD_QUIT \"q\"\n"); //$NON-NLS-1$
|
||||
code
|
||||
.write("static const memevent_cmd_func memevent_cmd_funcs[sizeof memevent_cmds - 1] = {\n"); //$NON-NLS-1$
|
||||
code.write("static const memevent_cmd_func memevent_cmd_funcs[sizeof memevent_cmds - 1] = {\n"); //$NON-NLS-1$
|
||||
code.write("memevent_get,\n"); //$NON-NLS-1$
|
||||
code.write("memevent_action,\n"); //$NON-NLS-1$
|
||||
code.write("memevent_quit,\n"); //$NON-NLS-1$
|
||||
|
@ -835,6 +837,7 @@ public class QuickParser2Tests extends TestCase {
|
|||
}
|
||||
|
||||
public void testOrder() throws Exception {
|
||||
//TODO - requires CPPVisitor
|
||||
Writer code = new StringWriter();
|
||||
code.write("#define __SGI_STL_INTERNAL_ALGOBASE_H\n"); //$NON-NLS-1$
|
||||
code.write("#include <string.h>\n"); //$NON-NLS-1$
|
||||
|
@ -1343,6 +1346,7 @@ public class QuickParser2Tests extends TestCase {
|
|||
// }
|
||||
|
||||
public void testBug47752() throws Exception {
|
||||
//TODO requires CPPVisitor
|
||||
parse("void func( cFoo bar ) try { } catch ( const char * error ){ }"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.gnu.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
|
||||
|
||||
/**
|
||||
|
@ -20,9 +22,17 @@ 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 static final int t_typeof = ICPPASTSimpleDeclSpecifier.t_last + 3;
|
||||
public static final int t_last = t_typeof;
|
||||
|
||||
public static final ASTNodeProperty TYPEOF_EXPRESSION = new ASTNodeProperty( "Typeof Expression"); //$NON-NLS-1$
|
||||
|
||||
public boolean isLongLong();
|
||||
public void setLongLong( boolean value );
|
||||
/**
|
||||
* @param typeofExpression
|
||||
*/
|
||||
public void setTypeofExpression(IASTExpression typeofExpression);
|
||||
public IASTExpression getTypeofExpression();
|
||||
|
||||
}
|
||||
|
|
|
@ -516,15 +516,13 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
protected abstract IASTCompoundStatement createCompoundStatement();
|
||||
|
||||
/**
|
||||
* @param la
|
||||
* @return @throws
|
||||
* EndOfFileException
|
||||
* @throws BacktrackException
|
||||
*/
|
||||
protected IASTExpression compoundStatementExpression(IToken la)
|
||||
protected IASTExpression compoundStatementExpression()
|
||||
throws EndOfFileException, BacktrackException {
|
||||
int startingOffset = la.getOffset();
|
||||
consume(IToken.tLPAREN);
|
||||
int startingOffset =consume(IToken.tLPAREN).getOffset();
|
||||
IASTCompoundStatement compoundStatement = null;
|
||||
if (mode == ParserMode.QUICK_PARSE
|
||||
|| mode == ParserMode.STRUCTURAL_PARSE)
|
||||
|
@ -564,7 +562,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
|
||||
if (la.getType() == IToken.tLPAREN && LT(2) == IToken.tLBRACE
|
||||
&& supportStatementsInExpressions) {
|
||||
IASTExpression resultExpression = compoundStatementExpression(la);
|
||||
IASTExpression resultExpression = compoundStatementExpression();
|
||||
if (resultExpression != null)
|
||||
return resultExpression;
|
||||
}
|
||||
|
@ -918,15 +916,20 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
|
||||
IToken m = mark();
|
||||
if (LT(1) == IToken.tLPAREN) {
|
||||
try {
|
||||
consume(IToken.tLPAREN);
|
||||
d = typeId(false);
|
||||
consume(IToken.tRPAREN);
|
||||
} catch (BacktrackException bt) {
|
||||
backup(m);
|
||||
d = null;
|
||||
unaryExpression = unaryExpression();
|
||||
if( LT(2) == IToken.tLBRACE )
|
||||
{
|
||||
unaryExpression = compoundStatementExpression();
|
||||
}
|
||||
else
|
||||
try {
|
||||
consume(IToken.tLPAREN);
|
||||
d = typeId(false);
|
||||
consume(IToken.tRPAREN);
|
||||
} catch (BacktrackException bt) {
|
||||
backup(m);
|
||||
d = null;
|
||||
unaryExpression = unaryExpression();
|
||||
}
|
||||
} else {
|
||||
unaryExpression = unaryExpression();
|
||||
}
|
||||
|
|
|
@ -621,6 +621,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
if (LT(1) == IToken.t_throw) {
|
||||
return throwExpression();
|
||||
}
|
||||
|
||||
if (LT(1) == IToken.tLPAREN && LT(2) == IToken.tLBRACE
|
||||
&& supportStatementsInExpressions) {
|
||||
IASTExpression resultExpression = compoundStatementExpression();
|
||||
if (resultExpression != null)
|
||||
return resultExpression;
|
||||
}
|
||||
|
||||
|
||||
IASTExpression conditionalExpression = conditionalExpression();
|
||||
// if the condition not taken, try assignment operators
|
||||
|
@ -2707,6 +2715,12 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
backup(mark);
|
||||
return true;
|
||||
}
|
||||
char [] destructorName = CharArrayUtils.concat( "~".toCharArray(), otherName ); //$NON-NLS-1$
|
||||
if( CharArrayUtils.equals( destructorName, className ))
|
||||
{
|
||||
backup( mark );
|
||||
return true;
|
||||
}
|
||||
|
||||
backup(mark);
|
||||
return false;
|
||||
|
@ -2752,6 +2766,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
ICPPASTCompositeTypeSpecifier classSpec = null;
|
||||
ICPPASTElaboratedTypeSpecifier elabSpec = null;
|
||||
IASTEnumerationSpecifier enumSpec = null;
|
||||
IASTExpression typeofExpression = null;
|
||||
declSpecifiers: for (;;) {
|
||||
switch (LT(1)) {
|
||||
case IToken.t_inline:
|
||||
|
@ -2939,8 +2954,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
}
|
||||
default:
|
||||
if (supportTypeOfUnaries && LT(1) == IGCCToken.t_typeof) {
|
||||
Object expression = unaryTypeofExpression();
|
||||
if (expression != null) {
|
||||
typeofExpression = unaryTypeofExpression();
|
||||
if (typeofExpression != null) {
|
||||
flags.setEncounteredTypename(true);
|
||||
}
|
||||
}
|
||||
|
@ -3008,10 +3023,16 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
return nameSpec;
|
||||
}
|
||||
ICPPASTSimpleDeclSpecifier simpleDeclSpec = null;
|
||||
if( isLongLong )
|
||||
if( isLongLong || typeofExpression != null )
|
||||
{
|
||||
simpleDeclSpec = createGPPSimpleDeclSpecifier();
|
||||
((IGPPASTSimpleDeclSpecifier)simpleDeclSpec).setLongLong( isLongLong );
|
||||
if( typeofExpression != null )
|
||||
{
|
||||
((IGPPASTSimpleDeclSpecifier)simpleDeclSpec).setTypeofExpression( typeofExpression );
|
||||
typeofExpression.setParent( simpleDeclSpec );
|
||||
typeofExpression.setPropertyInParent( IGPPASTSimpleDeclSpecifier.TYPEOF_EXPRESSION );
|
||||
}
|
||||
}
|
||||
else
|
||||
simpleDeclSpec = createSimpleDeclSpecifier();
|
||||
|
@ -3192,6 +3213,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
|
||||
|
||||
for (;;) {
|
||||
if (LT(1) == IToken.tRBRACE)
|
||||
break;
|
||||
|
||||
IASTInitializer clause = initializerClause( );
|
||||
if (clause != null) {
|
||||
result.addInitializer( clause );
|
||||
|
@ -3321,7 +3345,11 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
try {
|
||||
try {
|
||||
queryName = name();
|
||||
failed = true;
|
||||
//TODO - when the Visitor is available
|
||||
//find the IASTName relating to this in the AST
|
||||
//if this is a type, failed = false
|
||||
//if this is a value, failed = true
|
||||
failed = false;
|
||||
} catch (Exception e) {
|
||||
int endOffset = (lastToken != null) ? lastToken
|
||||
.getEndOffset()
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser2.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
|
||||
|
||||
/**
|
||||
|
@ -19,6 +20,8 @@ public class GPPASTSimpleDeclSpecifier extends CPPASTSimpleDeclSpecifier
|
|||
implements IGPPASTSimpleDeclSpecifier {
|
||||
|
||||
private boolean longLong;
|
||||
private boolean restrict;
|
||||
private IASTExpression typeOfExpression;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier#isLongLong()
|
||||
|
@ -38,16 +41,28 @@ public class GPPASTSimpleDeclSpecifier extends CPPASTSimpleDeclSpecifier
|
|||
* @see org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTDeclSpecifier#isRestrict()
|
||||
*/
|
||||
public boolean isRestrict() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
return restrict;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTDeclSpecifier#setRestrict(boolean)
|
||||
*/
|
||||
public void setRestrict(boolean value) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
restrict = value;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier#setTypeofExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setTypeofExpression(IASTExpression typeofExpression) {
|
||||
typeOfExpression = typeofExpression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier#getTypeofExpression()
|
||||
*/
|
||||
public IASTExpression getTypeofExpression() {
|
||||
return typeOfExpression;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue