1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Only 3 QuickParse2Tests failing.

This commit is contained in:
John Camelon 2004-11-23 20:42:55 +00:00
parent dbc642b6b4
commit 0069e2dae3
5 changed files with 84 additions and 24 deletions

View file

@ -407,6 +407,7 @@ public class QuickParser2Tests extends TestCase {
} }
public void testBug36766and36769C() throws Exception { public void testBug36766and36769C() throws Exception {
//TODO - requires CPPVisitor
Writer code = new StringWriter(); Writer code = new StringWriter();
code.write("template <class _CharT, class _Alloc>\n"); //$NON-NLS-1$ code.write("template <class _CharT, class _Alloc>\n"); //$NON-NLS-1$
code.write("_Rope_char_ref_proxy<_CharT, _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 { public void testBug36766and36769D() throws Exception {
//TODO - requires CPPVisitor
Writer code = new StringWriter(); Writer code = new StringWriter();
code.write("template <class _CharT, class _Alloc>\n"); //$NON-NLS-1$ code.write("template <class _CharT, class _Alloc>\n"); //$NON-NLS-1$
code.write("rope<_CharT, _Alloc>::~rope()\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 { 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$ 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_GET \"g\"\n"); //$NON-NLS-1$
code.write("#define CMD_ACTION \"a\"\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("#define CMD_QUIT \"q\"\n"); //$NON-NLS-1$
code code.write("static const memevent_cmd_func memevent_cmd_funcs[sizeof memevent_cmds - 1] = {\n"); //$NON-NLS-1$
.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_get,\n"); //$NON-NLS-1$
code.write("memevent_action,\n"); //$NON-NLS-1$ code.write("memevent_action,\n"); //$NON-NLS-1$
code.write("memevent_quit,\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 { public void testOrder() throws Exception {
//TODO - requires CPPVisitor
Writer code = new StringWriter(); Writer code = new StringWriter();
code.write("#define __SGI_STL_INTERNAL_ALGOBASE_H\n"); //$NON-NLS-1$ code.write("#define __SGI_STL_INTERNAL_ALGOBASE_H\n"); //$NON-NLS-1$
code.write("#include <string.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 { public void testBug47752() throws Exception {
//TODO requires CPPVisitor
parse("void func( cFoo bar ) try { } catch ( const char * error ){ }"); //$NON-NLS-1$ parse("void func( cFoo bar ) try { } catch ( const char * error ){ }"); //$NON-NLS-1$
} }

View file

@ -10,6 +10,8 @@
**********************************************************************/ **********************************************************************/
package org.eclipse.cdt.core.dom.ast.gnu.cpp; 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; 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_Complex = ICPPASTSimpleDeclSpecifier.t_last + 1;
public static final int t_Imaginary = ICPPASTSimpleDeclSpecifier.t_last + 2; 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 boolean isLongLong();
public void setLongLong( boolean value ); public void setLongLong( boolean value );
/**
* @param typeofExpression
*/
public void setTypeofExpression(IASTExpression typeofExpression);
public IASTExpression getTypeofExpression();
} }

View file

@ -516,15 +516,13 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
protected abstract IASTCompoundStatement createCompoundStatement(); protected abstract IASTCompoundStatement createCompoundStatement();
/** /**
* @param la
* @return @throws * @return @throws
* EndOfFileException * EndOfFileException
* @throws BacktrackException * @throws BacktrackException
*/ */
protected IASTExpression compoundStatementExpression(IToken la) protected IASTExpression compoundStatementExpression()
throws EndOfFileException, BacktrackException { throws EndOfFileException, BacktrackException {
int startingOffset = la.getOffset(); int startingOffset =consume(IToken.tLPAREN).getOffset();
consume(IToken.tLPAREN);
IASTCompoundStatement compoundStatement = null; IASTCompoundStatement compoundStatement = null;
if (mode == ParserMode.QUICK_PARSE if (mode == ParserMode.QUICK_PARSE
|| mode == ParserMode.STRUCTURAL_PARSE) || mode == ParserMode.STRUCTURAL_PARSE)
@ -564,7 +562,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
if (la.getType() == IToken.tLPAREN && LT(2) == IToken.tLBRACE if (la.getType() == IToken.tLPAREN && LT(2) == IToken.tLBRACE
&& supportStatementsInExpressions) { && supportStatementsInExpressions) {
IASTExpression resultExpression = compoundStatementExpression(la); IASTExpression resultExpression = compoundStatementExpression();
if (resultExpression != null) if (resultExpression != null)
return resultExpression; return resultExpression;
} }
@ -918,15 +916,20 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
IToken m = mark(); IToken m = mark();
if (LT(1) == IToken.tLPAREN) { if (LT(1) == IToken.tLPAREN) {
try { if( LT(2) == IToken.tLBRACE )
consume(IToken.tLPAREN); {
d = typeId(false); unaryExpression = compoundStatementExpression();
consume(IToken.tRPAREN);
} catch (BacktrackException bt) {
backup(m);
d = null;
unaryExpression = unaryExpression();
} }
else
try {
consume(IToken.tLPAREN);
d = typeId(false);
consume(IToken.tRPAREN);
} catch (BacktrackException bt) {
backup(m);
d = null;
unaryExpression = unaryExpression();
}
} else { } else {
unaryExpression = unaryExpression(); unaryExpression = unaryExpression();
} }

View file

@ -621,6 +621,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (LT(1) == IToken.t_throw) { if (LT(1) == IToken.t_throw) {
return throwExpression(); return throwExpression();
} }
if (LT(1) == IToken.tLPAREN && LT(2) == IToken.tLBRACE
&& supportStatementsInExpressions) {
IASTExpression resultExpression = compoundStatementExpression();
if (resultExpression != null)
return resultExpression;
}
IASTExpression conditionalExpression = conditionalExpression(); IASTExpression conditionalExpression = conditionalExpression();
// if the condition not taken, try assignment operators // if the condition not taken, try assignment operators
@ -2707,6 +2715,12 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
backup(mark); backup(mark);
return true; return true;
} }
char [] destructorName = CharArrayUtils.concat( "~".toCharArray(), otherName ); //$NON-NLS-1$
if( CharArrayUtils.equals( destructorName, className ))
{
backup( mark );
return true;
}
backup(mark); backup(mark);
return false; return false;
@ -2752,6 +2766,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
ICPPASTCompositeTypeSpecifier classSpec = null; ICPPASTCompositeTypeSpecifier classSpec = null;
ICPPASTElaboratedTypeSpecifier elabSpec = null; ICPPASTElaboratedTypeSpecifier elabSpec = null;
IASTEnumerationSpecifier enumSpec = null; IASTEnumerationSpecifier enumSpec = null;
IASTExpression typeofExpression = null;
declSpecifiers: for (;;) { declSpecifiers: for (;;) {
switch (LT(1)) { switch (LT(1)) {
case IToken.t_inline: case IToken.t_inline:
@ -2939,8 +2954,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
} }
default: default:
if (supportTypeOfUnaries && LT(1) == IGCCToken.t_typeof) { if (supportTypeOfUnaries && LT(1) == IGCCToken.t_typeof) {
Object expression = unaryTypeofExpression(); typeofExpression = unaryTypeofExpression();
if (expression != null) { if (typeofExpression != null) {
flags.setEncounteredTypename(true); flags.setEncounteredTypename(true);
} }
} }
@ -3008,10 +3023,16 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
return nameSpec; return nameSpec;
} }
ICPPASTSimpleDeclSpecifier simpleDeclSpec = null; ICPPASTSimpleDeclSpecifier simpleDeclSpec = null;
if( isLongLong ) if( isLongLong || typeofExpression != null )
{ {
simpleDeclSpec = createGPPSimpleDeclSpecifier(); simpleDeclSpec = createGPPSimpleDeclSpecifier();
((IGPPASTSimpleDeclSpecifier)simpleDeclSpec).setLongLong( isLongLong ); ((IGPPASTSimpleDeclSpecifier)simpleDeclSpec).setLongLong( isLongLong );
if( typeofExpression != null )
{
((IGPPASTSimpleDeclSpecifier)simpleDeclSpec).setTypeofExpression( typeofExpression );
typeofExpression.setParent( simpleDeclSpec );
typeofExpression.setPropertyInParent( IGPPASTSimpleDeclSpecifier.TYPEOF_EXPRESSION );
}
} }
else else
simpleDeclSpec = createSimpleDeclSpecifier(); simpleDeclSpec = createSimpleDeclSpecifier();
@ -3192,6 +3213,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
for (;;) { for (;;) {
if (LT(1) == IToken.tRBRACE)
break;
IASTInitializer clause = initializerClause( ); IASTInitializer clause = initializerClause( );
if (clause != null) { if (clause != null) {
result.addInitializer( clause ); result.addInitializer( clause );
@ -3321,7 +3345,11 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
try { try {
try { try {
queryName = name(); 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) { } catch (Exception e) {
int endOffset = (lastToken != null) ? lastToken int endOffset = (lastToken != null) ? lastToken
.getEndOffset() .getEndOffset()

View file

@ -10,6 +10,7 @@
**********************************************************************/ **********************************************************************/
package org.eclipse.cdt.internal.core.parser2.cpp; 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; import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
/** /**
@ -19,6 +20,8 @@ public class GPPASTSimpleDeclSpecifier extends CPPASTSimpleDeclSpecifier
implements IGPPASTSimpleDeclSpecifier { implements IGPPASTSimpleDeclSpecifier {
private boolean longLong; private boolean longLong;
private boolean restrict;
private IASTExpression typeOfExpression;
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier#isLongLong() * @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() * @see org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTDeclSpecifier#isRestrict()
*/ */
public boolean isRestrict() { public boolean isRestrict() {
// TODO Auto-generated method stub return restrict;
return false;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTDeclSpecifier#setRestrict(boolean) * @see org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTDeclSpecifier#setRestrict(boolean)
*/ */
public void setRestrict(boolean value) { 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;
} }
} }