mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 08:46:02 +02:00
Separated C++ and C Physical Implementations to provide Andrew more flexibility.
Added ICPPASTTemplateId and implementation.
This commit is contained in:
parent
70c6412de3
commit
03de1e32fd
45 changed files with 2928 additions and 514 deletions
|
@ -29,6 +29,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
|
import org.eclipse.cdt.internal.core.parser2.IProblemRequestor;
|
||||||
import org.eclipse.cdt.internal.core.parser2.ISourceCodeParser;
|
import org.eclipse.cdt.internal.core.parser2.ISourceCodeParser;
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.ANSICParserExtensionConfiguration;
|
import org.eclipse.cdt.internal.core.parser2.c.ANSICParserExtensionConfiguration;
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.GCCParserExtensionConfiguration;
|
import org.eclipse.cdt.internal.core.parser2.c.GCCParserExtensionConfiguration;
|
||||||
|
@ -38,7 +39,6 @@ import org.eclipse.cdt.internal.core.parser2.cpp.ANSICPPParserExtensionConfigura
|
||||||
import org.eclipse.cdt.internal.core.parser2.cpp.GNUCPPParserExtensionConfiguration;
|
import org.eclipse.cdt.internal.core.parser2.cpp.GNUCPPParserExtensionConfiguration;
|
||||||
import org.eclipse.cdt.internal.core.parser2.cpp.GNUCPPSourceParser;
|
import org.eclipse.cdt.internal.core.parser2.cpp.GNUCPPSourceParser;
|
||||||
import org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration;
|
import org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration;
|
||||||
import org.eclipse.cdt.internal.core.parser2.cpp.IProblemRequestor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.core.dom.ast.cpp;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public interface ICPPASTTemplateId extends IASTName {
|
||||||
|
|
||||||
|
public static final ASTNodeProperty TEMPLATE_NAME = new ASTNodeProperty( "TemplateId Name"); //$NON-NLS-1$
|
||||||
|
public IASTName getTemplateName();
|
||||||
|
public void setTemplateName( IASTName name );
|
||||||
|
|
||||||
|
public static final ASTNodeProperty TEMPLATE_ID_ARGUMENT = new ASTNodeProperty( "TemplateId Arg"); //$NON-NLS-1$
|
||||||
|
public void addTemplateArgument( IASTTypeId typeId );
|
||||||
|
public void addTemplateArgument( IASTExpression expression );
|
||||||
|
public List getTemplateArguments();
|
||||||
|
|
||||||
|
}
|
|
@ -59,25 +59,6 @@ import org.eclipse.cdt.core.parser.ParseError;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserProblemFactory;
|
import org.eclipse.cdt.internal.core.parser.ParserProblemFactory;
|
||||||
import org.eclipse.cdt.internal.core.parser.problem.IProblemFactory;
|
import org.eclipse.cdt.internal.core.parser.problem.IProblemFactory;
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTASMDeclaration;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTBreakStatement;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTCaseStatement;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTCastExpression;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTContinueStatement;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTDeclarationStatement;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTDefaultStatement;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTDoStatement;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTEnumerationSpecifier;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTExpressionStatement;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTForStatement;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTGotoStatement;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTIfStatement;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTLabelStatement;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTNullStatement;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTReturnStatement;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTSwitchStatement;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTWhileStatement;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.cpp.IProblemRequestor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -757,6 +738,11 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected abstract IASTBinaryExpression createBinaryExpression();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param expression
|
* @param expression
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
|
@ -805,11 +791,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
protected abstract IASTBinaryExpression createBinaryExpression();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param expression
|
* @param expression
|
||||||
* @return @throws
|
* @return @throws
|
||||||
|
@ -1157,21 +1138,31 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract IASTStatement statement() throws EndOfFileException,
|
||||||
|
BacktrackException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected abstract IASTEnumerator createEnumerator();
|
protected abstract IASTEnumerator createEnumerator();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param token
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected abstract IASTName createName(IToken token);
|
protected abstract IASTEnumerationSpecifier createEnumerationSpecifier();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected abstract IASTName createName();
|
protected abstract IASTName createName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param token
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected abstract IASTName createName(IToken token);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
*/
|
*/
|
||||||
|
@ -1191,368 +1182,83 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* (non-Javadoc)
|
* @return
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.internal.core.parser2.GNUBaseParser#statement(java.lang.Object)
|
|
||||||
*/
|
*/
|
||||||
protected IASTStatement statement() throws EndOfFileException,
|
protected abstract IASTDeclarationStatement createDeclarationStatement();
|
||||||
BacktrackException {
|
|
||||||
|
|
||||||
switch (LT(1)) {
|
/**
|
||||||
// labeled statements
|
* @return
|
||||||
case IToken.t_case:
|
*/
|
||||||
int startOffset = consume(IToken.t_case).getOffset();
|
protected abstract IASTExpressionStatement createExpressionStatement();
|
||||||
IASTExpression case_exp = constantExpression();
|
|
||||||
consume(IToken.tCOLON);
|
|
||||||
cleanupLastToken();
|
|
||||||
IASTCaseStatement cs = createCaseStatement();
|
|
||||||
((ASTNode)cs).setOffset( startOffset );
|
|
||||||
cs.setExpression( case_exp );
|
|
||||||
case_exp.setParent( cs );
|
|
||||||
case_exp.setPropertyInParent( IASTCaseStatement.EXPRESSION );
|
|
||||||
return cs;
|
|
||||||
case IToken.t_default:
|
|
||||||
startOffset = consume(IToken.t_default).getOffset();
|
|
||||||
consume(IToken.tCOLON);
|
|
||||||
cleanupLastToken();
|
|
||||||
IASTDefaultStatement df = createDefaultStatement();
|
|
||||||
((ASTNode)df).setOffset( startOffset );
|
|
||||||
return df;
|
|
||||||
// compound statement
|
|
||||||
case IToken.tLBRACE:
|
|
||||||
IASTCompoundStatement compound = compoundStatement();
|
|
||||||
cleanupLastToken();
|
|
||||||
return compound;
|
|
||||||
// selection statement
|
|
||||||
case IToken.t_if:
|
|
||||||
startOffset = consume(IToken.t_if).getOffset();
|
|
||||||
consume(IToken.tLPAREN);
|
|
||||||
IASTExpression if_condition = condition();
|
|
||||||
consume(IToken.tRPAREN);
|
|
||||||
IASTStatement then_clause = statement();
|
|
||||||
IASTStatement else_clause = null;
|
|
||||||
if (LT(1) == IToken.t_else) {
|
|
||||||
consume(IToken.t_else);
|
|
||||||
else_clause = statement();
|
|
||||||
}
|
|
||||||
|
|
||||||
IASTIfStatement if_stmt = createIfStatement();
|
/**
|
||||||
if_stmt.setCondition( if_condition );
|
* @return
|
||||||
((ASTNode)if_stmt).setOffset( startOffset );
|
*/
|
||||||
if_condition.setParent( if_stmt );
|
protected abstract IASTLabelStatement createLabelStatement();
|
||||||
if_condition.setPropertyInParent( IASTIfStatement.CONDITION );
|
|
||||||
if_stmt.setThenClause( then_clause );
|
|
||||||
then_clause.setParent( if_stmt );
|
|
||||||
then_clause.setPropertyInParent( IASTIfStatement.THEN );
|
|
||||||
if( else_clause != null )
|
|
||||||
{
|
|
||||||
if_stmt.setElseClause( else_clause );
|
|
||||||
else_clause.setParent( if_stmt );
|
|
||||||
else_clause.setPropertyInParent( IASTIfStatement.ELSE );
|
|
||||||
}
|
|
||||||
cleanupLastToken();
|
|
||||||
return if_stmt;
|
|
||||||
case IToken.t_switch:
|
|
||||||
startOffset = consume( IToken.t_switch ).getOffset();
|
|
||||||
consume(IToken.tLPAREN);
|
|
||||||
IASTExpression switch_condition = condition();
|
|
||||||
consume(IToken.tRPAREN);
|
|
||||||
IASTStatement switch_body = statement();
|
|
||||||
cleanupLastToken();
|
|
||||||
IASTSwitchStatement switch_statement = createSwitchStatement();
|
|
||||||
((ASTNode)switch_statement).setOffset( startOffset );
|
|
||||||
switch_statement.setController( switch_condition );
|
|
||||||
switch_condition.setParent( switch_statement );
|
|
||||||
switch_condition.setPropertyInParent( IASTSwitchStatement.CONTROLLER );
|
|
||||||
switch_statement.setBody( switch_body );
|
|
||||||
switch_body.setParent( switch_statement );
|
|
||||||
switch_body.setPropertyInParent( IASTSwitchStatement.BODY );
|
|
||||||
return switch_statement;
|
|
||||||
//iteration statements
|
|
||||||
case IToken.t_while:
|
|
||||||
startOffset = consume(IToken.t_while).getOffset();
|
|
||||||
consume(IToken.tLPAREN);
|
|
||||||
IASTExpression while_condition = condition();
|
|
||||||
consume(IToken.tRPAREN);
|
|
||||||
IASTStatement while_body = statement();
|
|
||||||
cleanupLastToken();
|
|
||||||
IASTWhileStatement while_statement = createWhileStatement();
|
|
||||||
((ASTNode)while_statement).setOffset( startOffset );
|
|
||||||
while_statement.setCondition( while_condition );
|
|
||||||
while_condition.setParent( while_statement );
|
|
||||||
while_condition.setPropertyInParent( IASTWhileStatement.CONDITION );
|
|
||||||
while_statement.setBody( while_body );
|
|
||||||
while_condition.setParent( while_statement );
|
|
||||||
while_condition.setPropertyInParent( IASTWhileStatement.BODY );
|
|
||||||
while_body.setParent( while_statement );
|
|
||||||
return while_statement;
|
|
||||||
case IToken.t_do:
|
|
||||||
startOffset = consume(IToken.t_do).getOffset();
|
|
||||||
IASTStatement do_body = statement();
|
|
||||||
consume(IToken.t_while);
|
|
||||||
consume(IToken.tLPAREN);
|
|
||||||
IASTExpression do_condition = condition();
|
|
||||||
consume(IToken.tRPAREN);
|
|
||||||
cleanupLastToken();
|
|
||||||
IASTDoStatement do_statement = createDoStatement();
|
|
||||||
((ASTNode)do_statement).setOffset( startOffset );
|
|
||||||
do_statement.setBody( do_body );
|
|
||||||
do_body.setParent( do_statement );
|
|
||||||
do_body.setPropertyInParent( IASTDoStatement.BODY );
|
|
||||||
do_statement.setCondition( do_condition );
|
|
||||||
do_condition.setParent( do_statement );
|
|
||||||
do_condition.setPropertyInParent( IASTDoStatement.CONDITION );
|
|
||||||
return do_statement;
|
|
||||||
case IToken.t_for:
|
|
||||||
startOffset = consume( IToken.t_for ).getOffset();
|
|
||||||
consume(IToken.tLPAREN);
|
|
||||||
IASTNode init = forInitStatement();
|
|
||||||
IASTExpression for_condition = null;
|
|
||||||
if (LT(1) != IToken.tSEMI)
|
|
||||||
for_condition = condition();
|
|
||||||
consume(IToken.tSEMI);
|
|
||||||
IASTExpression iterationExpression = null;
|
|
||||||
if (LT(1) != IToken.tRPAREN) {
|
|
||||||
iterationExpression = expression();
|
|
||||||
cleanupLastToken();
|
|
||||||
}
|
|
||||||
consume(IToken.tRPAREN);
|
|
||||||
IASTStatement for_body = statement();
|
|
||||||
cleanupLastToken();
|
|
||||||
IASTForStatement for_statement = createForStatement();
|
|
||||||
((ASTNode)for_statement).setOffset( startOffset );
|
|
||||||
if( init instanceof IASTDeclaration )
|
|
||||||
{
|
|
||||||
for_statement.setInit((IASTDeclaration) init);
|
|
||||||
((IASTDeclaration) init).setParent( for_statement );
|
|
||||||
((IASTDeclaration) init).setPropertyInParent( IASTForStatement.INITDECLARATION );
|
|
||||||
}
|
|
||||||
else if( init instanceof IASTExpression )
|
|
||||||
{
|
|
||||||
for_statement.setInit((IASTExpression) init);
|
|
||||||
((IASTExpression) init).setParent( for_statement );
|
|
||||||
((IASTExpression) init).setPropertyInParent( IASTForStatement.INITEXPRESSION );
|
|
||||||
}
|
|
||||||
if( for_condition != null )
|
|
||||||
{
|
|
||||||
for_statement.setCondition( for_condition );
|
|
||||||
for_condition.setParent( for_statement );
|
|
||||||
for_condition.setPropertyInParent( IASTForStatement.CONDITION );
|
|
||||||
}
|
|
||||||
if( iterationExpression != null )
|
|
||||||
{
|
|
||||||
for_statement.setIterationExpression( iterationExpression );
|
|
||||||
iterationExpression.setParent( for_statement );
|
|
||||||
iterationExpression.setPropertyInParent( IASTForStatement.ITERATION );
|
|
||||||
}
|
|
||||||
for_statement.setBody( for_body );
|
|
||||||
for_body.setParent( for_statement );
|
|
||||||
for_body.setPropertyInParent( IASTForStatement.BODY );
|
|
||||||
return for_statement;
|
|
||||||
//jump statement
|
|
||||||
case IToken.t_break:
|
|
||||||
startOffset = consume(IToken.t_break).getOffset();
|
|
||||||
consume(IToken.tSEMI);
|
|
||||||
cleanupLastToken();
|
|
||||||
IASTBreakStatement break_statement = createBreakStatement();
|
|
||||||
((ASTNode)break_statement).setOffset( startOffset );
|
|
||||||
return break_statement;
|
|
||||||
case IToken.t_continue:
|
|
||||||
startOffset = consume(IToken.t_continue).getOffset();
|
|
||||||
consume(IToken.tSEMI);
|
|
||||||
cleanupLastToken();
|
|
||||||
IASTContinueStatement continue_statement = createContinueStatement();
|
|
||||||
((ASTNode)continue_statement).setOffset( startOffset );
|
|
||||||
return continue_statement;
|
|
||||||
case IToken.t_return:
|
|
||||||
startOffset = consume(IToken.t_return).getOffset();
|
|
||||||
IASTExpression result = null;
|
|
||||||
if (LT(1) != IToken.tSEMI) {
|
|
||||||
result = expression();
|
|
||||||
cleanupLastToken();
|
|
||||||
}
|
|
||||||
consume(IToken.tSEMI);
|
|
||||||
cleanupLastToken();
|
|
||||||
IASTReturnStatement return_statement = createReturnStatement();
|
|
||||||
((ASTNode)return_statement).setOffset( startOffset );
|
|
||||||
if( result != null )
|
|
||||||
{
|
|
||||||
return_statement.setReturnValue( result );
|
|
||||||
result.setParent( return_statement );
|
|
||||||
result.setPropertyInParent( IASTReturnStatement.RETURNVALUE );
|
|
||||||
}
|
|
||||||
return return_statement;
|
|
||||||
case IToken.t_goto:
|
|
||||||
startOffset = consume(IToken.t_goto).getOffset();
|
|
||||||
IToken identifier = consume(IToken.tIDENTIFIER);
|
|
||||||
consume(IToken.tSEMI);
|
|
||||||
cleanupLastToken();
|
|
||||||
IASTName goto_label_name = createName( identifier );
|
|
||||||
IASTGotoStatement goto_statement = createGoToStatement();
|
|
||||||
((ASTNode)goto_statement).setOffset( startOffset );
|
|
||||||
goto_statement.setName( goto_label_name );
|
|
||||||
goto_label_name.setParent( goto_statement );
|
|
||||||
goto_label_name.setPropertyInParent( IASTGotoStatement.NAME );
|
|
||||||
return goto_statement;
|
|
||||||
case IToken.tSEMI:
|
|
||||||
startOffset = consume(IToken.tSEMI ).getOffset();
|
|
||||||
cleanupLastToken();
|
|
||||||
IASTNullStatement null_statement = createNullStatement();
|
|
||||||
((ASTNode)null_statement).setOffset( startOffset );
|
|
||||||
return null_statement;
|
|
||||||
default:
|
|
||||||
// can be many things:
|
|
||||||
// label
|
|
||||||
if (LT(1) == IToken.tIDENTIFIER && LT(2) == IToken.tCOLON) {
|
|
||||||
IToken labelName = consume(IToken.tIDENTIFIER);
|
|
||||||
consume(IToken.tCOLON);
|
|
||||||
IASTLabelStatement label_statement = createLabelStatement();
|
|
||||||
((ASTNode)label_statement).setOffset( labelName.getOffset() );
|
|
||||||
IASTName name = createName( labelName );
|
|
||||||
label_statement.setName( name );
|
|
||||||
name.setParent( label_statement );
|
|
||||||
name.setPropertyInParent( IASTLabelStatement.NAME );
|
|
||||||
return label_statement;
|
|
||||||
}
|
|
||||||
// expressionStatement
|
|
||||||
// Note: the function style cast ambiguity is handled in
|
|
||||||
// expression
|
|
||||||
// Since it only happens when we are in a statement
|
|
||||||
IToken mark = mark();
|
|
||||||
try {
|
|
||||||
IASTExpression expression = expression();
|
|
||||||
consume(IToken.tSEMI);
|
|
||||||
IASTExpressionStatement expressionStatement = createExpressionStatement();
|
|
||||||
expressionStatement.setExpression( expression );
|
|
||||||
expression.setParent( expressionStatement );
|
|
||||||
expression.setPropertyInParent( IASTExpressionStatement.EXPFRESSION );
|
|
||||||
cleanupLastToken();
|
|
||||||
return expressionStatement;
|
|
||||||
} catch (BacktrackException b) {
|
|
||||||
backup(mark);
|
|
||||||
}
|
|
||||||
|
|
||||||
// declarationStatement
|
/**
|
||||||
IASTDeclaration d = declaration();
|
* @return
|
||||||
IASTDeclarationStatement ds = createDeclarationStatement();
|
*/
|
||||||
ds.setDeclaration(d);
|
protected abstract IASTNullStatement createNullStatement();
|
||||||
d.setParent( ds );
|
|
||||||
d.setPropertyInParent( IASTDeclarationStatement.DECLARATION );
|
|
||||||
cleanupLastToken();
|
|
||||||
return ds;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected abstract IASTGotoStatement createGoToStatement();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected abstract IASTReturnStatement createReturnStatement();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected abstract IASTContinueStatement createContinueStatement();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected abstract IASTBreakStatement createBreakStatement();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected abstract IASTForStatement createForStatement();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected abstract IASTDoStatement createDoStatement();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected abstract IASTWhileStatement createWhileStatement();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected abstract IASTSwitchStatement createSwitchStatement();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected abstract IASTIfStatement createIfStatement();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected abstract IASTDefaultStatement createDefaultStatement();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected abstract IASTCaseStatement createCaseStatement();
|
||||||
|
|
||||||
protected abstract IASTDeclaration declaration() throws BacktrackException, EndOfFileException;
|
protected abstract IASTDeclaration declaration() throws BacktrackException, EndOfFileException;
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
protected IASTLabelStatement createLabelStatement() {
|
|
||||||
return new CASTLabelStatement();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
protected IASTGotoStatement createGoToStatement() {
|
|
||||||
return new CASTGotoStatement();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
protected IASTReturnStatement createReturnStatement() {
|
|
||||||
return new CASTReturnStatement();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
protected IASTForStatement createForStatement() {
|
|
||||||
return new CASTForStatement();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
protected IASTContinueStatement createContinueStatement() {
|
|
||||||
return new CASTContinueStatement();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
protected IASTDoStatement createDoStatement() {
|
|
||||||
return new CASTDoStatement();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
protected IASTBreakStatement createBreakStatement() {
|
|
||||||
return new CASTBreakStatement();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
protected IASTWhileStatement createWhileStatement() {
|
|
||||||
return new CASTWhileStatement();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
protected IASTNullStatement createNullStatement() {
|
|
||||||
return new CASTNullStatement();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
protected IASTSwitchStatement createSwitchStatement() {
|
|
||||||
return new CASTSwitchStatement();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
protected IASTIfStatement createIfStatement() {
|
|
||||||
return new CASTIfStatement();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
protected IASTDefaultStatement createDefaultStatement() {
|
|
||||||
return new CASTDefaultStatement();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
protected IASTCaseStatement createCaseStatement() {
|
|
||||||
return new CASTCaseStatement();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
protected IASTExpressionStatement createExpressionStatement() {
|
|
||||||
return new CASTExpressionStatement();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
protected IASTDeclarationStatement createDeclarationStatement() {
|
|
||||||
return new CASTDeclarationStatement();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract IASTNode forInitStatement() throws BacktrackException,
|
protected abstract IASTNode forInitStatement() throws BacktrackException,
|
||||||
EndOfFileException;
|
EndOfFileException;
|
||||||
|
@ -1587,13 +1293,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected IASTASMDeclaration createASMDirective() {
|
protected abstract IASTASMDeclaration createASMDirective();
|
||||||
return new CASTASMDeclaration();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IASTEnumerationSpecifier createEnumerationSpecifier() {
|
|
||||||
return new CASTEnumerationSpecifier();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param op
|
* @param op
|
||||||
|
@ -1618,8 +1318,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected IASTCastExpression createCastExpression() {
|
protected abstract IASTCastExpression createCastExpression();
|
||||||
return new CASTCastExpression();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -11,7 +11,7 @@
|
||||||
/*
|
/*
|
||||||
* Created on Oct 22, 2004
|
* Created on Oct 22, 2004
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.internal.core.parser2.cpp;
|
package org.eclipse.cdt.internal.core.parser2;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IProblem;
|
import org.eclipse.cdt.core.parser.IProblem;
|
||||||
|
|
|
@ -19,7 +19,6 @@ import org.eclipse.cdt.internal.core.parser2.ASTNode;
|
||||||
*/
|
*/
|
||||||
public class CASTNode extends ASTNode implements IASTNode {
|
public class CASTNode extends ASTNode implements IASTNode {
|
||||||
|
|
||||||
|
|
||||||
private IASTNode parent;
|
private IASTNode parent;
|
||||||
private ASTNodeProperty property;
|
private ASTNodeProperty property;
|
||||||
|
|
||||||
|
|
|
@ -13,43 +13,59 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTCaseStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTContinueStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDefaultStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDoStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
|
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTForStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
|
import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNullStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayDesignator;
|
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayDesignator;
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier;
|
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier;
|
||||||
|
@ -74,7 +90,7 @@ import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
|
import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
|
||||||
import org.eclipse.cdt.internal.core.parser2.ASTNode;
|
import org.eclipse.cdt.internal.core.parser2.ASTNode;
|
||||||
import org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser;
|
import org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser;
|
||||||
import org.eclipse.cdt.internal.core.parser2.cpp.IProblemRequestor;
|
import org.eclipse.cdt.internal.core.parser2.IProblemRequestor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -1930,4 +1946,375 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return new CASTEnumerator();
|
return new CASTEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTLabelStatement createLabelStatement() {
|
||||||
|
return new CASTLabelStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTGotoStatement createGoToStatement() {
|
||||||
|
return new CASTGotoStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTReturnStatement createReturnStatement() {
|
||||||
|
return new CASTReturnStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTForStatement createForStatement() {
|
||||||
|
return new CASTForStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTContinueStatement createContinueStatement() {
|
||||||
|
return new CASTContinueStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTDoStatement createDoStatement() {
|
||||||
|
return new CASTDoStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTBreakStatement createBreakStatement() {
|
||||||
|
return new CASTBreakStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTWhileStatement createWhileStatement() {
|
||||||
|
return new CASTWhileStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTNullStatement createNullStatement() {
|
||||||
|
return new CASTNullStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTSwitchStatement createSwitchStatement() {
|
||||||
|
return new CASTSwitchStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTIfStatement createIfStatement() {
|
||||||
|
return new CASTIfStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTDefaultStatement createDefaultStatement() {
|
||||||
|
return new CASTDefaultStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTCaseStatement createCaseStatement() {
|
||||||
|
return new CASTCaseStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTExpressionStatement createExpressionStatement() {
|
||||||
|
return new CASTExpressionStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTDeclarationStatement createDeclarationStatement() {
|
||||||
|
return new CASTDeclarationStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTASMDeclaration createASMDirective() {
|
||||||
|
return new CASTASMDeclaration();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IASTEnumerationSpecifier createEnumerationSpecifier() {
|
||||||
|
return new CASTEnumerationSpecifier();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTCastExpression createCastExpression() {
|
||||||
|
return new CASTCastExpression();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IASTStatement statement() throws EndOfFileException, BacktrackException {
|
||||||
|
|
||||||
|
switch (LT(1)) {
|
||||||
|
// labeled statements
|
||||||
|
case IToken.t_case:
|
||||||
|
int startOffset = consume(IToken.t_case).getOffset();
|
||||||
|
IASTExpression case_exp = constantExpression();
|
||||||
|
consume(IToken.tCOLON);
|
||||||
|
cleanupLastToken();
|
||||||
|
IASTCaseStatement cs = createCaseStatement();
|
||||||
|
((ASTNode)cs).setOffset( startOffset );
|
||||||
|
cs.setExpression( case_exp );
|
||||||
|
case_exp.setParent( cs );
|
||||||
|
case_exp.setPropertyInParent( IASTCaseStatement.EXPRESSION );
|
||||||
|
return cs;
|
||||||
|
case IToken.t_default:
|
||||||
|
startOffset = consume(IToken.t_default).getOffset();
|
||||||
|
consume(IToken.tCOLON);
|
||||||
|
cleanupLastToken();
|
||||||
|
IASTDefaultStatement df = createDefaultStatement();
|
||||||
|
((ASTNode)df).setOffset( startOffset );
|
||||||
|
return df;
|
||||||
|
// compound statement
|
||||||
|
case IToken.tLBRACE:
|
||||||
|
IASTCompoundStatement compound = compoundStatement();
|
||||||
|
cleanupLastToken();
|
||||||
|
return compound;
|
||||||
|
// selection statement
|
||||||
|
case IToken.t_if:
|
||||||
|
startOffset = consume(IToken.t_if).getOffset();
|
||||||
|
consume(IToken.tLPAREN);
|
||||||
|
IASTExpression if_condition = condition();
|
||||||
|
consume(IToken.tRPAREN);
|
||||||
|
IASTStatement then_clause = statement();
|
||||||
|
IASTStatement else_clause = null;
|
||||||
|
if (LT(1) == IToken.t_else) {
|
||||||
|
consume(IToken.t_else);
|
||||||
|
else_clause = statement();
|
||||||
|
}
|
||||||
|
|
||||||
|
IASTIfStatement if_stmt = createIfStatement();
|
||||||
|
if_stmt.setCondition( if_condition );
|
||||||
|
((ASTNode)if_stmt).setOffset( startOffset );
|
||||||
|
if_condition.setParent( if_stmt );
|
||||||
|
if_condition.setPropertyInParent( IASTIfStatement.CONDITION );
|
||||||
|
if_stmt.setThenClause( then_clause );
|
||||||
|
then_clause.setParent( if_stmt );
|
||||||
|
then_clause.setPropertyInParent( IASTIfStatement.THEN );
|
||||||
|
if( else_clause != null )
|
||||||
|
{
|
||||||
|
if_stmt.setElseClause( else_clause );
|
||||||
|
else_clause.setParent( if_stmt );
|
||||||
|
else_clause.setPropertyInParent( IASTIfStatement.ELSE );
|
||||||
|
}
|
||||||
|
cleanupLastToken();
|
||||||
|
return if_stmt;
|
||||||
|
case IToken.t_switch:
|
||||||
|
startOffset = consume( IToken.t_switch ).getOffset();
|
||||||
|
consume(IToken.tLPAREN);
|
||||||
|
IASTExpression switch_condition = condition();
|
||||||
|
consume(IToken.tRPAREN);
|
||||||
|
IASTStatement switch_body = statement();
|
||||||
|
cleanupLastToken();
|
||||||
|
IASTSwitchStatement switch_statement = createSwitchStatement();
|
||||||
|
((ASTNode)switch_statement).setOffset( startOffset );
|
||||||
|
switch_statement.setController( switch_condition );
|
||||||
|
switch_condition.setParent( switch_statement );
|
||||||
|
switch_condition.setPropertyInParent( IASTSwitchStatement.CONTROLLER );
|
||||||
|
switch_statement.setBody( switch_body );
|
||||||
|
switch_body.setParent( switch_statement );
|
||||||
|
switch_body.setPropertyInParent( IASTSwitchStatement.BODY );
|
||||||
|
return switch_statement;
|
||||||
|
//iteration statements
|
||||||
|
case IToken.t_while:
|
||||||
|
startOffset = consume(IToken.t_while).getOffset();
|
||||||
|
consume(IToken.tLPAREN);
|
||||||
|
IASTExpression while_condition = condition();
|
||||||
|
consume(IToken.tRPAREN);
|
||||||
|
IASTStatement while_body = statement();
|
||||||
|
cleanupLastToken();
|
||||||
|
IASTWhileStatement while_statement = createWhileStatement();
|
||||||
|
((ASTNode)while_statement).setOffset( startOffset );
|
||||||
|
while_statement.setCondition( while_condition );
|
||||||
|
while_condition.setParent( while_statement );
|
||||||
|
while_condition.setPropertyInParent( IASTWhileStatement.CONDITION );
|
||||||
|
while_statement.setBody( while_body );
|
||||||
|
while_condition.setParent( while_statement );
|
||||||
|
while_condition.setPropertyInParent( IASTWhileStatement.BODY );
|
||||||
|
while_body.setParent( while_statement );
|
||||||
|
return while_statement;
|
||||||
|
case IToken.t_do:
|
||||||
|
startOffset = consume(IToken.t_do).getOffset();
|
||||||
|
IASTStatement do_body = statement();
|
||||||
|
consume(IToken.t_while);
|
||||||
|
consume(IToken.tLPAREN);
|
||||||
|
IASTExpression do_condition = condition();
|
||||||
|
consume(IToken.tRPAREN);
|
||||||
|
cleanupLastToken();
|
||||||
|
IASTDoStatement do_statement = createDoStatement();
|
||||||
|
((ASTNode)do_statement).setOffset( startOffset );
|
||||||
|
do_statement.setBody( do_body );
|
||||||
|
do_body.setParent( do_statement );
|
||||||
|
do_body.setPropertyInParent( IASTDoStatement.BODY );
|
||||||
|
do_statement.setCondition( do_condition );
|
||||||
|
do_condition.setParent( do_statement );
|
||||||
|
do_condition.setPropertyInParent( IASTDoStatement.CONDITION );
|
||||||
|
return do_statement;
|
||||||
|
case IToken.t_for:
|
||||||
|
startOffset = consume( IToken.t_for ).getOffset();
|
||||||
|
consume(IToken.tLPAREN);
|
||||||
|
IASTNode init = forInitStatement();
|
||||||
|
IASTExpression for_condition = null;
|
||||||
|
if (LT(1) != IToken.tSEMI)
|
||||||
|
for_condition = condition();
|
||||||
|
consume(IToken.tSEMI);
|
||||||
|
IASTExpression iterationExpression = null;
|
||||||
|
if (LT(1) != IToken.tRPAREN) {
|
||||||
|
iterationExpression = expression();
|
||||||
|
cleanupLastToken();
|
||||||
|
}
|
||||||
|
consume(IToken.tRPAREN);
|
||||||
|
IASTStatement for_body = statement();
|
||||||
|
cleanupLastToken();
|
||||||
|
IASTForStatement for_statement = createForStatement();
|
||||||
|
((ASTNode)for_statement).setOffset( startOffset );
|
||||||
|
if( init instanceof IASTDeclaration )
|
||||||
|
{
|
||||||
|
for_statement.setInit((IASTDeclaration) init);
|
||||||
|
((IASTDeclaration) init).setParent( for_statement );
|
||||||
|
((IASTDeclaration) init).setPropertyInParent( IASTForStatement.INITDECLARATION );
|
||||||
|
}
|
||||||
|
else if( init instanceof IASTExpression )
|
||||||
|
{
|
||||||
|
for_statement.setInit((IASTExpression) init);
|
||||||
|
((IASTExpression) init).setParent( for_statement );
|
||||||
|
((IASTExpression) init).setPropertyInParent( IASTForStatement.INITEXPRESSION );
|
||||||
|
}
|
||||||
|
if( for_condition != null )
|
||||||
|
{
|
||||||
|
for_statement.setCondition( for_condition );
|
||||||
|
for_condition.setParent( for_statement );
|
||||||
|
for_condition.setPropertyInParent( IASTForStatement.CONDITION );
|
||||||
|
}
|
||||||
|
if( iterationExpression != null )
|
||||||
|
{
|
||||||
|
for_statement.setIterationExpression( iterationExpression );
|
||||||
|
iterationExpression.setParent( for_statement );
|
||||||
|
iterationExpression.setPropertyInParent( IASTForStatement.ITERATION );
|
||||||
|
}
|
||||||
|
for_statement.setBody( for_body );
|
||||||
|
for_body.setParent( for_statement );
|
||||||
|
for_body.setPropertyInParent( IASTForStatement.BODY );
|
||||||
|
return for_statement;
|
||||||
|
//jump statement
|
||||||
|
case IToken.t_break:
|
||||||
|
startOffset = consume(IToken.t_break).getOffset();
|
||||||
|
consume(IToken.tSEMI);
|
||||||
|
cleanupLastToken();
|
||||||
|
IASTBreakStatement break_statement = createBreakStatement();
|
||||||
|
((ASTNode)break_statement).setOffset( startOffset );
|
||||||
|
return break_statement;
|
||||||
|
case IToken.t_continue:
|
||||||
|
startOffset = consume(IToken.t_continue).getOffset();
|
||||||
|
consume(IToken.tSEMI);
|
||||||
|
cleanupLastToken();
|
||||||
|
IASTContinueStatement continue_statement = createContinueStatement();
|
||||||
|
((ASTNode)continue_statement).setOffset( startOffset );
|
||||||
|
return continue_statement;
|
||||||
|
case IToken.t_return:
|
||||||
|
startOffset = consume(IToken.t_return).getOffset();
|
||||||
|
IASTExpression result = null;
|
||||||
|
if (LT(1) != IToken.tSEMI) {
|
||||||
|
result = expression();
|
||||||
|
cleanupLastToken();
|
||||||
|
}
|
||||||
|
consume(IToken.tSEMI);
|
||||||
|
cleanupLastToken();
|
||||||
|
IASTReturnStatement return_statement = createReturnStatement();
|
||||||
|
((ASTNode)return_statement).setOffset( startOffset );
|
||||||
|
if( result != null )
|
||||||
|
{
|
||||||
|
return_statement.setReturnValue( result );
|
||||||
|
result.setParent( return_statement );
|
||||||
|
result.setPropertyInParent( IASTReturnStatement.RETURNVALUE );
|
||||||
|
}
|
||||||
|
return return_statement;
|
||||||
|
case IToken.t_goto:
|
||||||
|
startOffset = consume(IToken.t_goto).getOffset();
|
||||||
|
IToken identifier = consume(IToken.tIDENTIFIER);
|
||||||
|
consume(IToken.tSEMI);
|
||||||
|
cleanupLastToken();
|
||||||
|
IASTName goto_label_name = createName( identifier );
|
||||||
|
IASTGotoStatement goto_statement = createGoToStatement();
|
||||||
|
((ASTNode)goto_statement).setOffset( startOffset );
|
||||||
|
goto_statement.setName( goto_label_name );
|
||||||
|
goto_label_name.setParent( goto_statement );
|
||||||
|
goto_label_name.setPropertyInParent( IASTGotoStatement.NAME );
|
||||||
|
return goto_statement;
|
||||||
|
case IToken.tSEMI:
|
||||||
|
startOffset = consume(IToken.tSEMI ).getOffset();
|
||||||
|
cleanupLastToken();
|
||||||
|
IASTNullStatement null_statement = createNullStatement();
|
||||||
|
((ASTNode)null_statement).setOffset( startOffset );
|
||||||
|
return null_statement;
|
||||||
|
default:
|
||||||
|
// can be many things:
|
||||||
|
// label
|
||||||
|
if (LT(1) == IToken.tIDENTIFIER && LT(2) == IToken.tCOLON) {
|
||||||
|
IToken labelName = consume(IToken.tIDENTIFIER);
|
||||||
|
consume(IToken.tCOLON);
|
||||||
|
IASTLabelStatement label_statement = createLabelStatement();
|
||||||
|
((ASTNode)label_statement).setOffset( labelName.getOffset() );
|
||||||
|
IASTName name = createName( labelName );
|
||||||
|
label_statement.setName( name );
|
||||||
|
name.setParent( label_statement );
|
||||||
|
name.setPropertyInParent( IASTLabelStatement.NAME );
|
||||||
|
return label_statement;
|
||||||
|
}
|
||||||
|
// expressionStatement
|
||||||
|
// Note: the function style cast ambiguity is handled in
|
||||||
|
// expression
|
||||||
|
// Since it only happens when we are in a statement
|
||||||
|
IToken mark = mark();
|
||||||
|
try {
|
||||||
|
IASTExpression expression = expression();
|
||||||
|
consume(IToken.tSEMI);
|
||||||
|
IASTExpressionStatement expressionStatement = createExpressionStatement();
|
||||||
|
expressionStatement.setExpression( expression );
|
||||||
|
expression.setParent( expressionStatement );
|
||||||
|
expression.setPropertyInParent( IASTExpressionStatement.EXPFRESSION );
|
||||||
|
cleanupLastToken();
|
||||||
|
return expressionStatement;
|
||||||
|
} catch (BacktrackException b) {
|
||||||
|
backup(mark);
|
||||||
|
}
|
||||||
|
|
||||||
|
// declarationStatement
|
||||||
|
IASTDeclaration d = declaration();
|
||||||
|
IASTDeclarationStatement ds = createDeclarationStatement();
|
||||||
|
ds.setDeclaration(d);
|
||||||
|
d.setParent( ds );
|
||||||
|
d.setPropertyInParent( IASTDeclarationStatement.DECLARATION );
|
||||||
|
cleanupLastToken();
|
||||||
|
return ds;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTASMDeclaration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTASMDeclaration extends CPPASTNode implements
|
||||||
|
IASTASMDeclaration {
|
||||||
|
char [] assembly = null;
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTASMDeclaration#getAssembly()
|
||||||
|
*/
|
||||||
|
public String getAssembly() {
|
||||||
|
if( assembly == null ) return ""; //$NON-NLS-1$
|
||||||
|
return new String( assembly );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTASMDeclaration#setAssembly(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setAssembly(String assembly) {
|
||||||
|
this.assembly = assembly.toCharArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTBinaryExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTBinaryExpression extends CPPASTNode implements
|
||||||
|
IASTBinaryExpression {
|
||||||
|
|
||||||
|
private int op;
|
||||||
|
private IASTExpression operand1;
|
||||||
|
private IASTExpression operand2;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTBinaryExpression#getOperator()
|
||||||
|
*/
|
||||||
|
public int getOperator() {
|
||||||
|
return op;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTBinaryExpression#getOperand1()
|
||||||
|
*/
|
||||||
|
public IASTExpression getOperand1() {
|
||||||
|
return operand1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTBinaryExpression#getOperand2()
|
||||||
|
*/
|
||||||
|
public IASTExpression getOperand2() {
|
||||||
|
return operand2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTBinaryExpression#setOperator(int)
|
||||||
|
*/
|
||||||
|
public void setOperator(int op) {
|
||||||
|
this.op = op;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTBinaryExpression#setOperand1(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||||
|
*/
|
||||||
|
public void setOperand1(IASTExpression expression) {
|
||||||
|
operand1 = expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTBinaryExpression#setOperand2(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||||
|
*/
|
||||||
|
public void setOperand2(IASTExpression expression) {
|
||||||
|
operand2 = expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTBreakStatement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTBreakStatement extends CPPASTNode implements
|
||||||
|
IASTBreakStatement {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTCaseStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTCaseStatement extends CPPASTNode implements
|
||||||
|
IASTCaseStatement {
|
||||||
|
private IASTExpression expression;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTCaseStatement#getExpression()
|
||||||
|
*/
|
||||||
|
public IASTExpression getExpression() {
|
||||||
|
return expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTCaseStatement#setExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||||
|
*/
|
||||||
|
public void setExpression(IASTExpression expression) {
|
||||||
|
this.expression = expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTCastExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTCastExpression extends CPPASTUnaryExpression implements
|
||||||
|
IASTCastExpression {
|
||||||
|
private IASTTypeId typeId;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTUnaryTypeIdExpression#setTypeId(org.eclipse.cdt.core.dom.ast.IASTTypeId)
|
||||||
|
*/
|
||||||
|
public void setTypeId(IASTTypeId typeId) {
|
||||||
|
this.typeId = typeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTUnaryTypeIdExpression#getTypeId()
|
||||||
|
*/
|
||||||
|
public IASTTypeId getTypeId() {
|
||||||
|
return typeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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 java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTCompoundStatement extends CPPASTNode implements
|
||||||
|
IASTCompoundStatement {
|
||||||
|
|
||||||
|
private int currentIndex = 0;
|
||||||
|
private void removeNullStatements() {
|
||||||
|
int nullCount = 0;
|
||||||
|
for( int i = 0; i < statements.length; ++i )
|
||||||
|
if( statements[i] == null )
|
||||||
|
++nullCount;
|
||||||
|
if( nullCount == 0 ) return;
|
||||||
|
IASTStatement [] old = statements;
|
||||||
|
int newSize = old.length - nullCount;
|
||||||
|
statements = new IASTStatement[ newSize ];
|
||||||
|
for( int i = 0; i < newSize; ++i )
|
||||||
|
statements[i] = old[i];
|
||||||
|
currentIndex = newSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private IASTStatement [] statements = null;
|
||||||
|
private static final int DEFAULT_STATEMENT_LIST_SIZE = 8;
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTCompoundStatement#getStatements()
|
||||||
|
*/
|
||||||
|
public List getStatements() {
|
||||||
|
if( statements == null ) return Collections.EMPTY_LIST;
|
||||||
|
removeNullStatements();
|
||||||
|
return Arrays.asList( statements );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTCompoundStatement#addStatement(org.eclipse.cdt.core.dom.ast.IASTStatement)
|
||||||
|
*/
|
||||||
|
public void addStatement(IASTStatement statement) {
|
||||||
|
if( statements == null )
|
||||||
|
{
|
||||||
|
statements = new IASTStatement[ DEFAULT_STATEMENT_LIST_SIZE ];
|
||||||
|
currentIndex = 0;
|
||||||
|
}
|
||||||
|
if( statements.length == currentIndex )
|
||||||
|
{
|
||||||
|
IASTStatement [] old = statements;
|
||||||
|
statements = new IASTStatement[ old.length * 2 ];
|
||||||
|
for( int i = 0; i < old.length; ++i )
|
||||||
|
statements[i] = old[i];
|
||||||
|
}
|
||||||
|
statements[ currentIndex++ ] = statement;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTCompoundStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTCompoundStatementExpression extends CPPASTNode implements
|
||||||
|
IGNUASTCompoundStatementExpression {
|
||||||
|
private IASTCompoundStatement statement;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.c.gcc.IGCCASTCompoundStatementExpression#getCompoundStatement()
|
||||||
|
*/
|
||||||
|
public IASTCompoundStatement getCompoundStatement() {
|
||||||
|
return statement;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.c.gcc.IGCCASTCompoundStatementExpression#setCompoundStatement(org.eclipse.cdt.core.dom.ast.IASTCompoundStatement)
|
||||||
|
*/
|
||||||
|
public void setCompoundStatement(IASTCompoundStatement statement) {
|
||||||
|
this.statement = statement;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTConditionalExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTConditionalExpression extends CPPASTNode implements
|
||||||
|
IASTConditionalExpression {
|
||||||
|
private IASTExpression condition;
|
||||||
|
private IASTExpression negative;
|
||||||
|
private IASTExpression postive;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTConditionalExpression#getLogicalConditionExpression()
|
||||||
|
*/
|
||||||
|
public IASTExpression getLogicalConditionExpression() {
|
||||||
|
return condition;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTConditionalExpression#setLogicalConditionExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||||
|
*/
|
||||||
|
public void setLogicalConditionExpression(IASTExpression expression) {
|
||||||
|
condition = expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTConditionalExpression#getPositiveResultExpression()
|
||||||
|
*/
|
||||||
|
public IASTExpression getPositiveResultExpression() {
|
||||||
|
return postive;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTConditionalExpression#setPositiveResultExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||||
|
*/
|
||||||
|
public void setPositiveResultExpression(IASTExpression expression) {
|
||||||
|
this.postive = expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTConditionalExpression#getNegativeResultExpression()
|
||||||
|
*/
|
||||||
|
public IASTExpression getNegativeResultExpression() {
|
||||||
|
return negative;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTConditionalExpression#setNegativeResultExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||||
|
*/
|
||||||
|
public void setNegativeResultExpression(IASTExpression expression) {
|
||||||
|
this.negative = expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTContinueStatement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTContinueStatement extends CPPASTNode implements
|
||||||
|
IASTContinueStatement {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTDeclarationStatement extends CPPASTNode implements
|
||||||
|
IASTDeclarationStatement {
|
||||||
|
|
||||||
|
private IASTDeclaration declaration;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement#getDeclaration()
|
||||||
|
*/
|
||||||
|
public IASTDeclaration getDeclaration() {
|
||||||
|
return declaration;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement#setDeclaration(org.eclipse.cdt.core.dom.ast.IASTDeclaration)
|
||||||
|
*/
|
||||||
|
public void setDeclaration(IASTDeclaration declaration) {
|
||||||
|
this.declaration = declaration;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTDefaultStatement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTDefaultStatement extends CPPASTNode implements
|
||||||
|
IASTDefaultStatement {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTDoStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTDoStatement extends CPPASTNode implements IASTDoStatement {
|
||||||
|
private IASTStatement body;
|
||||||
|
private IASTExpression condition;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTDoStatement#getBody()
|
||||||
|
*/
|
||||||
|
public IASTStatement getBody() {
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTDoStatement#setBody(org.eclipse.cdt.core.dom.ast.IASTStatement)
|
||||||
|
*/
|
||||||
|
public void setBody(IASTStatement body) {
|
||||||
|
this.body = body;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTDoStatement#getCondition()
|
||||||
|
*/
|
||||||
|
public IASTExpression getCondition() {
|
||||||
|
return condition;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTDoStatement#setCondition(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||||
|
*/
|
||||||
|
public void setCondition(IASTExpression condition) {
|
||||||
|
this.condition = condition;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTEnumerator extends CPPASTNode implements IASTEnumerator {
|
||||||
|
private IASTName name;
|
||||||
|
private IASTExpression value;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator#setName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||||
|
*/
|
||||||
|
public void setName(IASTName name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator#getName()
|
||||||
|
*/
|
||||||
|
public IASTName getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator#setValue(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||||
|
*/
|
||||||
|
public void setValue(IASTExpression expression) {
|
||||||
|
this.value = expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator#getValue()
|
||||||
|
*/
|
||||||
|
public IASTExpression getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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 java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTExpressionList extends CPPASTNode implements
|
||||||
|
IASTExpressionList {
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTExpressionList#getExpressions()
|
||||||
|
*/
|
||||||
|
public List getExpressions() {
|
||||||
|
if( expressions == null ) return Collections.EMPTY_LIST;
|
||||||
|
removeNullExpressions();
|
||||||
|
return Arrays.asList( expressions );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTExpressionList#addExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||||
|
*/
|
||||||
|
public void addExpression(IASTExpression expression) {
|
||||||
|
if( expressions == null )
|
||||||
|
{
|
||||||
|
expressions = new IASTExpression[ DEFAULT_EXPRESSIONLIST_SIZE ];
|
||||||
|
currentIndex = 0;
|
||||||
|
}
|
||||||
|
if( expressions.length == currentIndex )
|
||||||
|
{
|
||||||
|
IASTExpression [] old = expressions;
|
||||||
|
expressions = new IASTExpression[ old.length * 2 ];
|
||||||
|
for( int i = 0; i < old.length; ++i )
|
||||||
|
expressions[i] = old[i];
|
||||||
|
}
|
||||||
|
expressions[ currentIndex++ ] = expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param decls2
|
||||||
|
*/
|
||||||
|
private void removeNullExpressions() {
|
||||||
|
int nullCount = 0;
|
||||||
|
for( int i = 0; i < expressions.length; ++i )
|
||||||
|
if( expressions[i] == null )
|
||||||
|
++nullCount;
|
||||||
|
if( nullCount == 0 ) return;
|
||||||
|
IASTExpression [] old = expressions;
|
||||||
|
int newSize = old.length - nullCount;
|
||||||
|
expressions = new IASTExpression[ newSize ];
|
||||||
|
for( int i = 0; i < newSize; ++i )
|
||||||
|
expressions[i] = old[i];
|
||||||
|
currentIndex = newSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int currentIndex = 0;
|
||||||
|
private IASTExpression [] expressions = null;
|
||||||
|
private static final int DEFAULT_EXPRESSIONLIST_SIZE = 4;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTExpressionStatement extends CPPASTNode implements
|
||||||
|
IASTExpressionStatement {
|
||||||
|
private IASTExpression expression;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTExpressionStatement#getExpression()
|
||||||
|
*/
|
||||||
|
public IASTExpression getExpression() {
|
||||||
|
return expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTExpressionStatement#setExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||||
|
*/
|
||||||
|
public void setExpression(IASTExpression expression) {
|
||||||
|
this.expression = expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTFieldDeclarator extends CPPASTDeclarator implements
|
||||||
|
IASTFieldDeclarator {
|
||||||
|
|
||||||
|
private IASTExpression bitField;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator#getBitFieldSize()
|
||||||
|
*/
|
||||||
|
public IASTExpression getBitFieldSize() {
|
||||||
|
return bitField;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator#setBitFieldSize(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||||
|
*/
|
||||||
|
public void setBitFieldSize(IASTExpression size) {
|
||||||
|
this.bitField = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,100 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTForStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTForStatement extends CPPASTNode implements IASTForStatement {
|
||||||
|
|
||||||
|
private IASTExpression initialExpression;
|
||||||
|
private IASTDeclaration initDeclaration;
|
||||||
|
private IASTExpression condition;
|
||||||
|
private IASTExpression iterationExpression;
|
||||||
|
private IASTStatement body;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTForStatement#getInitExpression()
|
||||||
|
*/
|
||||||
|
public IASTExpression getInitExpression() {
|
||||||
|
return initialExpression;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTForStatement#setInit(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||||
|
*/
|
||||||
|
public void setInit(IASTExpression expression) {
|
||||||
|
this.initialExpression = expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTForStatement#getInitDeclaration()
|
||||||
|
*/
|
||||||
|
public IASTDeclaration getInitDeclaration() {
|
||||||
|
return initDeclaration;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTForStatement#setInit(org.eclipse.cdt.core.dom.ast.IASTDeclaration)
|
||||||
|
*/
|
||||||
|
public void setInit(IASTDeclaration declaration) {
|
||||||
|
this.initDeclaration = declaration;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTForStatement#getCondition()
|
||||||
|
*/
|
||||||
|
public IASTExpression getCondition() {
|
||||||
|
return condition;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTForStatement#setCondition(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||||
|
*/
|
||||||
|
public void setCondition(IASTExpression condition) {
|
||||||
|
this.condition = condition;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTForStatement#getIterationExpression()
|
||||||
|
*/
|
||||||
|
public IASTExpression getIterationExpression() {
|
||||||
|
return iterationExpression;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTForStatement#setIterationExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||||
|
*/
|
||||||
|
public void setIterationExpression(IASTExpression iterator) {
|
||||||
|
this.iterationExpression = iterator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTForStatement#getBody()
|
||||||
|
*/
|
||||||
|
public IASTStatement getBody() {
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTForStatement#setBody(org.eclipse.cdt.core.dom.ast.IASTStatement)
|
||||||
|
*/
|
||||||
|
public void setBody(IASTStatement statement) {
|
||||||
|
body = statement;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTFunctionCallExpression extends CPPASTNode implements
|
||||||
|
IASTFunctionCallExpression {
|
||||||
|
private IASTExpression functionName;
|
||||||
|
private IASTExpression parameter;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression#setFunctionNameExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||||
|
*/
|
||||||
|
public void setFunctionNameExpression(IASTExpression expression) {
|
||||||
|
this.functionName = expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression#getFunctionNameExpression()
|
||||||
|
*/
|
||||||
|
public IASTExpression getFunctionNameExpression() {
|
||||||
|
return functionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression#setParameterExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||||
|
*/
|
||||||
|
public void setParameterExpression(IASTExpression expression) {
|
||||||
|
this.parameter = expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression#getParameterExpression()
|
||||||
|
*/
|
||||||
|
public IASTExpression getParameterExpression() {
|
||||||
|
return parameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTDeclSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTFunctionDefinition extends CPPASTNode implements
|
||||||
|
IASTFunctionDefinition {
|
||||||
|
|
||||||
|
private IASTDeclSpecifier declSpecifier;
|
||||||
|
private IASTFunctionDeclarator declarator;
|
||||||
|
private IASTStatement bodyStatement;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition#getDeclSpecifier()
|
||||||
|
*/
|
||||||
|
public IASTDeclSpecifier getDeclSpecifier() {
|
||||||
|
return declSpecifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition#setDeclSpecifier(org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier)
|
||||||
|
*/
|
||||||
|
public void setDeclSpecifier(IASTDeclSpecifier declSpec) {
|
||||||
|
declSpecifier = declSpec;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition#getDeclarator()
|
||||||
|
*/
|
||||||
|
public IASTFunctionDeclarator getDeclarator() {
|
||||||
|
return declarator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition#setDeclarator(org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator)
|
||||||
|
*/
|
||||||
|
public void setDeclarator(IASTFunctionDeclarator declarator) {
|
||||||
|
this.declarator = declarator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition#getBody()
|
||||||
|
*/
|
||||||
|
public IASTStatement getBody() {
|
||||||
|
return bodyStatement;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition#setBody(org.eclipse.cdt.core.dom.ast.IASTStatement)
|
||||||
|
*/
|
||||||
|
public void setBody(IASTStatement statement) {
|
||||||
|
bodyStatement = statement;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTGotoStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTGotoStatement extends CPPASTNode implements
|
||||||
|
IASTGotoStatement {
|
||||||
|
private IASTName name;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTGotoStatement#getName()
|
||||||
|
*/
|
||||||
|
public IASTName getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTGotoStatement#setName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||||
|
*/
|
||||||
|
public void setName(IASTName name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTIdExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTIdExpression extends CPPASTNode implements IASTIdExpression {
|
||||||
|
private IASTName name;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTIdExpression#getName()
|
||||||
|
*/
|
||||||
|
public IASTName getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTIdExpression#setName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||||
|
*/
|
||||||
|
public void setName(IASTName name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTIfStatement extends CPPASTNode implements IASTIfStatement {
|
||||||
|
private IASTExpression condition;
|
||||||
|
private IASTStatement thenClause;
|
||||||
|
private IASTStatement elseClause;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTIfStatement#getCondition()
|
||||||
|
*/
|
||||||
|
public IASTExpression getCondition() {
|
||||||
|
return condition;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTIfStatement#setCondition(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||||
|
*/
|
||||||
|
public void setCondition(IASTExpression condition) {
|
||||||
|
this.condition = condition;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTIfStatement#getThenClause()
|
||||||
|
*/
|
||||||
|
public IASTStatement getThenClause() {
|
||||||
|
return thenClause;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTIfStatement#setThenClause(org.eclipse.cdt.core.dom.ast.IASTStatement)
|
||||||
|
*/
|
||||||
|
public void setThenClause(IASTStatement thenClause) {
|
||||||
|
this.thenClause = thenClause;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTIfStatement#getElseClause()
|
||||||
|
*/
|
||||||
|
public IASTStatement getElseClause() {
|
||||||
|
return elseClause;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTIfStatement#setElseClause(org.eclipse.cdt.core.dom.ast.IASTStatement)
|
||||||
|
*/
|
||||||
|
public void setElseClause(IASTStatement elseClause) {
|
||||||
|
this.elseClause = elseClause;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTInitializerExpresion extends CPPASTNode implements
|
||||||
|
IASTInitializerExpression {
|
||||||
|
|
||||||
|
private IASTExpression exp;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTInitializerExpression#getExpression()
|
||||||
|
*/
|
||||||
|
public IASTExpression getExpression() {
|
||||||
|
return exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTInitializerExpression#setExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||||
|
*/
|
||||||
|
public void setExpression(IASTExpression expression) {
|
||||||
|
this.exp = expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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 java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTInitializerList extends CPPASTNode implements
|
||||||
|
IASTInitializerList {
|
||||||
|
|
||||||
|
private int currentIndex = 0;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration#getDeclarators()
|
||||||
|
*/
|
||||||
|
public List getInitializers() {
|
||||||
|
if( initializers == null ) return Collections.EMPTY_LIST;
|
||||||
|
removeNullInitializers();
|
||||||
|
return Arrays.asList( initializers );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addInitializer( IASTInitializer d )
|
||||||
|
{
|
||||||
|
if( initializers == null )
|
||||||
|
{
|
||||||
|
initializers = new IASTInitializer[ DEFAULT_INITIALIZERS_LIST_SIZE ];
|
||||||
|
currentIndex = 0;
|
||||||
|
}
|
||||||
|
if( initializers.length == currentIndex )
|
||||||
|
{
|
||||||
|
IASTInitializer [] old = initializers;
|
||||||
|
initializers = new IASTInitializer[ old.length * 2 ];
|
||||||
|
for( int i = 0; i < old.length; ++i )
|
||||||
|
initializers[i] = old[i];
|
||||||
|
}
|
||||||
|
initializers[ currentIndex++ ] = d;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param decls2
|
||||||
|
*/
|
||||||
|
private void removeNullInitializers() {
|
||||||
|
int nullCount = 0;
|
||||||
|
for( int i = 0; i < initializers.length; ++i )
|
||||||
|
if( initializers[i] == null )
|
||||||
|
++nullCount;
|
||||||
|
if( nullCount == 0 ) return;
|
||||||
|
IASTInitializer [] old = initializers;
|
||||||
|
int newSize = old.length - nullCount;
|
||||||
|
initializers = new IASTInitializer[ newSize ];
|
||||||
|
for( int i = 0; i < newSize; ++i )
|
||||||
|
initializers[i] = old[i];
|
||||||
|
currentIndex = newSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private IASTInitializer [] initializers = null;
|
||||||
|
private static final int DEFAULT_INITIALIZERS_LIST_SIZE = 4;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTLabelStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTLabelStatement extends CPPASTNode implements
|
||||||
|
IASTLabelStatement {
|
||||||
|
private IASTName name;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTLabelStatement#getName()
|
||||||
|
*/
|
||||||
|
public IASTName getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTLabelStatement#setName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||||
|
*/
|
||||||
|
public void setName(IASTName name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -11,13 +11,45 @@
|
||||||
package org.eclipse.cdt.internal.core.parser2.cpp;
|
package org.eclipse.cdt.internal.core.parser2.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression;
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTLiteralExpression;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CPPASTLiteralExpression extends CASTLiteralExpression implements
|
public class CPPASTLiteralExpression extends CPPASTNode implements
|
||||||
ICPPASTLiteralExpression {
|
ICPPASTLiteralExpression {
|
||||||
|
|
||||||
|
private int kind;
|
||||||
|
private String value = ""; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTLiteralExpression#getKind()
|
||||||
|
*/
|
||||||
|
public int getKind() {
|
||||||
|
return kind;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTLiteralExpression#setKind(int)
|
||||||
|
*/
|
||||||
|
public void setKind(int value) {
|
||||||
|
this.kind = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTLiteralExpression#setValue(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
|
public String toString() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,103 +10,58 @@
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser2.cpp;
|
package org.eclipse.cdt.internal.core.parser2.cpp;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CPPASTName extends CPPASTNode implements ICPPASTQualifiedName {
|
public class CPPASTName extends CPPASTNode implements IASTName {
|
||||||
|
|
||||||
|
private char[] name;
|
||||||
|
private static final char[] EMPTY_CHAR_ARRAY = { };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param duple
|
* @param name
|
||||||
|
*/
|
||||||
|
public CPPASTName(char [] name ) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public CPPASTName() {
|
public CPPASTName() {
|
||||||
|
name = EMPTY_CHAR_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTName#resolveBinding()
|
* @see org.eclipse.cdt.core.dom.ast.IASTName#resolveBinding()
|
||||||
*/
|
*/
|
||||||
public IBinding resolveBinding() {
|
public IBinding resolveBinding() {
|
||||||
// TODO Auto-generated method stub
|
//TODO
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setBinding( IBinding binding ){
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see java.lang.Object#toString()
|
* @see java.lang.Object#toString()
|
||||||
*/
|
*/
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if( names == null ) return null;
|
if( name == EMPTY_CHAR_ARRAY ) return null;
|
||||||
removeNullNames();
|
return new String( name );
|
||||||
StringBuffer buffer = new StringBuffer();
|
}
|
||||||
for( int i = 0; i < names.length; ++i )
|
|
||||||
|
public char[] toCharArray() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName( char [] name )
|
||||||
{
|
{
|
||||||
String n = names[i].toString();
|
this.name = name;
|
||||||
if( n == null )
|
|
||||||
return null;
|
|
||||||
buffer.append( n );
|
|
||||||
if( i != names.length - 1 )
|
|
||||||
buffer.append( "::"); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
return buffer.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName#addName(org.eclipse.cdt.core.dom.ast.IASTName)
|
|
||||||
*/
|
|
||||||
public void addName(IASTName name) {
|
|
||||||
if( names == null )
|
|
||||||
{
|
|
||||||
names = new IASTName[ DEFAULT_NAMES_LIST_SIZE ];
|
|
||||||
currentIndex = 0;
|
|
||||||
}
|
|
||||||
if( names.length == currentIndex )
|
|
||||||
{
|
|
||||||
IASTName [] old = names;
|
|
||||||
names = new IASTName[ old.length * 2 ];
|
|
||||||
for( int i = 0; i < old.length; ++i )
|
|
||||||
names[i] = old[i];
|
|
||||||
}
|
|
||||||
names[ currentIndex++ ] = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param decls2
|
|
||||||
*/
|
|
||||||
private void removeNullNames() {
|
|
||||||
int nullCount = 0;
|
|
||||||
for( int i = 0; i < names.length; ++i )
|
|
||||||
if( names[i] == null )
|
|
||||||
++nullCount;
|
|
||||||
if( nullCount == 0 ) return;
|
|
||||||
IASTName [] old = names;
|
|
||||||
int newSize = old.length - nullCount;
|
|
||||||
names = new IASTName[ newSize ];
|
|
||||||
for( int i = 0; i < newSize; ++i )
|
|
||||||
names[i] = old[i];
|
|
||||||
currentIndex = newSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int currentIndex = 0;
|
|
||||||
private IASTName [] names = null;
|
|
||||||
private static final int DEFAULT_NAMES_LIST_SIZE = 4;
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName#getNames()
|
|
||||||
*/
|
|
||||||
public List getNames() {
|
|
||||||
if( names == null ) return Collections.EMPTY_LIST;
|
|
||||||
removeNullNames();
|
|
||||||
return Arrays.asList( names );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,12 +12,11 @@ package org.eclipse.cdt.internal.core.parser2.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceAlias;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceAlias;
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTNode;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CPPASTNamespaceAlias extends CASTNode implements
|
public class CPPASTNamespaceAlias extends CPPASTNode implements
|
||||||
ICPPASTNamespaceAlias {
|
ICPPASTNamespaceAlias {
|
||||||
|
|
||||||
private IASTName alias;
|
private IASTName alias;
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTNullStatement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTNullStatement extends CPPASTNode implements
|
||||||
|
IASTNullStatement {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,112 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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 java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTQualifiedName extends CPPASTNode implements ICPPASTQualifiedName {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param duple
|
||||||
|
*/
|
||||||
|
public CPPASTQualifiedName() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTName#resolveBinding()
|
||||||
|
*/
|
||||||
|
public IBinding resolveBinding() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
|
public String toString() {
|
||||||
|
if( names == null ) return null;
|
||||||
|
removeNullNames();
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
for( int i = 0; i < names.length; ++i )
|
||||||
|
{
|
||||||
|
String n = names[i].toString();
|
||||||
|
if( n == null )
|
||||||
|
return null;
|
||||||
|
buffer.append( n );
|
||||||
|
if( i != names.length - 1 )
|
||||||
|
buffer.append( "::"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName#addName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||||
|
*/
|
||||||
|
public void addName(IASTName name) {
|
||||||
|
if( names == null )
|
||||||
|
{
|
||||||
|
names = new IASTName[ DEFAULT_NAMES_LIST_SIZE ];
|
||||||
|
currentIndex = 0;
|
||||||
|
}
|
||||||
|
if( names.length == currentIndex )
|
||||||
|
{
|
||||||
|
IASTName [] old = names;
|
||||||
|
names = new IASTName[ old.length * 2 ];
|
||||||
|
for( int i = 0; i < old.length; ++i )
|
||||||
|
names[i] = old[i];
|
||||||
|
}
|
||||||
|
names[ currentIndex++ ] = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param decls2
|
||||||
|
*/
|
||||||
|
private void removeNullNames() {
|
||||||
|
int nullCount = 0;
|
||||||
|
for( int i = 0; i < names.length; ++i )
|
||||||
|
if( names[i] == null )
|
||||||
|
++nullCount;
|
||||||
|
if( nullCount == 0 ) return;
|
||||||
|
IASTName [] old = names;
|
||||||
|
int newSize = old.length - nullCount;
|
||||||
|
names = new IASTName[ newSize ];
|
||||||
|
for( int i = 0; i < newSize; ++i )
|
||||||
|
names[i] = old[i];
|
||||||
|
currentIndex = newSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int currentIndex = 0;
|
||||||
|
private IASTName [] names = null;
|
||||||
|
private static final int DEFAULT_NAMES_LIST_SIZE = 4;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName#getNames()
|
||||||
|
*/
|
||||||
|
public List getNames() {
|
||||||
|
if( names == null ) return Collections.EMPTY_LIST;
|
||||||
|
removeNullNames();
|
||||||
|
return Arrays.asList( names );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTReturnStatement extends CPPASTNode implements
|
||||||
|
IASTReturnStatement {
|
||||||
|
private IASTExpression retValue;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTReturnStatement#getReturnValue()
|
||||||
|
*/
|
||||||
|
public IASTExpression getReturnValue() {
|
||||||
|
return retValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTReturnStatement#setReturnValue(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||||
|
*/
|
||||||
|
public void setReturnValue(IASTExpression returnValue) {
|
||||||
|
retValue = returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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 java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTSimpleDeclaration extends CPPASTNode implements
|
||||||
|
IASTSimpleDeclaration {
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration#getDeclSpecifier()
|
||||||
|
*/
|
||||||
|
public IASTDeclSpecifier getDeclSpecifier() {
|
||||||
|
return declSpecifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration#getDeclarators()
|
||||||
|
*/
|
||||||
|
public List getDeclarators() {
|
||||||
|
if( declarators == null ) return Collections.EMPTY_LIST;
|
||||||
|
removeNullDeclarators();
|
||||||
|
return Arrays.asList( declarators );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addDeclarator( IASTDeclarator d )
|
||||||
|
{
|
||||||
|
if( declarators == null )
|
||||||
|
{
|
||||||
|
declarators = new IASTDeclarator[ DEFAULT_DECLARATORS_LIST_SIZE ];
|
||||||
|
currentIndex = 0;
|
||||||
|
}
|
||||||
|
if( declarators.length == currentIndex )
|
||||||
|
{
|
||||||
|
IASTDeclarator [] old = declarators;
|
||||||
|
declarators = new IASTDeclarator[ old.length * 2 ];
|
||||||
|
for( int i = 0; i < old.length; ++i )
|
||||||
|
declarators[i] = old[i];
|
||||||
|
}
|
||||||
|
declarators[ currentIndex++ ] = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeNullDeclarators() {
|
||||||
|
int nullCount = 0;
|
||||||
|
for( int i = 0; i < declarators.length; ++i )
|
||||||
|
if( declarators[i] == null )
|
||||||
|
++nullCount;
|
||||||
|
if( nullCount == 0 ) return;
|
||||||
|
IASTDeclarator [] old = declarators;
|
||||||
|
int newSize = old.length - nullCount;
|
||||||
|
declarators = new IASTDeclarator[ newSize ];
|
||||||
|
for( int i = 0; i < newSize; ++i )
|
||||||
|
declarators[i] = old[i];
|
||||||
|
currentIndex = newSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int currentIndex = 0;
|
||||||
|
private IASTDeclarator [] declarators = null;
|
||||||
|
private static final int DEFAULT_DECLARATORS_LIST_SIZE = 4;
|
||||||
|
private IASTDeclSpecifier declSpecifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param declSpecifier The declSpecifier to set.
|
||||||
|
*/
|
||||||
|
public void setDeclSpecifier(IASTDeclSpecifier declSpecifier) {
|
||||||
|
this.declSpecifier = declSpecifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTSwitchStatement extends CPPASTNode implements
|
||||||
|
IASTSwitchStatement {
|
||||||
|
|
||||||
|
private IASTExpression controller;
|
||||||
|
private IASTStatement body;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTSwitchStatement#getController()
|
||||||
|
*/
|
||||||
|
public IASTExpression getController() {
|
||||||
|
return controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTSwitchStatement#setController(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||||
|
*/
|
||||||
|
public void setController(IASTExpression controller) {
|
||||||
|
this.controller = controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTSwitchStatement#getBody()
|
||||||
|
*/
|
||||||
|
public IASTStatement getBody() {
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTSwitchStatement#setBody(org.eclipse.cdt.core.dom.ast.IASTStatement)
|
||||||
|
*/
|
||||||
|
public void setBody(IASTStatement body) {
|
||||||
|
this.body = body;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,119 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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 java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId {
|
||||||
|
|
||||||
|
private IASTName templateName;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId#getTemplateName()
|
||||||
|
*/
|
||||||
|
public IASTName getTemplateName() {
|
||||||
|
return templateName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId#setTemplateName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||||
|
*/
|
||||||
|
public void setTemplateName(IASTName name) {
|
||||||
|
templateName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId#addTemplateArgument(org.eclipse.cdt.core.dom.ast.IASTTypeId)
|
||||||
|
*/
|
||||||
|
public void addTemplateArgument(IASTTypeId typeId) {
|
||||||
|
if( templateArguments == null )
|
||||||
|
{
|
||||||
|
templateArguments = new IASTNode[ DEFAULT_ARGS_LIST_SIZE ];
|
||||||
|
currentIndex = 0;
|
||||||
|
}
|
||||||
|
if( templateArguments.length == currentIndex )
|
||||||
|
{
|
||||||
|
IASTNode [] old = templateArguments;
|
||||||
|
templateArguments = new IASTNode[ old.length * 2 ];
|
||||||
|
for( int i = 0; i < old.length; ++i )
|
||||||
|
templateArguments[i] = old[i];
|
||||||
|
}
|
||||||
|
templateArguments[ currentIndex++ ] = typeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId#addTemplateArgument(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||||
|
*/
|
||||||
|
public void addTemplateArgument(IASTExpression expression) {
|
||||||
|
if( templateArguments == null )
|
||||||
|
{
|
||||||
|
templateArguments = new IASTNode[ DEFAULT_ARGS_LIST_SIZE ];
|
||||||
|
currentIndex = 0;
|
||||||
|
}
|
||||||
|
if( templateArguments.length == currentIndex )
|
||||||
|
{
|
||||||
|
IASTNode [] old = templateArguments;
|
||||||
|
templateArguments = new IASTNode[ old.length * 2 ];
|
||||||
|
for( int i = 0; i < old.length; ++i )
|
||||||
|
templateArguments[i] = old[i];
|
||||||
|
}
|
||||||
|
templateArguments[ currentIndex++ ] = expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId#getTemplateArguments()
|
||||||
|
*/
|
||||||
|
public List getTemplateArguments() {
|
||||||
|
if( templateArguments == null ) return Collections.EMPTY_LIST;
|
||||||
|
removeNullArguments();
|
||||||
|
return Arrays.asList( templateArguments );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeNullArguments() {
|
||||||
|
int nullCount = 0;
|
||||||
|
for( int i = 0; i < templateArguments.length; ++i )
|
||||||
|
if( templateArguments[i] == null )
|
||||||
|
++nullCount;
|
||||||
|
if( nullCount == 0 ) return;
|
||||||
|
IASTNode [] old = templateArguments;
|
||||||
|
int newSize = old.length - nullCount;
|
||||||
|
templateArguments = new IASTNode[ newSize ];
|
||||||
|
for( int i = 0; i < newSize; ++i )
|
||||||
|
templateArguments[i] = old[i];
|
||||||
|
currentIndex = newSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int currentIndex = 0;
|
||||||
|
private IASTNode [] templateArguments = null;
|
||||||
|
private static final int DEFAULT_ARGS_LIST_SIZE = 4;
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTName#resolveBinding()
|
||||||
|
*/
|
||||||
|
public IBinding resolveBinding() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,99 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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 java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTTranslationUnit extends CPPASTNode implements
|
||||||
|
IASTTranslationUnit {
|
||||||
|
private IASTDeclaration [] decls = null;
|
||||||
|
private static final int DEFAULT_CHILDREN_LIST_SIZE = 8;
|
||||||
|
private int currentIndex = 0;
|
||||||
|
|
||||||
|
public void addDeclaration( IASTDeclaration d )
|
||||||
|
{
|
||||||
|
if( decls == null )
|
||||||
|
{
|
||||||
|
decls = new IASTDeclaration[ DEFAULT_CHILDREN_LIST_SIZE ];
|
||||||
|
currentIndex = 0;
|
||||||
|
}
|
||||||
|
if( decls.length == currentIndex )
|
||||||
|
{
|
||||||
|
IASTDeclaration [] old = decls;
|
||||||
|
decls = new IASTDeclaration[ old.length * 2 ];
|
||||||
|
for( int i = 0; i < old.length; ++i )
|
||||||
|
decls[i] = old[i];
|
||||||
|
}
|
||||||
|
decls[ currentIndex++ ] = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getDeclarations()
|
||||||
|
*/
|
||||||
|
public List getDeclarations() {
|
||||||
|
if( decls == null ) return Collections.EMPTY_LIST;
|
||||||
|
removeNullDeclarations();
|
||||||
|
return Arrays.asList( decls );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param decls2
|
||||||
|
*/
|
||||||
|
private void removeNullDeclarations() {
|
||||||
|
int nullCount = 0;
|
||||||
|
for( int i = 0; i < decls.length; ++i )
|
||||||
|
if( decls[i] == null )
|
||||||
|
++nullCount;
|
||||||
|
if( nullCount == 0 ) return;
|
||||||
|
IASTDeclaration [] old = decls;
|
||||||
|
int newSize = old.length - nullCount;
|
||||||
|
decls = new IASTDeclaration[ newSize ];
|
||||||
|
for( int i = 0; i < newSize; ++i )
|
||||||
|
decls[i] = old[i];
|
||||||
|
currentIndex = newSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getScope()
|
||||||
|
*/
|
||||||
|
public IScope getScope() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getDeclarations(org.eclipse.cdt.core.dom.ast.IBinding)
|
||||||
|
*/
|
||||||
|
public List getDeclarations(IBinding binding) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getReferences(org.eclipse.cdt.core.dom.ast.IBinding)
|
||||||
|
*/
|
||||||
|
public List getReferences(IBinding binding) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -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.IASTTypeId;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTTypeIdExpression extends CPPASTNode implements
|
||||||
|
IASTTypeIdExpression {
|
||||||
|
|
||||||
|
private int op;
|
||||||
|
private IASTTypeId typeId;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression#getOperator()
|
||||||
|
*/
|
||||||
|
public int getOperator() {
|
||||||
|
return op;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression#setOperator(int)
|
||||||
|
*/
|
||||||
|
public void setOperator(int value) {
|
||||||
|
this.op = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression#setTypeId(org.eclipse.cdt.core.dom.ast.IASTTypeId)
|
||||||
|
*/
|
||||||
|
public void setTypeId(IASTTypeId typeId) {
|
||||||
|
this.typeId = typeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression#getTypeId()
|
||||||
|
*/
|
||||||
|
public IASTTypeId getTypeId() {
|
||||||
|
return typeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTUnaryExpression extends CPPASTNode implements
|
||||||
|
IASTUnaryExpression {
|
||||||
|
|
||||||
|
private int operator;
|
||||||
|
private IASTExpression operand;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTUnaryExpression#getOperator()
|
||||||
|
*/
|
||||||
|
public int getOperator() {
|
||||||
|
return operator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTUnaryExpression#setOperator(int)
|
||||||
|
*/
|
||||||
|
public void setOperator(int value) {
|
||||||
|
this.operator = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTUnaryExpression#getOperand()
|
||||||
|
*/
|
||||||
|
public IASTExpression getOperand() {
|
||||||
|
return operand;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTUnaryExpression#setOperand(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||||
|
*/
|
||||||
|
public void setOperand(IASTExpression expression) {
|
||||||
|
operand = expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class CPPASTWhileStatement extends CPPASTNode implements
|
||||||
|
IASTWhileStatement {
|
||||||
|
private IASTExpression condition;
|
||||||
|
private IASTStatement body;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTWhileStatement#getCondition()
|
||||||
|
*/
|
||||||
|
public IASTExpression getCondition() {
|
||||||
|
return condition;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTWhileStatement#setCondition(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||||
|
*/
|
||||||
|
public void setCondition(IASTExpression condition) {
|
||||||
|
this.condition = condition;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTWhileStatement#getBody()
|
||||||
|
*/
|
||||||
|
public IASTStatement getBody() {
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTWhileStatement#setBody(org.eclipse.cdt.core.dom.ast.IASTStatement)
|
||||||
|
*/
|
||||||
|
public void setBody(IASTStatement body) {
|
||||||
|
this.body = body;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -14,43 +14,59 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTCaseStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTContinueStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDefaultStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDoStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
|
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTForStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
|
import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNullStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPointer;
|
import org.eclipse.cdt.core.dom.ast.IASTPointer;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
|
||||||
|
@ -78,6 +94,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
|
||||||
|
@ -110,23 +127,7 @@ import org.eclipse.cdt.internal.core.parser.TemplateParameterManager;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
|
import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
|
||||||
import org.eclipse.cdt.internal.core.parser2.ASTNode;
|
import org.eclipse.cdt.internal.core.parser2.ASTNode;
|
||||||
import org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser;
|
import org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser;
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTBinaryExpression;
|
import org.eclipse.cdt.internal.core.parser2.IProblemRequestor;
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTCompoundStatement;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTCompoundStatementExpression;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTConditionalExpression;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTEnumerator;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTExpressionList;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTFieldDeclarator;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTFunctionCallExpression;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTFunctionDefinition;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTIdExpression;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTInitializerExpresion;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTInitializerList;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTName;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTSimpleDeclaration;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTTranslationUnit;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTTypeIdExpression;
|
|
||||||
import org.eclipse.cdt.internal.core.parser2.c.CASTUnaryExpression;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is our implementation of the IParser interface, serving as a
|
* This is our implementation of the IParser interface, serving as a
|
||||||
|
@ -1514,7 +1515,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private IASTFunctionCallExpression createFunctionCallExpression() {
|
private IASTFunctionCallExpression createFunctionCallExpression() {
|
||||||
return new CASTFunctionCallExpression();
|
return new CPPASTFunctionCallExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1655,7 +1656,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected IASTIdExpression createIdExpression() {
|
protected IASTIdExpression createIdExpression() {
|
||||||
return new CASTIdExpression();
|
return new CPPASTIdExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ITokenDuple idExpression() throws EndOfFileException, BacktrackException
|
protected ITokenDuple idExpression() throws EndOfFileException, BacktrackException
|
||||||
|
@ -2350,7 +2351,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected ICPPASTQualifiedName createQualifiedName(ITokenDuple duple) {
|
protected ICPPASTQualifiedName createQualifiedName(ITokenDuple duple) {
|
||||||
CPPASTName result = new CPPASTName();
|
CPPASTQualifiedName result = new CPPASTQualifiedName();
|
||||||
result.setOffset( duple.getStartOffset());
|
result.setOffset( duple.getStartOffset());
|
||||||
ITokenDuple [] segments = duple.getSegments();
|
ITokenDuple [] segments = duple.getSegments();
|
||||||
for( int i = 0; i < segments.length; ++i )
|
for( int i = 0; i < segments.length; ++i )
|
||||||
|
@ -2377,8 +2378,35 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* @param duple
|
* @param duple
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private IASTName createTemplateID(ITokenDuple duple) {
|
protected ICPPASTTemplateId createTemplateID(ITokenDuple duple) {
|
||||||
return new CASTName(); //TODO - what is a template ID?
|
ICPPASTTemplateId result = new CPPASTTemplateId();
|
||||||
|
((ASTNode)result).setOffset( duple.getStartOffset() );
|
||||||
|
char [] image = duple.extractNameFromTemplateId();
|
||||||
|
CPPASTName templateIdName = (CPPASTName) createName();
|
||||||
|
templateIdName.setOffset(duple.getStartOffset());
|
||||||
|
templateIdName.setName( image );
|
||||||
|
result.setTemplateName( templateIdName );
|
||||||
|
templateIdName.setParent( result );
|
||||||
|
templateIdName.setPropertyInParent( ICPPASTTemplateId.TEMPLATE_NAME );
|
||||||
|
if( duple.getTemplateIdArgLists() != null )
|
||||||
|
{
|
||||||
|
List args = duple.getTemplateIdArgLists()[0];
|
||||||
|
if( args != null )
|
||||||
|
for( int i = 0; i < args.size(); ++i )
|
||||||
|
{
|
||||||
|
IASTNode n = (IASTNode) args.get(i);
|
||||||
|
if( n instanceof IASTTypeId || n instanceof IASTExpression )
|
||||||
|
{
|
||||||
|
n.setParent( result );
|
||||||
|
n.setPropertyInParent( ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT );
|
||||||
|
if( n instanceof IASTTypeId )
|
||||||
|
result.addTemplateArgument((IASTTypeId) n);
|
||||||
|
else
|
||||||
|
result.addTemplateArgument((IASTExpression)n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2388,7 +2416,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
protected IASTName createName(ITokenDuple duple) {
|
protected IASTName createName(ITokenDuple duple) {
|
||||||
if( duple == null ) return createName();
|
if( duple == null ) return createName();
|
||||||
if( duple.getSegmentCount() != 1 ) return createQualifiedName( duple );
|
if( duple.getSegmentCount() != 1 ) return createQualifiedName( duple );
|
||||||
CASTName name = new CASTName( duple.toCharArray() );
|
CPPASTName name = new CPPASTName( duple.toCharArray() );
|
||||||
name.setOffset( duple.getStartOffset());
|
name.setOffset( duple.getStartOffset());
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -2553,14 +2581,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected IASTFunctionDefinition createFunctionDefinition() {
|
protected IASTFunctionDefinition createFunctionDefinition() {
|
||||||
return new CASTFunctionDefinition();
|
return new CPPASTFunctionDefinition();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected IASTSimpleDeclaration createSimpleDeclaration() {
|
protected IASTSimpleDeclaration createSimpleDeclaration() {
|
||||||
return new CASTSimpleDeclaration();
|
return new CPPASTSimpleDeclaration();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3258,14 +3286,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected IASTInitializerList createInitializerList() {
|
protected IASTInitializerList createInitializerList() {
|
||||||
return new CASTInitializerList();
|
return new CPPASTInitializerList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private IASTInitializerExpression createInitializerExpression() {
|
private IASTInitializerExpression createInitializerExpression() {
|
||||||
return new CASTInitializerExpresion();
|
return new CPPASTInitializerExpresion();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3599,7 +3627,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private IASTFieldDeclarator createFieldDeclarator() {
|
private IASTFieldDeclarator createFieldDeclarator() {
|
||||||
return new CASTFieldDeclarator();
|
return new CPPASTFieldDeclarator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4100,7 +4128,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected IASTTranslationUnit createTranslationUnit() {
|
protected IASTTranslationUnit createTranslationUnit() {
|
||||||
return new CASTTranslationUnit();
|
return new CPPASTTranslationUnit();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void consumeArrayModifiers(List collection) throws EndOfFileException, BacktrackException {
|
protected void consumeArrayModifiers(List collection) throws EndOfFileException, BacktrackException {
|
||||||
|
@ -4143,63 +4171,63 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createCompoundStatement()
|
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createCompoundStatement()
|
||||||
*/
|
*/
|
||||||
protected IASTCompoundStatement createCompoundStatement() {
|
protected IASTCompoundStatement createCompoundStatement() {
|
||||||
return new CASTCompoundStatement();
|
return new CPPASTCompoundStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createBinaryExpression()
|
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createBinaryExpression()
|
||||||
*/
|
*/
|
||||||
protected IASTBinaryExpression createBinaryExpression() {
|
protected IASTBinaryExpression createBinaryExpression() {
|
||||||
return new CASTBinaryExpression();
|
return new CPPASTBinaryExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createConditionalExpression()
|
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createConditionalExpression()
|
||||||
*/
|
*/
|
||||||
protected IASTConditionalExpression createConditionalExpression() {
|
protected IASTConditionalExpression createConditionalExpression() {
|
||||||
return new CASTConditionalExpression();
|
return new CPPASTConditionalExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createUnaryExpression()
|
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createUnaryExpression()
|
||||||
*/
|
*/
|
||||||
protected IASTUnaryExpression createUnaryExpression() {
|
protected IASTUnaryExpression createUnaryExpression() {
|
||||||
return new CASTUnaryExpression();
|
return new CPPASTUnaryExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createCompoundStatementExpression()
|
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createCompoundStatementExpression()
|
||||||
*/
|
*/
|
||||||
protected IGNUASTCompoundStatementExpression createCompoundStatementExpression() {
|
protected IGNUASTCompoundStatementExpression createCompoundStatementExpression() {
|
||||||
return new CASTCompoundStatementExpression();
|
return new CPPASTCompoundStatementExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createExpressionList()
|
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createExpressionList()
|
||||||
*/
|
*/
|
||||||
protected IASTExpressionList createExpressionList() {
|
protected IASTExpressionList createExpressionList() {
|
||||||
return new CASTExpressionList();
|
return new CPPASTExpressionList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createName(org.eclipse.cdt.core.parser.IToken)
|
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createName(org.eclipse.cdt.core.parser.IToken)
|
||||||
*/
|
*/
|
||||||
protected IASTName createName(IToken token) {
|
protected IASTName createName(IToken token) {
|
||||||
return new CASTName( token.getCharImage() );
|
return new CPPASTName( token.getCharImage() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createName()
|
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createName()
|
||||||
*/
|
*/
|
||||||
protected IASTName createName() {
|
protected IASTName createName() {
|
||||||
return new CASTName();
|
return new CPPASTName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createEnumerator()
|
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createEnumerator()
|
||||||
*/
|
*/
|
||||||
protected IASTEnumerator createEnumerator() {
|
protected IASTEnumerator createEnumerator() {
|
||||||
return new CASTEnumerator();
|
return new CPPASTEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -4219,7 +4247,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected IASTTypeIdExpression createTypeIdExpression() {
|
protected IASTTypeIdExpression createTypeIdExpression() {
|
||||||
return new CASTTypeIdExpression();
|
return new CPPASTTypeIdExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -4229,5 +4257,372 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return new CPPASTEnumerationSpecifier();
|
return new CPPASTEnumerationSpecifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTLabelStatement createLabelStatement() {
|
||||||
|
return new CPPASTLabelStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTGotoStatement createGoToStatement() {
|
||||||
|
return new CPPASTGotoStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTReturnStatement createReturnStatement() {
|
||||||
|
return new CPPASTReturnStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTForStatement createForStatement() {
|
||||||
|
return new CPPASTForStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTContinueStatement createContinueStatement() {
|
||||||
|
return new CPPASTContinueStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTDoStatement createDoStatement() {
|
||||||
|
return new CPPASTDoStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTBreakStatement createBreakStatement() {
|
||||||
|
return new CPPASTBreakStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTWhileStatement createWhileStatement() {
|
||||||
|
return new CPPASTWhileStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTNullStatement createNullStatement() {
|
||||||
|
return new CPPASTNullStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTSwitchStatement createSwitchStatement() {
|
||||||
|
return new CPPASTSwitchStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTIfStatement createIfStatement() {
|
||||||
|
return new CPPASTIfStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTDefaultStatement createDefaultStatement() {
|
||||||
|
return new CPPASTDefaultStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTCaseStatement createCaseStatement() {
|
||||||
|
return new CPPASTCaseStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTExpressionStatement createExpressionStatement() {
|
||||||
|
return new CPPASTExpressionStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTDeclarationStatement createDeclarationStatement() {
|
||||||
|
return new CPPASTDeclarationStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTASMDeclaration createASMDirective() {
|
||||||
|
return new CPPASTASMDeclaration();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTCastExpression createCastExpression() {
|
||||||
|
return new CPPASTCastExpression();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IASTStatement statement() throws EndOfFileException, BacktrackException {
|
||||||
|
|
||||||
|
switch (LT(1)) {
|
||||||
|
// labeled statements
|
||||||
|
case IToken.t_case:
|
||||||
|
int startOffset = consume(IToken.t_case).getOffset();
|
||||||
|
IASTExpression case_exp = constantExpression();
|
||||||
|
consume(IToken.tCOLON);
|
||||||
|
cleanupLastToken();
|
||||||
|
IASTCaseStatement cs = createCaseStatement();
|
||||||
|
((ASTNode)cs).setOffset( startOffset );
|
||||||
|
cs.setExpression( case_exp );
|
||||||
|
case_exp.setParent( cs );
|
||||||
|
case_exp.setPropertyInParent( IASTCaseStatement.EXPRESSION );
|
||||||
|
return cs;
|
||||||
|
case IToken.t_default:
|
||||||
|
startOffset = consume(IToken.t_default).getOffset();
|
||||||
|
consume(IToken.tCOLON);
|
||||||
|
cleanupLastToken();
|
||||||
|
IASTDefaultStatement df = createDefaultStatement();
|
||||||
|
((ASTNode)df).setOffset( startOffset );
|
||||||
|
return df;
|
||||||
|
// compound statement
|
||||||
|
case IToken.tLBRACE:
|
||||||
|
IASTCompoundStatement compound = compoundStatement();
|
||||||
|
cleanupLastToken();
|
||||||
|
return compound;
|
||||||
|
// selection statement
|
||||||
|
case IToken.t_if:
|
||||||
|
startOffset = consume(IToken.t_if).getOffset();
|
||||||
|
consume(IToken.tLPAREN);
|
||||||
|
IASTExpression if_condition = condition();
|
||||||
|
consume(IToken.tRPAREN);
|
||||||
|
IASTStatement then_clause = statement();
|
||||||
|
IASTStatement else_clause = null;
|
||||||
|
if (LT(1) == IToken.t_else) {
|
||||||
|
consume(IToken.t_else);
|
||||||
|
else_clause = statement();
|
||||||
|
}
|
||||||
|
|
||||||
|
IASTIfStatement if_stmt = createIfStatement();
|
||||||
|
if_stmt.setCondition( if_condition );
|
||||||
|
((ASTNode)if_stmt).setOffset( startOffset );
|
||||||
|
if_condition.setParent( if_stmt );
|
||||||
|
if_condition.setPropertyInParent( IASTIfStatement.CONDITION );
|
||||||
|
if_stmt.setThenClause( then_clause );
|
||||||
|
then_clause.setParent( if_stmt );
|
||||||
|
then_clause.setPropertyInParent( IASTIfStatement.THEN );
|
||||||
|
if( else_clause != null )
|
||||||
|
{
|
||||||
|
if_stmt.setElseClause( else_clause );
|
||||||
|
else_clause.setParent( if_stmt );
|
||||||
|
else_clause.setPropertyInParent( IASTIfStatement.ELSE );
|
||||||
|
}
|
||||||
|
cleanupLastToken();
|
||||||
|
return if_stmt;
|
||||||
|
case IToken.t_switch:
|
||||||
|
startOffset = consume( IToken.t_switch ).getOffset();
|
||||||
|
consume(IToken.tLPAREN);
|
||||||
|
IASTExpression switch_condition = condition();
|
||||||
|
consume(IToken.tRPAREN);
|
||||||
|
IASTStatement switch_body = statement();
|
||||||
|
cleanupLastToken();
|
||||||
|
IASTSwitchStatement switch_statement = createSwitchStatement();
|
||||||
|
((ASTNode)switch_statement).setOffset( startOffset );
|
||||||
|
switch_statement.setController( switch_condition );
|
||||||
|
switch_condition.setParent( switch_statement );
|
||||||
|
switch_condition.setPropertyInParent( IASTSwitchStatement.CONTROLLER );
|
||||||
|
switch_statement.setBody( switch_body );
|
||||||
|
switch_body.setParent( switch_statement );
|
||||||
|
switch_body.setPropertyInParent( IASTSwitchStatement.BODY );
|
||||||
|
return switch_statement;
|
||||||
|
//iteration statements
|
||||||
|
case IToken.t_while:
|
||||||
|
startOffset = consume(IToken.t_while).getOffset();
|
||||||
|
consume(IToken.tLPAREN);
|
||||||
|
IASTExpression while_condition = condition();
|
||||||
|
consume(IToken.tRPAREN);
|
||||||
|
IASTStatement while_body = statement();
|
||||||
|
cleanupLastToken();
|
||||||
|
IASTWhileStatement while_statement = createWhileStatement();
|
||||||
|
((ASTNode)while_statement).setOffset( startOffset );
|
||||||
|
while_statement.setCondition( while_condition );
|
||||||
|
while_condition.setParent( while_statement );
|
||||||
|
while_condition.setPropertyInParent( IASTWhileStatement.CONDITION );
|
||||||
|
while_statement.setBody( while_body );
|
||||||
|
while_condition.setParent( while_statement );
|
||||||
|
while_condition.setPropertyInParent( IASTWhileStatement.BODY );
|
||||||
|
while_body.setParent( while_statement );
|
||||||
|
return while_statement;
|
||||||
|
case IToken.t_do:
|
||||||
|
startOffset = consume(IToken.t_do).getOffset();
|
||||||
|
IASTStatement do_body = statement();
|
||||||
|
consume(IToken.t_while);
|
||||||
|
consume(IToken.tLPAREN);
|
||||||
|
IASTExpression do_condition = condition();
|
||||||
|
consume(IToken.tRPAREN);
|
||||||
|
cleanupLastToken();
|
||||||
|
IASTDoStatement do_statement = createDoStatement();
|
||||||
|
((ASTNode)do_statement).setOffset( startOffset );
|
||||||
|
do_statement.setBody( do_body );
|
||||||
|
do_body.setParent( do_statement );
|
||||||
|
do_body.setPropertyInParent( IASTDoStatement.BODY );
|
||||||
|
do_statement.setCondition( do_condition );
|
||||||
|
do_condition.setParent( do_statement );
|
||||||
|
do_condition.setPropertyInParent( IASTDoStatement.CONDITION );
|
||||||
|
return do_statement;
|
||||||
|
case IToken.t_for:
|
||||||
|
startOffset = consume( IToken.t_for ).getOffset();
|
||||||
|
consume(IToken.tLPAREN);
|
||||||
|
IASTNode init = forInitStatement();
|
||||||
|
IASTExpression for_condition = null;
|
||||||
|
if (LT(1) != IToken.tSEMI)
|
||||||
|
for_condition = condition();
|
||||||
|
consume(IToken.tSEMI);
|
||||||
|
IASTExpression iterationExpression = null;
|
||||||
|
if (LT(1) != IToken.tRPAREN) {
|
||||||
|
iterationExpression = expression();
|
||||||
|
cleanupLastToken();
|
||||||
|
}
|
||||||
|
consume(IToken.tRPAREN);
|
||||||
|
IASTStatement for_body = statement();
|
||||||
|
cleanupLastToken();
|
||||||
|
IASTForStatement for_statement = createForStatement();
|
||||||
|
((ASTNode)for_statement).setOffset( startOffset );
|
||||||
|
if( init instanceof IASTDeclaration )
|
||||||
|
{
|
||||||
|
for_statement.setInit((IASTDeclaration) init);
|
||||||
|
((IASTDeclaration) init).setParent( for_statement );
|
||||||
|
((IASTDeclaration) init).setPropertyInParent( IASTForStatement.INITDECLARATION );
|
||||||
|
}
|
||||||
|
else if( init instanceof IASTExpression )
|
||||||
|
{
|
||||||
|
for_statement.setInit((IASTExpression) init);
|
||||||
|
((IASTExpression) init).setParent( for_statement );
|
||||||
|
((IASTExpression) init).setPropertyInParent( IASTForStatement.INITEXPRESSION );
|
||||||
|
}
|
||||||
|
if( for_condition != null )
|
||||||
|
{
|
||||||
|
for_statement.setCondition( for_condition );
|
||||||
|
for_condition.setParent( for_statement );
|
||||||
|
for_condition.setPropertyInParent( IASTForStatement.CONDITION );
|
||||||
|
}
|
||||||
|
if( iterationExpression != null )
|
||||||
|
{
|
||||||
|
for_statement.setIterationExpression( iterationExpression );
|
||||||
|
iterationExpression.setParent( for_statement );
|
||||||
|
iterationExpression.setPropertyInParent( IASTForStatement.ITERATION );
|
||||||
|
}
|
||||||
|
for_statement.setBody( for_body );
|
||||||
|
for_body.setParent( for_statement );
|
||||||
|
for_body.setPropertyInParent( IASTForStatement.BODY );
|
||||||
|
return for_statement;
|
||||||
|
//jump statement
|
||||||
|
case IToken.t_break:
|
||||||
|
startOffset = consume(IToken.t_break).getOffset();
|
||||||
|
consume(IToken.tSEMI);
|
||||||
|
cleanupLastToken();
|
||||||
|
IASTBreakStatement break_statement = createBreakStatement();
|
||||||
|
((ASTNode)break_statement).setOffset( startOffset );
|
||||||
|
return break_statement;
|
||||||
|
case IToken.t_continue:
|
||||||
|
startOffset = consume(IToken.t_continue).getOffset();
|
||||||
|
consume(IToken.tSEMI);
|
||||||
|
cleanupLastToken();
|
||||||
|
IASTContinueStatement continue_statement = createContinueStatement();
|
||||||
|
((ASTNode)continue_statement).setOffset( startOffset );
|
||||||
|
return continue_statement;
|
||||||
|
case IToken.t_return:
|
||||||
|
startOffset = consume(IToken.t_return).getOffset();
|
||||||
|
IASTExpression result = null;
|
||||||
|
if (LT(1) != IToken.tSEMI) {
|
||||||
|
result = expression();
|
||||||
|
cleanupLastToken();
|
||||||
|
}
|
||||||
|
consume(IToken.tSEMI);
|
||||||
|
cleanupLastToken();
|
||||||
|
IASTReturnStatement return_statement = createReturnStatement();
|
||||||
|
((ASTNode)return_statement).setOffset( startOffset );
|
||||||
|
if( result != null )
|
||||||
|
{
|
||||||
|
return_statement.setReturnValue( result );
|
||||||
|
result.setParent( return_statement );
|
||||||
|
result.setPropertyInParent( IASTReturnStatement.RETURNVALUE );
|
||||||
|
}
|
||||||
|
return return_statement;
|
||||||
|
case IToken.t_goto:
|
||||||
|
startOffset = consume(IToken.t_goto).getOffset();
|
||||||
|
IToken identifier = consume(IToken.tIDENTIFIER);
|
||||||
|
consume(IToken.tSEMI);
|
||||||
|
cleanupLastToken();
|
||||||
|
IASTName goto_label_name = createName( identifier );
|
||||||
|
IASTGotoStatement goto_statement = createGoToStatement();
|
||||||
|
((ASTNode)goto_statement).setOffset( startOffset );
|
||||||
|
goto_statement.setName( goto_label_name );
|
||||||
|
goto_label_name.setParent( goto_statement );
|
||||||
|
goto_label_name.setPropertyInParent( IASTGotoStatement.NAME );
|
||||||
|
return goto_statement;
|
||||||
|
case IToken.tSEMI:
|
||||||
|
startOffset = consume(IToken.tSEMI ).getOffset();
|
||||||
|
cleanupLastToken();
|
||||||
|
IASTNullStatement null_statement = createNullStatement();
|
||||||
|
((ASTNode)null_statement).setOffset( startOffset );
|
||||||
|
return null_statement;
|
||||||
|
default:
|
||||||
|
// can be many things:
|
||||||
|
// label
|
||||||
|
if (LT(1) == IToken.tIDENTIFIER && LT(2) == IToken.tCOLON) {
|
||||||
|
IToken labelName = consume(IToken.tIDENTIFIER);
|
||||||
|
consume(IToken.tCOLON);
|
||||||
|
IASTLabelStatement label_statement = createLabelStatement();
|
||||||
|
((ASTNode)label_statement).setOffset( labelName.getOffset() );
|
||||||
|
IASTName name = createName( labelName );
|
||||||
|
label_statement.setName( name );
|
||||||
|
name.setParent( label_statement );
|
||||||
|
name.setPropertyInParent( IASTLabelStatement.NAME );
|
||||||
|
return label_statement;
|
||||||
|
}
|
||||||
|
// expressionStatement
|
||||||
|
// Note: the function style cast ambiguity is handled in
|
||||||
|
// expression
|
||||||
|
// Since it only happens when we are in a statement
|
||||||
|
IToken mark = mark();
|
||||||
|
try {
|
||||||
|
IASTExpression expression = expression();
|
||||||
|
consume(IToken.tSEMI);
|
||||||
|
IASTExpressionStatement expressionStatement = createExpressionStatement();
|
||||||
|
expressionStatement.setExpression( expression );
|
||||||
|
expression.setParent( expressionStatement );
|
||||||
|
expression.setPropertyInParent( IASTExpressionStatement.EXPFRESSION );
|
||||||
|
cleanupLastToken();
|
||||||
|
return expressionStatement;
|
||||||
|
} catch (BacktrackException b) {
|
||||||
|
backup(mark);
|
||||||
|
}
|
||||||
|
|
||||||
|
// declarationStatement
|
||||||
|
IASTDeclaration d = declaration();
|
||||||
|
IASTDeclarationStatement ds = createDeclarationStatement();
|
||||||
|
ds.setDeclaration(d);
|
||||||
|
d.setParent( ds );
|
||||||
|
d.setPropertyInParent( IASTDeclarationStatement.DECLARATION );
|
||||||
|
cleanupLastToken();
|
||||||
|
return ds;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue