mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-09 09:15:38 +02:00
actions for templates, conversion functions and exceptions
This commit is contained in:
parent
10534b5968
commit
0b0508f728
7 changed files with 2725 additions and 2428 deletions
|
@ -84,9 +84,11 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
|
||||
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.ICPPASTSimpleTypeTemplateParameter;
|
||||
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.ICPPASTTemplateSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
||||
|
@ -157,10 +159,12 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTReturnStatement;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclSpecifier;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclaration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleTypeConstructorExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleTypeTemplateParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSwitchStatement;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTemplateId;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTemplateSpecialization;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTemplatedTypeTemplateParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTryBlockStatement;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTypeId;
|
||||
|
@ -521,4 +525,12 @@ public class CPPASTNodeFactory implements ICPPASTNodeFactory {
|
|||
return new CPPASTFieldDeclarator(name, bitFieldSize);
|
||||
}
|
||||
|
||||
public ICPPASTSimpleTypeTemplateParameter newSimpleTypeTemplateParameter(int type, IASTName name, IASTTypeId typeId) {
|
||||
return new CPPASTSimpleTypeTemplateParameter(type, name, typeId);
|
||||
}
|
||||
|
||||
public ICPPASTTemplatedTypeTemplateParameter newTemplatedTypeTemplateParameter(IASTName name, IASTExpression idExpression) {
|
||||
return new CPPASTTemplatedTypeTemplateParameter(name, idExpression);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -68,10 +68,12 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
|
||||
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.ICPPASTSimpleTypeTemplateParameter;
|
||||
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.ICPPASTTemplateSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
|
||||
|
@ -582,7 +584,7 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
|
|||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
||||
|
||||
IASTStatement body = (IASTStatement) astStack.pop();
|
||||
IASTDeclaration decl = (hasEllipsis) ? (IASTDeclaration) astStack.pop() : null;
|
||||
IASTDeclaration decl = hasEllipsis ? null : (IASTDeclaration) astStack.pop();
|
||||
|
||||
ICPPASTCatchHandler catchHandler = nodeFactory.newCatchHandler(decl, body);
|
||||
catchHandler.setIsCatchAll(hasEllipsis);
|
||||
|
@ -882,7 +884,7 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
|
|||
|
||||
/**
|
||||
* template_declaration
|
||||
* ::= export_opt 'template' '<' template_parameter_list '>' declaration
|
||||
* ::= export_opt 'template' '<' <openscope-ast> template_parameter_list '>' declaration
|
||||
*/
|
||||
public void consumeTemplateDeclaration() {
|
||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
||||
|
@ -1428,8 +1430,66 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
|
|||
}
|
||||
|
||||
declarator.setInitializer(initializer);
|
||||
|
||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* type_parameter
|
||||
* ::= 'class' identifier_name_opt -- simple type template parameter
|
||||
* | 'class' identifier_name_opt '=' type_id
|
||||
* | 'typename' identifier_name_opt
|
||||
* | 'typename' identifier_name_opt '=' type_id
|
||||
*/
|
||||
public void consumeSimpleTypeTemplateParameter(boolean hasTypeId) {
|
||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
||||
|
||||
IASTTypeId typeId = hasTypeId ? (IASTTypeId)astStack.pop() : null;
|
||||
|
||||
IASTName name = (IASTName)astStack.pop();
|
||||
int type = getTemplateParameterType(parser.getLeftIToken());
|
||||
|
||||
ICPPASTSimpleTypeTemplateParameter templateParameter = nodeFactory.newSimpleTypeTemplateParameter(type, name, typeId);
|
||||
|
||||
setOffsetAndLength(templateParameter);
|
||||
astStack.push(templateParameter);
|
||||
|
||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
||||
}
|
||||
|
||||
private static int getTemplateParameterType(IToken token) {
|
||||
switch(token.getKind()) {
|
||||
default: assert false;
|
||||
case TK_class: return ICPPASTSimpleTypeTemplateParameter.st_class;
|
||||
case TK_typename: return ICPPASTSimpleTypeTemplateParameter.st_typename;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* type_parameter
|
||||
* ::= 'template' '<' <openscope-ast> template_parameter_list '>' 'class' identifier_name_opt
|
||||
* | 'template' '<' <openscope-ast> template_parameter_list '>' 'class' identifier_name_opt '=' id_expression
|
||||
* @param hasIdExpr
|
||||
*/
|
||||
public void consumeTemplatedTypeTemplateParameter(boolean hasIdExpr) {
|
||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
||||
|
||||
IASTExpression idExpression = hasIdExpr ? (IASTExpression)astStack.pop() : null;
|
||||
IASTName name = (IASTName) astStack.pop();
|
||||
|
||||
ICPPASTTemplatedTypeTemplateParameter templateParameter = nodeFactory.newTemplatedTypeTemplateParameter(name, idExpression);
|
||||
|
||||
for(Object param : astStack.closeScope())
|
||||
templateParameter.addTemplateParamter((ICPPASTTemplateParameter)param);
|
||||
|
||||
setOffsetAndLength(templateParameter);
|
||||
astStack.push(templateParameter);
|
||||
|
||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -40,9 +40,11 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
|
||||
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.ICPPASTSimpleTypeTemplateParameter;
|
||||
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.ICPPASTTemplateSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
||||
|
@ -122,8 +124,11 @@ public interface ICPPASTNodeFactory extends IASTNodeFactory {
|
|||
|
||||
public ICPPASTFunctionDeclarator newCPPFunctionDeclarator(IASTName name);
|
||||
|
||||
public ICPPASTConstructorChainInitializer newConstructorChainInitializer(
|
||||
IASTName name, IASTExpression expr);
|
||||
public ICPPASTConstructorChainInitializer newConstructorChainInitializer(IASTName name, IASTExpression expr);
|
||||
|
||||
public ICPPASTFunctionTryBlockDeclarator newFunctionTryBlockDeclarator(IASTName name);
|
||||
|
||||
public ICPPASTSimpleTypeTemplateParameter newSimpleTypeTemplateParameter(int type, IASTName name, IASTTypeId typeId);
|
||||
|
||||
public ICPPASTTemplatedTypeTemplateParameter newTemplatedTypeTemplateParameter(IASTName name, IASTExpression idExpression);
|
||||
}
|
||||
|
|
|
@ -358,7 +358,11 @@ primary_expression
|
|||
::= literal
|
||||
| '(' expression ')'
|
||||
/. $Build consumeExpressionBracketed(); $EndBuild ./
|
||||
| qualified_or_unqualified_name
|
||||
| id_expression
|
||||
|
||||
|
||||
id_expression
|
||||
::= qualified_or_unqualified_name
|
||||
/. $Build consumeExpressionName(); $EndBuild ./
|
||||
|
||||
|
||||
|
@ -1251,9 +1255,9 @@ ptr_operator_seq
|
|||
| ptr_operator_seq ptr_operator
|
||||
|
||||
|
||||
ptr_operator_seq_opt
|
||||
::= ptr_operator_seq
|
||||
| $empty
|
||||
--ptr_operator_seq_opt
|
||||
-- ::= ptr_operator_seq
|
||||
-- | $empty
|
||||
|
||||
|
||||
cv_qualifier_seq
|
||||
|
@ -1564,16 +1568,20 @@ conversion_function_id_name
|
|||
|
||||
|
||||
conversion_type_id
|
||||
::= type_specifier_seq conversion_declarator_opt
|
||||
::= type_specifier_seq conversion_declarator
|
||||
/. $Build consumeTypeId(true); $EndBuild ./
|
||||
| type_specifier_seq
|
||||
/. $Build consumeTypeId(false); $EndBuild ./
|
||||
|
||||
|
||||
conversion_declarator
|
||||
::= ptr_operator conversion_declarator_opt
|
||||
|
||||
::= <openscope-ast> ptr_operator_seq
|
||||
/. $Build consumeDeclaratorWithPointer(false); $EndBuild ./
|
||||
|
||||
|
||||
conversion_declarator_opt
|
||||
::= conversion_declarator
|
||||
| $empty
|
||||
--conversion_declarator_opt
|
||||
-- ::= conversion_declarator
|
||||
-- | $empty
|
||||
|
||||
|
||||
ctor_initializer_list
|
||||
|
@ -1622,7 +1630,7 @@ overloadable_operator
|
|||
|
||||
|
||||
template_declaration
|
||||
::= export_opt 'template' '<' template_parameter_list '>' declaration
|
||||
::= export_opt 'template' '<' <openscope-ast> template_parameter_list '>' declaration
|
||||
/. $Build consumeTemplateDeclaration(); $EndBuild ./
|
||||
|
||||
|
||||
|
@ -1644,12 +1652,18 @@ template_parameter
|
|||
|
||||
|
||||
type_parameter
|
||||
::= 'class' identifier_opt
|
||||
| 'class' identifier_opt '=' type_id
|
||||
| 'typename' identifier_opt
|
||||
| 'typename' identifier_opt '=' type_id
|
||||
| 'template' '<' template_parameter_list '>' 'class' identifier_opt
|
||||
| 'template' '<' template_parameter_list '>' 'class' identifier_opt '=' qualified_or_unqualified_name
|
||||
::= 'class' identifier_name_opt
|
||||
/. $Build consumeSimpleTypeTemplateParameter(false); $EndBuild ./
|
||||
| 'class' identifier_name_opt '=' type_id
|
||||
/. $Build consumeSimpleTypeTemplateParameter(true); $EndBuild ./
|
||||
| 'typename' identifier_name_opt
|
||||
/. $Build consumeSimpleTypeTemplateParameter(false); $EndBuild ./
|
||||
| 'typename' identifier_name_opt '=' type_id
|
||||
/. $Build consumeSimpleTypeTemplateParameter(true); $EndBuild ./
|
||||
| 'template' '<' <openscope-ast> template_parameter_list '>' 'class' identifier_name_opt
|
||||
/. $Build consumeTemplatedTypeTemplateParameter(false); $EndBuild ./
|
||||
| 'template' '<' <openscope-ast> template_parameter_list '>' 'class' identifier_name_opt '=' id_expression
|
||||
/. $Build consumeTemplatedTypeTemplateParameter(true); $EndBuild ./
|
||||
|
||||
|
||||
-- pushes name node on stack
|
||||
|
@ -1707,10 +1721,14 @@ handler
|
|||
/. $Build consumeStatementCatchHandler(true); $EndBuild ./
|
||||
|
||||
|
||||
-- open a scope just so that we can reuse consumeDeclarationSimple()
|
||||
exception_declaration
|
||||
::= type_specifier_seq declarator
|
||||
| type_specifier_seq abstract_declarator
|
||||
::= type_specifier_seq <openscope-ast> declarator
|
||||
/. $Build consumeDeclarationSimple(true); $EndBuild ./
|
||||
| type_specifier_seq <openscope-ast> abstract_declarator
|
||||
/. $Build consumeDeclarationSimple(true); $EndBuild ./
|
||||
| type_specifier_seq
|
||||
/. $Build consumeDeclarationSimple(false); $EndBuild ./
|
||||
|
||||
|
||||
-- puts type ids on the stack
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -15,7 +15,7 @@ package org.eclipse.cdt.internal.core.dom.lrparser.cpp;
|
|||
|
||||
public interface CPPParsersym {
|
||||
public final static int
|
||||
TK_asm = 63,
|
||||
TK_asm = 62,
|
||||
TK_auto = 49,
|
||||
TK_bool = 13,
|
||||
TK_break = 76,
|
||||
|
@ -48,7 +48,7 @@ public interface CPPParsersym {
|
|||
TK_mutable = 53,
|
||||
TK_namespace = 60,
|
||||
TK_new = 42,
|
||||
TK_operator = 5,
|
||||
TK_operator = 6,
|
||||
TK_private = 116,
|
||||
TK_protected = 117,
|
||||
TK_public = 118,
|
||||
|
@ -97,7 +97,7 @@ public interface CPPParsersym {
|
|||
TK_PlusPlus = 11,
|
||||
TK_MinusMinus = 12,
|
||||
TK_And = 7,
|
||||
TK_Star = 6,
|
||||
TK_Star = 5,
|
||||
TK_Plus = 8,
|
||||
TK_Minus = 9,
|
||||
TK_Tilde = 4,
|
||||
|
@ -106,7 +106,7 @@ public interface CPPParsersym {
|
|||
TK_Percent = 90,
|
||||
TK_RightShift = 86,
|
||||
TK_LeftShift = 87,
|
||||
TK_LT = 62,
|
||||
TK_LT = 63,
|
||||
TK_GT = 67,
|
||||
TK_LE = 91,
|
||||
TK_GE = 92,
|
||||
|
@ -146,8 +146,8 @@ public interface CPPParsersym {
|
|||
"LeftParen",
|
||||
"ColonColon",
|
||||
"Tilde",
|
||||
"operator",
|
||||
"Star",
|
||||
"operator",
|
||||
"And",
|
||||
"Plus",
|
||||
"Minus",
|
||||
|
@ -203,8 +203,8 @@ public interface CPPParsersym {
|
|||
"LeftBrace",
|
||||
"namespace",
|
||||
"LeftBracket",
|
||||
"LT",
|
||||
"asm",
|
||||
"LT",
|
||||
"enum",
|
||||
"struct",
|
||||
"union",
|
||||
|
|
Loading…
Add table
Reference in a new issue