mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-28 11:25:35 +02:00
Some minor fixes to the parser to get constructors/destructors working.
This commit is contained in:
parent
40b44d0371
commit
3ab24c5b3d
3 changed files with 34 additions and 11 deletions
|
@ -120,7 +120,6 @@ public class NewModelBuilder implements IParserCallback {
|
||||||
elem.setPos(offset, macroName.length());
|
elem.setPos(offset, macroName.length());
|
||||||
|
|
||||||
((TranslationUnit)translationUnit.getElement()).addChild(elem);
|
((TranslationUnit)translationUnit.getElement()).addChild(elem);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int startPos;
|
private int startPos;
|
||||||
|
@ -150,7 +149,6 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
|
||||||
((TranslationUnit)translationUnit.getElement()).addChild(elem);
|
((TranslationUnit)translationUnit.getElement()).addChild(elem);
|
||||||
elem.setIdPos(offset, includeFile.length());
|
elem.setIdPos(offset, includeFile.length());
|
||||||
elem.setPos(offset, includeFile.length());
|
elem.setPos(offset, includeFile.length());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -78,6 +78,10 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements Declarati
|
||||||
List clause =currentDeclarator.getParameterDeclarationClause();
|
List clause =currentDeclarator.getParameterDeclarationClause();
|
||||||
if( clause == null )
|
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
|
// this is an attribute or a varaible
|
||||||
if( parentElement instanceof IStructure )
|
if( parentElement instanceof IStructure )
|
||||||
{
|
{
|
||||||
|
@ -85,9 +89,6 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements Declarati
|
||||||
}
|
}
|
||||||
else if( parentElement instanceof ITranslationUnit )
|
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() );
|
declaration = new Variable( parentElement, currentDeclarator.getName().toString() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,10 +78,10 @@ c, quick);
|
||||||
public void translationUnit() throws Exception {
|
public void translationUnit() throws Exception {
|
||||||
Object translationUnit = callback.translationUnitBegin();
|
Object translationUnit = callback.translationUnitBegin();
|
||||||
Token lastBacktrack = null;
|
Token lastBacktrack = null;
|
||||||
Token lastToken = null;
|
Token lastToken = null;
|
||||||
while (LT(1) != Token.tEOF) {
|
while (LT(1) != Token.tEOF) {
|
||||||
try {
|
try {
|
||||||
lastToken = currToken;
|
lastToken = currToken;
|
||||||
declaration( translationUnit );
|
declaration( translationUnit );
|
||||||
if( currToken == lastToken )
|
if( currToken == lastToken )
|
||||||
skipToNextSemi();
|
skipToNextSemi();
|
||||||
|
@ -295,6 +295,8 @@ c, quick);
|
||||||
case Token.t_friend:
|
case Token.t_friend:
|
||||||
case Token.t_const:
|
case Token.t_const:
|
||||||
case Token.t_volatile:
|
case Token.t_volatile:
|
||||||
|
callback.simpleDeclSpecifier(decl, consume());
|
||||||
|
break;
|
||||||
case Token.t_char:
|
case Token.t_char:
|
||||||
case Token.t_wchar_t:
|
case Token.t_wchar_t:
|
||||||
case Token.t_bool:
|
case Token.t_bool:
|
||||||
|
@ -317,7 +319,8 @@ c, quick);
|
||||||
consume();
|
consume();
|
||||||
// handle nested later:
|
// handle nested later:
|
||||||
case Token.tIDENTIFIER:
|
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:
|
// handle nested later:
|
||||||
if( ! encounteredTypename )
|
if( ! encounteredTypename )
|
||||||
|
@ -367,9 +370,11 @@ c, quick);
|
||||||
last = consume();
|
last = consume();
|
||||||
|
|
||||||
// TODO - whacky way to deal with destructors, please revisit
|
// TODO - whacky way to deal with destructors, please revisit
|
||||||
|
if (LT(1) == Token.tCOMPL)
|
||||||
|
consume();
|
||||||
|
|
||||||
switch (LT(1)) {
|
switch (LT(1)) {
|
||||||
case Token.tIDENTIFIER:
|
case Token.tIDENTIFIER:
|
||||||
case Token.tCOMPL:
|
|
||||||
last = consume();
|
last = consume();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -379,9 +384,11 @@ c, quick);
|
||||||
while (LT(1) == Token.tCOLONCOLON) {
|
while (LT(1) == Token.tCOLONCOLON) {
|
||||||
last = consume();
|
last = consume();
|
||||||
|
|
||||||
|
if (LT(1) == Token.tCOMPL)
|
||||||
|
consume();
|
||||||
|
|
||||||
switch (LT(1)) {
|
switch (LT(1)) {
|
||||||
case Token.tIDENTIFIER:
|
case Token.tIDENTIFIER:
|
||||||
case Token.tCOMPL:
|
|
||||||
last = consume();
|
last = consume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -430,6 +437,16 @@ c, quick);
|
||||||
// doNothing
|
// doNothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// assignmentExpression || { initializerList , } || { }
|
||||||
|
try
|
||||||
|
{
|
||||||
|
assignmentExpression();
|
||||||
|
}
|
||||||
|
catch( Backtrack b )
|
||||||
|
{
|
||||||
|
// doNothing
|
||||||
|
}
|
||||||
|
|
||||||
if (LT(1) == Token.tLBRACE) {
|
if (LT(1) == Token.tLBRACE) {
|
||||||
// for now, just consume to matching brace
|
// for now, just consume to matching brace
|
||||||
consume();
|
consume();
|
||||||
|
@ -448,6 +465,9 @@ c, quick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
callback.declaratorEnd( declarator );
|
callback.declaratorEnd( declarator );
|
||||||
|
@ -550,7 +570,7 @@ c, quick);
|
||||||
|
|
||||||
Token mark = mark();
|
Token mark = mark();
|
||||||
if (t == Token.tIDENTIFIER || t == Token.tCOLONCOLON)
|
if (t == Token.tIDENTIFIER || t == Token.tCOLONCOLON)
|
||||||
name();
|
name();
|
||||||
|
|
||||||
if (t == Token.tSTAR) {
|
if (t == Token.tSTAR) {
|
||||||
consume();
|
consume();
|
||||||
|
@ -610,6 +630,8 @@ c, quick);
|
||||||
|
|
||||||
memberDeclarationLoop:
|
memberDeclarationLoop:
|
||||||
while (LT(1) != Token.tRBRACE) {
|
while (LT(1) != Token.tRBRACE) {
|
||||||
|
Token lastToken = currToken;
|
||||||
|
|
||||||
switch (LT(1)) {
|
switch (LT(1)) {
|
||||||
case Token.t_public:
|
case Token.t_public:
|
||||||
consume();
|
consume();
|
||||||
|
@ -629,6 +651,8 @@ c, quick);
|
||||||
default:
|
default:
|
||||||
declaration(classSpec);
|
declaration(classSpec);
|
||||||
}
|
}
|
||||||
|
if (lastToken == currToken)
|
||||||
|
skipToNextSemi();
|
||||||
}
|
}
|
||||||
// consume the }
|
// consume the }
|
||||||
consume();
|
consume();
|
||||||
|
|
Loading…
Add table
Reference in a new issue