1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 18:56:02 +02:00

Some minor fixes to the parser to get constructors/destructors working.

This commit is contained in:
Doug Schaefer 2003-03-06 19:46:28 +00:00
parent 40b44d0371
commit 3ab24c5b3d
3 changed files with 34 additions and 11 deletions

View file

@ -120,7 +120,6 @@ public class NewModelBuilder implements IParserCallback {
elem.setPos(offset, macroName.length());
((TranslationUnit)translationUnit.getElement()).addChild(elem);
}
private int startPos;
@ -150,7 +149,6 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
((TranslationUnit)translationUnit.getElement()).addChild(elem);
elem.setIdPos(offset, includeFile.length());
elem.setPos(offset, includeFile.length());
}
/**

View file

@ -78,6 +78,10 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements Declarati
List clause =currentDeclarator.getParameterDeclarationClause();
if( clause == null )
{
// TODO - this was to get rid of the NULL pointer we've been seeing
if (currentDeclarator.getName() == null)
return;
// this is an attribute or a varaible
if( parentElement instanceof IStructure )
{
@ -85,9 +89,6 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements Declarati
}
else if( parentElement instanceof ITranslationUnit )
{
// TODO - this was to get rid of the NULL pointer we've been seeing
if (currentDeclarator.getName() == null)
return;
declaration = new Variable( parentElement, currentDeclarator.getName().toString() );
}
}

View file

@ -78,10 +78,10 @@ c, quick);
public void translationUnit() throws Exception {
Object translationUnit = callback.translationUnitBegin();
Token lastBacktrack = null;
Token lastToken = null;
Token lastToken = null;
while (LT(1) != Token.tEOF) {
try {
lastToken = currToken;
lastToken = currToken;
declaration( translationUnit );
if( currToken == lastToken )
skipToNextSemi();
@ -295,6 +295,8 @@ c, quick);
case Token.t_friend:
case Token.t_const:
case Token.t_volatile:
callback.simpleDeclSpecifier(decl, consume());
break;
case Token.t_char:
case Token.t_wchar_t:
case Token.t_bool:
@ -317,7 +319,8 @@ c, quick);
consume();
// handle nested later:
case Token.tIDENTIFIER:
if( ! encounteredRawType )
// TODO - Kludgy way to handle constructors/destructors
if (!encounteredRawType && LT(2) != Token.tCOLONCOLON && LT(2) != Token.tLPAREN)
{
// handle nested later:
if( ! encounteredTypename )
@ -367,9 +370,11 @@ c, quick);
last = consume();
// TODO - whacky way to deal with destructors, please revisit
if (LT(1) == Token.tCOMPL)
consume();
switch (LT(1)) {
case Token.tIDENTIFIER:
case Token.tCOMPL:
last = consume();
break;
default:
@ -379,9 +384,11 @@ c, quick);
while (LT(1) == Token.tCOLONCOLON) {
last = consume();
if (LT(1) == Token.tCOMPL)
consume();
switch (LT(1)) {
case Token.tIDENTIFIER:
case Token.tCOMPL:
last = consume();
}
}
@ -430,6 +437,16 @@ c, quick);
// doNothing
}
// assignmentExpression || { initializerList , } || { }
try
{
assignmentExpression();
}
catch( Backtrack b )
{
// doNothing
}
if (LT(1) == Token.tLBRACE) {
// for now, just consume to matching brace
consume();
@ -448,6 +465,9 @@ c, quick);
}
}
}
else
{
}
}
callback.declaratorEnd( declarator );
@ -550,7 +570,7 @@ c, quick);
Token mark = mark();
if (t == Token.tIDENTIFIER || t == Token.tCOLONCOLON)
name();
name();
if (t == Token.tSTAR) {
consume();
@ -610,6 +630,8 @@ c, quick);
memberDeclarationLoop:
while (LT(1) != Token.tRBRACE) {
Token lastToken = currToken;
switch (LT(1)) {
case Token.t_public:
consume();
@ -629,6 +651,8 @@ c, quick);
default:
declaration(classSpec);
}
if (lastToken == currToken)
skipToNextSemi();
}
// consume the }
consume();