mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 08:46:02 +02:00
cleaned up grammar files and actions a bit
This commit is contained in:
parent
28e80032cf
commit
5b09380625
28 changed files with 3610 additions and 6160 deletions
|
@ -9,13 +9,9 @@
|
||||||
-- IBM Corporation - initial API and implementation
|
-- IBM Corporation - initial API and implementation
|
||||||
-----------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- TODO "complete" rules can be removed
|
|
||||||
|
|
||||||
-- TODO when the architecture has solidified try to move common
|
|
||||||
-- stuff between C99 and C++ into one file.
|
|
||||||
|
|
||||||
$Include
|
$Include
|
||||||
common.g
|
../common.g
|
||||||
$End
|
$End
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,25 +30,20 @@ $End
|
||||||
|
|
||||||
$Define
|
$Define
|
||||||
-- These macros allow the template and header code to be customized by an extending parser.
|
-- These macros allow the template and header code to be customized by an extending parser.
|
||||||
$ast_class /.Object./
|
|
||||||
$data_class /. Object ./ -- allow anything to be passed between actions
|
|
||||||
|
|
||||||
$extra_interfaces /. ./
|
$ast_class /.Object./
|
||||||
|
|
||||||
|
$extra_interfaces /. ./ -- can override this macro to provide additional interfaces
|
||||||
$additional_interfaces /. , IParserActionTokenProvider, IParser $extra_interfaces ./
|
$additional_interfaces /. , IParserActionTokenProvider, IParser $extra_interfaces ./
|
||||||
|
|
||||||
$build_action_class /. ./
|
$build_action_class /. ./ -- name of the class that has the AST building callbacks
|
||||||
$resolve_action_class /. ./
|
$node_factory_create_expression /. ./ -- expression that will create the node factory
|
||||||
$node_factory_create_expression /. ./
|
|
||||||
|
|
||||||
$lexer_class /. ./
|
$Build /. $BeginAction action. ./ -- special action just for calling methods on the builder
|
||||||
$action_class /. ./
|
|
||||||
|
|
||||||
$Build /. $BeginAction action. ./
|
|
||||||
$EndBuild /. $EndAction ./
|
$EndBuild /. $EndAction ./
|
||||||
$End
|
$End
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$Globals
|
$Globals
|
||||||
/.
|
/.
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -109,8 +104,9 @@ $Headers
|
||||||
return $sym_type.orderedTerminalSymbols;
|
return $sym_type.orderedTerminalSymbols;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("nls")
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "$action_type"; //$NON-NLS-1$
|
return "$action_type";
|
||||||
}
|
}
|
||||||
|
|
||||||
./
|
./
|
|
@ -9,23 +9,10 @@
|
||||||
-- IBM Corporation - initial API and implementation
|
-- IBM Corporation - initial API and implementation
|
||||||
----------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------
|
||||||
|
|
||||||
$Notice
|
|
||||||
-- Copied into all files generated by LPG
|
|
||||||
/./*******************************************************************************
|
|
||||||
* Copyright (c) 2006, 2008 IBM Corporation and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/epl_v10.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* IBM Corporation - initial API and implementation
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
// This file was generated by LPG
|
|
||||||
./
|
|
||||||
$End
|
|
||||||
|
|
||||||
|
$Include
|
||||||
|
../common.g
|
||||||
|
$End
|
||||||
|
|
||||||
|
|
||||||
$Terminals
|
$Terminals
|
||||||
|
@ -118,157 +105,16 @@ $End
|
||||||
|
|
||||||
$Globals
|
$Globals
|
||||||
/.
|
/.
|
||||||
import java.util.*;
|
import org.eclipse.cdt.core.dom.ast.cpp.*;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.*;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.*;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPNodeFactory;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPNodeFactory;
|
||||||
import org.eclipse.cdt.core.dom.lrparser.action.cpp.CPPBuildASTParserAction;
|
import org.eclipse.cdt.core.dom.lrparser.action.cpp.CPPBuildASTParserAction;
|
||||||
import org.eclipse.cdt.core.dom.lrparser.IParser;
|
|
||||||
import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
|
|
||||||
import org.eclipse.cdt.core.dom.lrparser.lpgextensions.FixedBacktrackingParser;
|
|
||||||
./
|
./
|
||||||
$End
|
$End
|
||||||
|
|
||||||
-- TODO move as much code and macros as possible into a common file
|
|
||||||
|
|
||||||
$Define
|
$Define
|
||||||
-- These macros allow the template and header code to be customized by an extending parser.
|
|
||||||
$ast_class /.Object./
|
|
||||||
$additional_interfaces /. , IParserActionTokenProvider, IParser ./
|
|
||||||
|
|
||||||
$build_action_class /. CPPBuildASTParserAction ./
|
$build_action_class /. CPPBuildASTParserAction ./
|
||||||
$resolve_action_class /. C99TypedefTrackerParserAction ./
|
|
||||||
$node_factory_create_expression /. CPPNodeFactory.getDefault() ./
|
$node_factory_create_expression /. CPPNodeFactory.getDefault() ./
|
||||||
|
|
||||||
$action_class /. CPPParserAction ./
|
|
||||||
$data_class /. Object ./ -- allow anything to be passed between actions
|
|
||||||
|
|
||||||
$UndoResolver /.$Undo action.resolver.undo(); $EndUndo./
|
|
||||||
|
|
||||||
$Resolve /. $BeginTrial $resolve.
|
|
||||||
./
|
|
||||||
$EndResolve /. $EndTrial
|
|
||||||
$UndoResolver
|
|
||||||
./ -- undo actions are automatically generated for binding resolution actions
|
|
||||||
|
|
||||||
$Builder /. $BeginFinal $builder.
|
|
||||||
./
|
|
||||||
$EndBuilder /. $EndFinal ./
|
|
||||||
|
|
||||||
$Build /. $Action $Builder ./
|
|
||||||
$EndBuild /. $EndBuilder $EndAction ./
|
|
||||||
|
|
||||||
$resolve /. action.resolver./
|
|
||||||
$builder /. action.builder./
|
|
||||||
|
|
||||||
-- comment out when using trial/undo
|
|
||||||
$Action /. $BeginAction ./
|
|
||||||
$BeginFinal /. ./
|
|
||||||
$EndFinal /. ./
|
|
||||||
|
|
||||||
$End
|
|
||||||
|
|
||||||
|
|
||||||
$Headers
|
|
||||||
/.
|
|
||||||
private $action_class action;
|
|
||||||
|
|
||||||
// uncomment to use with backtracking parser
|
|
||||||
public $action_type() { // constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
|
|
||||||
// binding resolution actions need access to IASTName nodes, temporary
|
|
||||||
action = new $action_class();
|
|
||||||
//action.resolver = new $resolve_action_class(this);
|
|
||||||
action.builder = new $build_action_class($node_factory_create_expression, this, tu);
|
|
||||||
//action.builder.setTokenMap(CPPParsersym.orderedTerminalSymbols);
|
|
||||||
|
|
||||||
action.builder.setParserOptions(options);
|
|
||||||
|
|
||||||
// comment this line to use with backtracking parser
|
|
||||||
//setParserAction(action);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void addToken(IToken token) {
|
|
||||||
token.setKind(mapKind(token.getKind()));
|
|
||||||
super.addToken(token);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public IASTCompletionNode parse(IASTTranslationUnit tu, Set<IParser.Options> options) {
|
|
||||||
// this has to be done, or... kaboom!
|
|
||||||
setStreamLength(getSize());
|
|
||||||
initActions(tu, options);
|
|
||||||
|
|
||||||
final int errorRepairCount = -1; // _1 means full error handling
|
|
||||||
parser(null, errorRepairCount); // do the actual parse
|
|
||||||
super.resetTokenStream(); // allow tokens to be garbage collected
|
|
||||||
|
|
||||||
// the completion node may be null
|
|
||||||
IASTCompletionNode compNode = action.builder.getASTCompletionNode();
|
|
||||||
|
|
||||||
//action = null; // causes getSecondaryParseResult() to fail
|
|
||||||
|
|
||||||
// Comment this line to use with backtracking parser
|
|
||||||
//parserAction = null;
|
|
||||||
|
|
||||||
return compNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// uncomment this method to use with backtracking parser
|
|
||||||
public List getRuleTokens() {
|
|
||||||
return Collections.unmodifiableList(getTokens().subList(getLeftSpan(), getRightSpan() + 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
public IASTNode getSecondaryParseResult() {
|
|
||||||
return action.builder.getSecondaryParseResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getOrderedTerminalSymbols() {
|
|
||||||
return $sym_type.orderedTerminalSymbols;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return "$action_type"; //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
./
|
|
||||||
$End
|
|
||||||
|
|
||||||
-- TODO this has to be moved into a common file
|
|
||||||
|
|
||||||
$Globals
|
|
||||||
/.
|
|
||||||
import org.eclipse.cdt.core.dom.lrparser.action.ITokenMap;
|
|
||||||
import org.eclipse.cdt.core.dom.lrparser.action.TokenMap;
|
|
||||||
./
|
|
||||||
$End
|
|
||||||
|
|
||||||
$Headers
|
|
||||||
/.
|
|
||||||
|
|
||||||
private ITokenMap tokenMap = null;
|
|
||||||
|
|
||||||
public void setTokens(List<IToken> tokens) {
|
|
||||||
resetTokenStream();
|
|
||||||
addToken(new Token(null, 0, 0, 0)); // dummy token
|
|
||||||
for(IToken token : tokens) {
|
|
||||||
token.setKind(tokenMap.mapKind(token.getKind()));
|
|
||||||
addToken(token);
|
|
||||||
}
|
|
||||||
addToken(new Token(null, 0, 0, $sym_type.TK_EOF_TOKEN));
|
|
||||||
}
|
|
||||||
|
|
||||||
public $action_type(String[] mapFrom) { // constructor
|
|
||||||
tokenMap = new TokenMap($sym_type.orderedTerminalSymbols, mapFrom);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
./
|
|
||||||
$End
|
$End
|
||||||
|
|
||||||
|
|
||||||
|
@ -281,11 +127,11 @@ $Rules
|
||||||
|
|
||||||
<openscope-ast>
|
<openscope-ast>
|
||||||
::= $empty
|
::= $empty
|
||||||
/.$Action $Builder openASTScope(); $EndBuilder $EndAction./
|
/. $Build openASTScope(); $EndBuild ./
|
||||||
|
|
||||||
<empty>
|
<empty>
|
||||||
::= $empty
|
::= $empty
|
||||||
/.$Action $Builder consumeEmpty(); $EndBuilder $EndAction./
|
/. $Build consumeEmpty(); $EndBuild ./
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------
|
||||||
-- Content assist
|
-- Content assist
|
||||||
|
@ -1596,11 +1442,11 @@ base_specifier
|
||||||
|
|
||||||
access_specifier_keyword
|
access_specifier_keyword
|
||||||
::= 'private'
|
::= 'private'
|
||||||
/. $Build consumeAccessKeywordToken(); $EndBuild ./
|
/. $Build consumeToken(); $EndBuild ./
|
||||||
| 'protected'
|
| 'protected'
|
||||||
/. $Build consumeAccessKeywordToken(); $EndBuild ./
|
/. $Build consumeToken(); $EndBuild ./
|
||||||
| 'public'
|
| 'public'
|
||||||
/. $Build consumeAccessKeywordToken(); $EndBuild ./
|
/. $Build consumeToken(); $EndBuild ./
|
||||||
|
|
||||||
|
|
||||||
access_specifier_keyword_opt
|
access_specifier_keyword_opt
|
||||||
|
|
|
@ -72,7 +72,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression;
|
||||||
import org.eclipse.cdt.core.dom.lrparser.IParser;
|
import org.eclipse.cdt.core.dom.lrparser.IParser;
|
||||||
import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
|
import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
|
||||||
import org.eclipse.cdt.core.parser.IProblem;
|
import org.eclipse.cdt.core.parser.IProblem;
|
||||||
import org.eclipse.cdt.core.parser.util.DebugUtil;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit;
|
||||||
|
@ -99,12 +98,7 @@ public abstract class BuildASTParserAction {
|
||||||
* @see BuildASTParserAction#consumeEmpty()
|
* @see BuildASTParserAction#consumeEmpty()
|
||||||
*/
|
*/
|
||||||
protected static final Object PLACE_HOLDER = Boolean.TRUE; // any object will do
|
protected static final Object PLACE_HOLDER = Boolean.TRUE; // any object will do
|
||||||
|
|
||||||
|
|
||||||
// turn debug tracing on and off
|
|
||||||
// TODO move this into an AspectJ project
|
|
||||||
protected static final boolean TRACE_ACTIONS = false;
|
|
||||||
protected static final boolean TRACE_AST_STACK = false;
|
|
||||||
|
|
||||||
|
|
||||||
/** Stack that holds the intermediate nodes as the AST is being built */
|
/** Stack that holds the intermediate nodes as the AST is being built */
|
||||||
|
@ -373,7 +367,6 @@ public abstract class BuildASTParserAction {
|
||||||
* Start of actions.
|
* Start of actions.
|
||||||
************************************************************************************************************/
|
************************************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method that is called by the special <openscope> production
|
* Method that is called by the special <openscope> production
|
||||||
|
@ -384,7 +377,6 @@ public abstract class BuildASTParserAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Place null on the stack.
|
* Place null on the stack.
|
||||||
* Usually called for optional element to indicate the element
|
* Usually called for optional element to indicate the element
|
||||||
|
@ -403,21 +395,15 @@ public abstract class BuildASTParserAction {
|
||||||
* cases like an optional keyword this action is useful.
|
* cases like an optional keyword this action is useful.
|
||||||
*/
|
*/
|
||||||
public void consumePlaceHolder() {
|
public void consumePlaceHolder() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
astStack.push(PLACE_HOLDER);
|
astStack.push(PLACE_HOLDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current token and places it on the stack for later consumption.
|
* Gets the current token and places it on the stack for later consumption.
|
||||||
*/
|
*/
|
||||||
public void consumeDeclSpecToken() {
|
public void consumeDeclSpecToken() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
astStack.push(parser.getRightIToken());
|
astStack.push(parser.getRightIToken());
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -425,18 +411,12 @@ public abstract class BuildASTParserAction {
|
||||||
* Gets the current token and places it on the stack for later consumption.
|
* Gets the current token and places it on the stack for later consumption.
|
||||||
*/
|
*/
|
||||||
public void consumeToken() {
|
public void consumeToken() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
astStack.push(parser.getRightIToken());
|
astStack.push(parser.getRightIToken());
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void consumeTranslationUnit() {
|
public void consumeTranslationUnit() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
// can't close the outermost scope
|
// can't close the outermost scope
|
||||||
// the outermost scope may be empty if there are no tokens in the file
|
// the outermost scope may be empty if there are no tokens in the file
|
||||||
for(Object o : astStack.topScope()) {
|
for(Object o : astStack.topScope()) {
|
||||||
|
@ -452,8 +432,6 @@ public abstract class BuildASTParserAction {
|
||||||
|
|
||||||
resolveAmbiguityNodes();
|
resolveAmbiguityNodes();
|
||||||
tu.freeze();
|
tu.freeze();
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -469,7 +447,7 @@ public abstract class BuildASTParserAction {
|
||||||
* ambiguity nodes were created.
|
* ambiguity nodes were created.
|
||||||
*/
|
*/
|
||||||
private void resolveAmbiguityNodes() {
|
private void resolveAmbiguityNodes() {
|
||||||
tu.accept(EMPTY_VISITOR); // TODO make sure the DOM parser still does it this way
|
tu.accept(EMPTY_VISITOR);
|
||||||
if (tu instanceof ASTTranslationUnit) {
|
if (tu instanceof ASTTranslationUnit) {
|
||||||
((ASTTranslationUnit)tu).cleanupAfterAmbiguityResolution();
|
((ASTTranslationUnit)tu).cleanupAfterAmbiguityResolution();
|
||||||
}
|
}
|
||||||
|
@ -484,16 +462,11 @@ public abstract class BuildASTParserAction {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Consumes a single identifier token.
|
* Consumes a single identifier token.
|
||||||
*/
|
*/
|
||||||
public void consumeIdentifierName() {
|
public void consumeIdentifierName() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
astStack.push(createName(parser.getRightIToken()));
|
astStack.push(createName(parser.getRightIToken()));
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -503,8 +476,6 @@ public abstract class BuildASTParserAction {
|
||||||
* TODO, be careful where exactly in the grammar this is called, it may be called unnecessarily
|
* TODO, be careful where exactly in the grammar this is called, it may be called unnecessarily
|
||||||
*/
|
*/
|
||||||
public void consumeStatementDeclarationWithDisambiguation() {
|
public void consumeStatementDeclarationWithDisambiguation() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTDeclaration decl = (IASTDeclaration) astStack.pop();
|
IASTDeclaration decl = (IASTDeclaration) astStack.pop();
|
||||||
IASTDeclarationStatement declarationStatement = nodeFactory.newDeclarationStatement(decl);
|
IASTDeclarationStatement declarationStatement = nodeFactory.newDeclarationStatement(decl);
|
||||||
setOffsetAndLength(declarationStatement);
|
setOffsetAndLength(declarationStatement);
|
||||||
|
@ -542,8 +513,6 @@ public abstract class BuildASTParserAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
astStack.push(result);
|
astStack.push(result);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -555,14 +524,10 @@ public abstract class BuildASTParserAction {
|
||||||
* Wrap a declaration in a DeclarationStatement.
|
* Wrap a declaration in a DeclarationStatement.
|
||||||
*/
|
*/
|
||||||
public void consumeStatementDeclaration() {
|
public void consumeStatementDeclaration() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTDeclaration decl = (IASTDeclaration) astStack.pop();
|
IASTDeclaration decl = (IASTDeclaration) astStack.pop();
|
||||||
IASTDeclarationStatement declarationStatement = nodeFactory.newDeclarationStatement(decl);
|
IASTDeclarationStatement declarationStatement = nodeFactory.newDeclarationStatement(decl);
|
||||||
setOffsetAndLength(declarationStatement);
|
setOffsetAndLength(declarationStatement);
|
||||||
astStack.push(declarationStatement);
|
astStack.push(declarationStatement);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -598,8 +563,6 @@ public abstract class BuildASTParserAction {
|
||||||
* @see ICPPASTLiteralExpression
|
* @see ICPPASTLiteralExpression
|
||||||
*/
|
*/
|
||||||
public void consumeExpressionLiteral(int kind) {
|
public void consumeExpressionLiteral(int kind) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IToken token = parser.getRightIToken();
|
IToken token = parser.getRightIToken();
|
||||||
String rep = token.toString();
|
String rep = token.toString();
|
||||||
|
|
||||||
|
@ -613,47 +576,32 @@ public abstract class BuildASTParserAction {
|
||||||
IASTLiteralExpression expr = nodeFactory.newLiteralExpression(kind, rep);
|
IASTLiteralExpression expr = nodeFactory.newLiteralExpression(kind, rep);
|
||||||
setOffsetAndLength(expr, token);
|
setOffsetAndLength(expr, token);
|
||||||
astStack.push(expr);
|
astStack.push(expr);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void consumeExpressionBracketed() {
|
public void consumeExpressionBracketed() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTExpression operand = (IASTExpression) astStack.pop();
|
IASTExpression operand = (IASTExpression) astStack.pop();
|
||||||
IASTUnaryExpression expr = nodeFactory.newUnaryExpression(IASTUnaryExpression.op_bracketedPrimary, operand);
|
IASTUnaryExpression expr = nodeFactory.newUnaryExpression(IASTUnaryExpression.op_bracketedPrimary, operand);
|
||||||
setOffsetAndLength(expr);
|
setOffsetAndLength(expr);
|
||||||
astStack.push(expr);
|
astStack.push(expr);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void consumeExpressionID() {
|
public void consumeExpressionID() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
//IASTName name = createName(parser.getRightIToken());
|
|
||||||
IASTName name = createName(parser.getLeftIToken());
|
IASTName name = createName(parser.getLeftIToken());
|
||||||
IASTIdExpression expr = nodeFactory.newIdExpression(name);
|
IASTIdExpression expr = nodeFactory.newIdExpression(name);
|
||||||
setOffsetAndLength(expr);
|
setOffsetAndLength(expr);
|
||||||
astStack.push(expr);
|
astStack.push(expr);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void consumeExpressionName() {
|
public void consumeExpressionName() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTName name = (IASTName) astStack.pop();
|
IASTName name = (IASTName) astStack.pop();
|
||||||
IASTIdExpression expr = nodeFactory.newIdExpression(name);
|
IASTIdExpression expr = nodeFactory.newIdExpression(name);
|
||||||
setOffsetAndLength(expr);
|
setOffsetAndLength(expr);
|
||||||
astStack.push(expr);
|
astStack.push(expr);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -661,8 +609,6 @@ public abstract class BuildASTParserAction {
|
||||||
* expression ::= <openscope-ast> expression_list_actual
|
* expression ::= <openscope-ast> expression_list_actual
|
||||||
*/
|
*/
|
||||||
public void consumeExpressionList() {
|
public void consumeExpressionList() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
List<Object> expressions = astStack.closeScope();
|
List<Object> expressions = astStack.closeScope();
|
||||||
if(expressions.size() == 1) {
|
if(expressions.size() == 1) {
|
||||||
astStack.push(expressions.get(0));
|
astStack.push(expressions.get(0));
|
||||||
|
@ -677,8 +623,6 @@ public abstract class BuildASTParserAction {
|
||||||
setOffsetAndLength(exprList);
|
setOffsetAndLength(exprList);
|
||||||
astStack.push(exprList);
|
astStack.push(exprList);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -686,15 +630,11 @@ public abstract class BuildASTParserAction {
|
||||||
* postfix_expression ::= postfix_expression '[' expression ']'
|
* postfix_expression ::= postfix_expression '[' expression ']'
|
||||||
*/
|
*/
|
||||||
public void consumeExpressionArraySubscript() {
|
public void consumeExpressionArraySubscript() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTExpression subscript = (IASTExpression) astStack.pop();
|
IASTExpression subscript = (IASTExpression) astStack.pop();
|
||||||
IASTExpression arrayExpr = (IASTExpression) astStack.pop();
|
IASTExpression arrayExpr = (IASTExpression) astStack.pop();
|
||||||
IASTArraySubscriptExpression expr = nodeFactory.newArraySubscriptExpression(arrayExpr, subscript);
|
IASTArraySubscriptExpression expr = nodeFactory.newArraySubscriptExpression(arrayExpr, subscript);
|
||||||
setOffsetAndLength(expr);
|
setOffsetAndLength(expr);
|
||||||
astStack.push(expr);
|
astStack.push(expr);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -702,16 +642,12 @@ public abstract class BuildASTParserAction {
|
||||||
* postfix_expression ::= postfix_expression '(' expression_list_opt ')'
|
* postfix_expression ::= postfix_expression '(' expression_list_opt ')'
|
||||||
*/
|
*/
|
||||||
public void consumeExpressionFunctionCall() {
|
public void consumeExpressionFunctionCall() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTExpression argList = (IASTExpression) astStack.pop(); // may be null
|
IASTExpression argList = (IASTExpression) astStack.pop(); // may be null
|
||||||
IASTExpression idExpr = (IASTExpression) astStack.pop();
|
IASTExpression idExpr = (IASTExpression) astStack.pop();
|
||||||
|
|
||||||
IASTFunctionCallExpression expr = nodeFactory.newFunctionCallExpression(idExpr, argList);
|
IASTFunctionCallExpression expr = nodeFactory.newFunctionCallExpression(idExpr, argList);
|
||||||
setOffsetAndLength(expr);
|
setOffsetAndLength(expr);
|
||||||
astStack.push(expr);
|
astStack.push(expr);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -719,8 +655,6 @@ public abstract class BuildASTParserAction {
|
||||||
* @param operator constant for {@link ICPPASTCastExpression}
|
* @param operator constant for {@link ICPPASTCastExpression}
|
||||||
*/
|
*/
|
||||||
public void consumeExpressionCast(int operator) {
|
public void consumeExpressionCast(int operator) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTExpression operand = (IASTExpression) astStack.pop();
|
IASTExpression operand = (IASTExpression) astStack.pop();
|
||||||
IASTTypeId typeId = (IASTTypeId) astStack.pop();
|
IASTTypeId typeId = (IASTTypeId) astStack.pop();
|
||||||
IASTCastExpression expr = nodeFactory.newCastExpression(operator, typeId, operand);
|
IASTCastExpression expr = nodeFactory.newCastExpression(operator, typeId, operand);
|
||||||
|
@ -740,8 +674,6 @@ public abstract class BuildASTParserAction {
|
||||||
setOffsetAndLength(ambiguityNode);
|
setOffsetAndLength(ambiguityNode);
|
||||||
astStack.push(ambiguityNode);
|
astStack.push(ambiguityNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -753,14 +685,10 @@ public abstract class BuildASTParserAction {
|
||||||
* @param operator From IASTUnaryExpression
|
* @param operator From IASTUnaryExpression
|
||||||
*/
|
*/
|
||||||
public void consumeExpressionUnaryOperator(int operator) {
|
public void consumeExpressionUnaryOperator(int operator) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTExpression operand = (IASTExpression) astStack.pop();
|
IASTExpression operand = (IASTExpression) astStack.pop();
|
||||||
IASTUnaryExpression expr = nodeFactory.newUnaryExpression(operator, operand);
|
IASTUnaryExpression expr = nodeFactory.newUnaryExpression(operator, operand);
|
||||||
setOffsetAndLength(expr);
|
setOffsetAndLength(expr);
|
||||||
astStack.push(expr);
|
astStack.push(expr);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -770,8 +698,6 @@ public abstract class BuildASTParserAction {
|
||||||
* @see consumeExpressionUnaryOperator For the other use of sizeof
|
* @see consumeExpressionUnaryOperator For the other use of sizeof
|
||||||
*/
|
*/
|
||||||
public void consumeExpressionTypeId(int operator) {
|
public void consumeExpressionTypeId(int operator) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTTypeId typeId = (IASTTypeId) astStack.pop();
|
IASTTypeId typeId = (IASTTypeId) astStack.pop();
|
||||||
IASTTypeIdExpression expr = nodeFactory.newTypeIdExpression(operator, typeId);
|
IASTTypeIdExpression expr = nodeFactory.newTypeIdExpression(operator, typeId);
|
||||||
setOffsetAndLength(expr);
|
setOffsetAndLength(expr);
|
||||||
|
@ -787,8 +713,6 @@ public abstract class BuildASTParserAction {
|
||||||
setOffsetAndLength(ambiguityNode);
|
setOffsetAndLength(ambiguityNode);
|
||||||
astStack.push(ambiguityNode);
|
astStack.push(ambiguityNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -798,15 +722,11 @@ public abstract class BuildASTParserAction {
|
||||||
* @param op Field from IASTBinaryExpression
|
* @param op Field from IASTBinaryExpression
|
||||||
*/
|
*/
|
||||||
public void consumeExpressionBinaryOperator(int op) {
|
public void consumeExpressionBinaryOperator(int op) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTExpression expr2 = (IASTExpression) astStack.pop();
|
IASTExpression expr2 = (IASTExpression) astStack.pop();
|
||||||
IASTExpression expr1 = (IASTExpression) astStack.pop();
|
IASTExpression expr1 = (IASTExpression) astStack.pop();
|
||||||
IASTBinaryExpression binExpr = nodeFactory.newBinaryExpression(op, expr1, expr2);
|
IASTBinaryExpression binExpr = nodeFactory.newBinaryExpression(op, expr1, expr2);
|
||||||
setOffsetAndLength(binExpr);
|
setOffsetAndLength(binExpr);
|
||||||
astStack.push(binExpr);
|
astStack.push(binExpr);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -814,16 +734,12 @@ public abstract class BuildASTParserAction {
|
||||||
* conditional_expression ::= logical_OR_expression '?' expression ':' conditional_expression
|
* conditional_expression ::= logical_OR_expression '?' expression ':' conditional_expression
|
||||||
*/
|
*/
|
||||||
public void consumeExpressionConditional() {
|
public void consumeExpressionConditional() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTExpression expr3 = (IASTExpression) astStack.pop();
|
IASTExpression expr3 = (IASTExpression) astStack.pop();
|
||||||
IASTExpression expr2 = (IASTExpression) astStack.pop();
|
IASTExpression expr2 = (IASTExpression) astStack.pop();
|
||||||
IASTExpression expr1 = (IASTExpression) astStack.pop();
|
IASTExpression expr1 = (IASTExpression) astStack.pop();
|
||||||
IASTConditionalExpression condExpr = nodeFactory.newConditionalExpession(expr1, expr2, expr3);
|
IASTConditionalExpression condExpr = nodeFactory.newConditionalExpession(expr1, expr2, expr3);
|
||||||
setOffsetAndLength(condExpr);
|
setOffsetAndLength(condExpr);
|
||||||
astStack.push(condExpr);
|
astStack.push(condExpr);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -832,16 +748,12 @@ public abstract class BuildASTParserAction {
|
||||||
* label_identifier ::= identifier
|
* label_identifier ::= identifier
|
||||||
*/
|
*/
|
||||||
public void consumeStatementLabeled() {
|
public void consumeStatementLabeled() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTStatement body = (IASTStatement) astStack.pop();
|
IASTStatement body = (IASTStatement) astStack.pop();
|
||||||
IASTName label = createName(parser.getLeftIToken());
|
IASTName label = createName(parser.getLeftIToken());
|
||||||
|
|
||||||
IASTLabelStatement stat = nodeFactory.newLabelStatement(label, body);
|
IASTLabelStatement stat = nodeFactory.newLabelStatement(label, body);
|
||||||
setOffsetAndLength(stat);
|
setOffsetAndLength(stat);
|
||||||
astStack.push(stat);
|
astStack.push(stat);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -849,8 +761,6 @@ public abstract class BuildASTParserAction {
|
||||||
* labeled_statement ::= 'case' constant_expression ':' statement
|
* labeled_statement ::= 'case' constant_expression ':' statement
|
||||||
*/
|
*/
|
||||||
public void consumeStatementCase() {
|
public void consumeStatementCase() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTStatement body = (IASTStatement) astStack.pop();
|
IASTStatement body = (IASTStatement) astStack.pop();
|
||||||
IASTExpression expr = (IASTExpression) astStack.pop();
|
IASTExpression expr = (IASTExpression) astStack.pop();
|
||||||
|
|
||||||
|
@ -863,8 +773,6 @@ public abstract class BuildASTParserAction {
|
||||||
compound.addStatement(body);
|
compound.addStatement(body);
|
||||||
|
|
||||||
astStack.push(compound);
|
astStack.push(compound);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -872,8 +780,6 @@ public abstract class BuildASTParserAction {
|
||||||
* labeled_statement ::= 'default' ':' <openscope-ast> statement
|
* labeled_statement ::= 'default' ':' <openscope-ast> statement
|
||||||
*/
|
*/
|
||||||
public void consumeStatementDefault() {
|
public void consumeStatementDefault() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTStatement body = (IASTStatement) astStack.pop();
|
IASTStatement body = (IASTStatement) astStack.pop();
|
||||||
|
|
||||||
IASTDefaultStatement stat = nodeFactory.newDefaultStatement();
|
IASTDefaultStatement stat = nodeFactory.newDefaultStatement();
|
||||||
|
@ -888,8 +794,6 @@ public abstract class BuildASTParserAction {
|
||||||
compound.addStatement(body);
|
compound.addStatement(body);
|
||||||
|
|
||||||
astStack.push(compound);
|
astStack.push(compound);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -898,13 +802,9 @@ public abstract class BuildASTParserAction {
|
||||||
* expression_statement ::= ';'
|
* expression_statement ::= ';'
|
||||||
*/
|
*/
|
||||||
public void consumeStatementNull() {
|
public void consumeStatementNull() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTNullStatement stat = nodeFactory.newNullStatement();
|
IASTNullStatement stat = nodeFactory.newNullStatement();
|
||||||
setOffsetAndLength(stat);
|
setOffsetAndLength(stat);
|
||||||
astStack.push(stat);
|
astStack.push(stat);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -912,14 +812,10 @@ public abstract class BuildASTParserAction {
|
||||||
* expression_statement ::= expression ';'
|
* expression_statement ::= expression ';'
|
||||||
*/
|
*/
|
||||||
public void consumeStatementExpression() {
|
public void consumeStatementExpression() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTExpression expr = (IASTExpression) astStack.pop();
|
IASTExpression expr = (IASTExpression) astStack.pop();
|
||||||
IASTExpressionStatement stat = nodeFactory.newExpressionStatement(expr);
|
IASTExpressionStatement stat = nodeFactory.newExpressionStatement(expr);
|
||||||
setOffsetAndLength(stat);
|
setOffsetAndLength(stat);
|
||||||
astStack.push(stat);
|
astStack.push(stat);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -930,8 +826,6 @@ public abstract class BuildASTParserAction {
|
||||||
* block_item_list ::= block_item | block_item_list block_item
|
* block_item_list ::= block_item | block_item_list block_item
|
||||||
*/
|
*/
|
||||||
public void consumeStatementCompoundStatement(boolean hasStatementsInBody) {
|
public void consumeStatementCompoundStatement(boolean hasStatementsInBody) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTCompoundStatement block = nodeFactory.newCompoundStatement();
|
IASTCompoundStatement block = nodeFactory.newCompoundStatement();
|
||||||
|
|
||||||
if(hasStatementsInBody) {
|
if(hasStatementsInBody) {
|
||||||
|
@ -942,8 +836,6 @@ public abstract class BuildASTParserAction {
|
||||||
|
|
||||||
setOffsetAndLength(block);
|
setOffsetAndLength(block);
|
||||||
astStack.push(block);
|
astStack.push(block);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -952,15 +844,11 @@ public abstract class BuildASTParserAction {
|
||||||
* ::= 'do' statement 'while' '(' expression ')' ';'
|
* ::= 'do' statement 'while' '(' expression ')' ';'
|
||||||
*/
|
*/
|
||||||
public void consumeStatementDoLoop() {
|
public void consumeStatementDoLoop() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTExpression condition = (IASTExpression) astStack.pop();
|
IASTExpression condition = (IASTExpression) astStack.pop();
|
||||||
IASTStatement body = (IASTStatement) astStack.pop();
|
IASTStatement body = (IASTStatement) astStack.pop();
|
||||||
IASTDoStatement stat = nodeFactory.newDoStatement(body, condition);
|
IASTDoStatement stat = nodeFactory.newDoStatement(body, condition);
|
||||||
setOffsetAndLength(stat);
|
setOffsetAndLength(stat);
|
||||||
astStack.push(stat);
|
astStack.push(stat);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -968,16 +856,11 @@ public abstract class BuildASTParserAction {
|
||||||
/**
|
/**
|
||||||
* jump_statement ::= goto goto_identifier ';'
|
* jump_statement ::= goto goto_identifier ';'
|
||||||
*/
|
*/
|
||||||
public void consumeStatementGoto(/*IBinding binding*/) {
|
public void consumeStatementGoto() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTName name = createName(parser.getRuleTokens().get(1));
|
IASTName name = createName(parser.getRuleTokens().get(1));
|
||||||
//name.setBinding(binding);
|
|
||||||
IASTGotoStatement gotoStat = nodeFactory.newGotoStatement(name);
|
IASTGotoStatement gotoStat = nodeFactory.newGotoStatement(name);
|
||||||
setOffsetAndLength(gotoStat);
|
setOffsetAndLength(gotoStat);
|
||||||
astStack.push(gotoStat);
|
astStack.push(gotoStat);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -985,13 +868,9 @@ public abstract class BuildASTParserAction {
|
||||||
* jump_statement ::= continue ';'
|
* jump_statement ::= continue ';'
|
||||||
*/
|
*/
|
||||||
public void consumeStatementContinue() {
|
public void consumeStatementContinue() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTContinueStatement stat = nodeFactory.newContinueStatement();
|
IASTContinueStatement stat = nodeFactory.newContinueStatement();
|
||||||
setOffsetAndLength(stat);
|
setOffsetAndLength(stat);
|
||||||
astStack.push(stat);
|
astStack.push(stat);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -999,13 +878,9 @@ public abstract class BuildASTParserAction {
|
||||||
* jump_statement ::= break ';'
|
* jump_statement ::= break ';'
|
||||||
*/
|
*/
|
||||||
public void consumeStatementBreak() {
|
public void consumeStatementBreak() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTBreakStatement stat = nodeFactory.newBreakStatement();
|
IASTBreakStatement stat = nodeFactory.newBreakStatement();
|
||||||
setOffsetAndLength(stat);
|
setOffsetAndLength(stat);
|
||||||
astStack.push(stat);
|
astStack.push(stat);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1014,14 +889,10 @@ public abstract class BuildASTParserAction {
|
||||||
* jump_statement ::= return expression ';'
|
* jump_statement ::= return expression ';'
|
||||||
*/
|
*/
|
||||||
public void consumeStatementReturn(boolean hasExpr) {
|
public void consumeStatementReturn(boolean hasExpr) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTExpression expr = hasExpr ? (IASTExpression) astStack.pop() : null;
|
IASTExpression expr = hasExpr ? (IASTExpression) astStack.pop() : null;
|
||||||
IASTReturnStatement returnStat = nodeFactory.newReturnStatement(expr);
|
IASTReturnStatement returnStat = nodeFactory.newReturnStatement(expr);
|
||||||
setOffsetAndLength(returnStat);
|
setOffsetAndLength(returnStat);
|
||||||
astStack.push(returnStat);
|
astStack.push(returnStat);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1032,8 +903,6 @@ public abstract class BuildASTParserAction {
|
||||||
* | specifier_qualifier_list abstract_declarator
|
* | specifier_qualifier_list abstract_declarator
|
||||||
*/
|
*/
|
||||||
public void consumeTypeId(boolean hasDeclarator) {
|
public void consumeTypeId(boolean hasDeclarator) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTDeclarator declarator;
|
IASTDeclarator declarator;
|
||||||
if(hasDeclarator)
|
if(hasDeclarator)
|
||||||
declarator = (IASTDeclarator) astStack.pop();
|
declarator = (IASTDeclarator) astStack.pop();
|
||||||
|
@ -1046,8 +915,6 @@ public abstract class BuildASTParserAction {
|
||||||
IASTTypeId typeId = nodeFactory.newTypeId(declSpecifier, declarator);
|
IASTTypeId typeId = nodeFactory.newTypeId(declSpecifier, declarator);
|
||||||
setOffsetAndLength(typeId);
|
setOffsetAndLength(typeId);
|
||||||
astStack.push(typeId);
|
astStack.push(typeId);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1060,8 +927,6 @@ public abstract class BuildASTParserAction {
|
||||||
* | <openscope-ast> ptr_operator_seq direct_declarator
|
* | <openscope-ast> ptr_operator_seq direct_declarator
|
||||||
*/
|
*/
|
||||||
public void consumeDeclaratorWithPointer(boolean hasDeclarator) {
|
public void consumeDeclaratorWithPointer(boolean hasDeclarator) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTDeclarator decl;
|
IASTDeclarator decl;
|
||||||
if(hasDeclarator)
|
if(hasDeclarator)
|
||||||
decl = (IASTDeclarator) astStack.pop();
|
decl = (IASTDeclarator) astStack.pop();
|
||||||
|
@ -1073,8 +938,6 @@ public abstract class BuildASTParserAction {
|
||||||
|
|
||||||
setOffsetAndLength(decl);
|
setOffsetAndLength(decl);
|
||||||
astStack.push(decl);
|
astStack.push(decl);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1087,8 +950,6 @@ public abstract class BuildASTParserAction {
|
||||||
* a default value without also specifying a named declarator
|
* a default value without also specifying a named declarator
|
||||||
*/
|
*/
|
||||||
public void consumeDeclaratorWithInitializer(boolean hasDeclarator) {
|
public void consumeDeclaratorWithInitializer(boolean hasDeclarator) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTInitializer initializer = (IASTInitializer) astStack.pop();
|
IASTInitializer initializer = (IASTInitializer) astStack.pop();
|
||||||
|
|
||||||
IASTDeclarator declarator;
|
IASTDeclarator declarator;
|
||||||
|
@ -1104,8 +965,6 @@ public abstract class BuildASTParserAction {
|
||||||
|
|
||||||
declarator.setInitializer(initializer);
|
declarator.setInitializer(initializer);
|
||||||
setOffsetAndLength(declarator); // adjust the length to include the initializer
|
setOffsetAndLength(declarator); // adjust the length to include the initializer
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1115,15 +974,11 @@ public abstract class BuildASTParserAction {
|
||||||
* | declaration_specifiers abstract_declarator
|
* | declaration_specifiers abstract_declarator
|
||||||
*/
|
*/
|
||||||
public void consumeParameterDeclaration() {
|
public void consumeParameterDeclaration() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTDeclarator declarator = (IASTDeclarator) astStack.pop();
|
IASTDeclarator declarator = (IASTDeclarator) astStack.pop();
|
||||||
IASTDeclSpecifier declSpec = (IASTDeclSpecifier) astStack.pop();
|
IASTDeclSpecifier declSpec = (IASTDeclSpecifier) astStack.pop();
|
||||||
IASTParameterDeclaration declaration = nodeFactory.newParameterDeclaration(declSpec, declarator);
|
IASTParameterDeclaration declaration = nodeFactory.newParameterDeclaration(declSpec, declarator);
|
||||||
setOffsetAndLength(declaration);
|
setOffsetAndLength(declaration);
|
||||||
astStack.push(declaration);
|
astStack.push(declaration);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1131,8 +986,6 @@ public abstract class BuildASTParserAction {
|
||||||
* parameter_declaration ::= declaration_specifiers
|
* parameter_declaration ::= declaration_specifiers
|
||||||
*/
|
*/
|
||||||
public void consumeParameterDeclarationWithoutDeclarator() {
|
public void consumeParameterDeclarationWithoutDeclarator() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
// offsets need to be calculated differently in this case
|
// offsets need to be calculated differently in this case
|
||||||
final int endOffset = parser.getRightIToken().getEndOffset();
|
final int endOffset = parser.getRightIToken().getEndOffset();
|
||||||
|
|
||||||
|
@ -1148,8 +1001,6 @@ public abstract class BuildASTParserAction {
|
||||||
|
|
||||||
setOffsetAndLength(declaration);
|
setOffsetAndLength(declaration);
|
||||||
astStack.push(declaration);
|
astStack.push(declaration);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1203,15 +1054,11 @@ public abstract class BuildASTParserAction {
|
||||||
* direct_declarator ::= '(' declarator ')'
|
* direct_declarator ::= '(' declarator ')'
|
||||||
*/
|
*/
|
||||||
public void consumeDirectDeclaratorBracketed() {
|
public void consumeDirectDeclaratorBracketed() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTDeclarator nested = (IASTDeclarator) astStack.pop();
|
IASTDeclarator nested = (IASTDeclarator) astStack.pop();
|
||||||
IASTDeclarator declarator = nodeFactory.newDeclarator(nodeFactory.newName());
|
IASTDeclarator declarator = nodeFactory.newDeclarator(nodeFactory.newName());
|
||||||
declarator.setNestedDeclarator(nested);
|
declarator.setNestedDeclarator(nested);
|
||||||
setOffsetAndLength(declarator);
|
setOffsetAndLength(declarator);
|
||||||
astStack.push(declarator);
|
astStack.push(declarator);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1219,14 +1066,10 @@ public abstract class BuildASTParserAction {
|
||||||
* direct_declarator ::= declarator_id_name
|
* direct_declarator ::= declarator_id_name
|
||||||
*/
|
*/
|
||||||
public void consumeDirectDeclaratorIdentifier() {
|
public void consumeDirectDeclaratorIdentifier() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTName name = (IASTName) astStack.pop();
|
IASTName name = (IASTName) astStack.pop();
|
||||||
IASTDeclarator declarator = nodeFactory.newDeclarator(name);
|
IASTDeclarator declarator = nodeFactory.newDeclarator(name);
|
||||||
setOffsetAndLength(declarator);
|
setOffsetAndLength(declarator);
|
||||||
astStack.push(declarator);
|
astStack.push(declarator);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1236,14 +1079,10 @@ public abstract class BuildASTParserAction {
|
||||||
* | '[' assignment_expression ']'
|
* | '[' assignment_expression ']'
|
||||||
*/
|
*/
|
||||||
public void consumeDirectDeclaratorArrayModifier(boolean hasAssignmentExpr) {
|
public void consumeDirectDeclaratorArrayModifier(boolean hasAssignmentExpr) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTExpression expr = hasAssignmentExpr ? (IASTExpression)astStack.pop() : null;
|
IASTExpression expr = hasAssignmentExpr ? (IASTExpression)astStack.pop() : null;
|
||||||
IASTArrayModifier arrayModifier = nodeFactory.newArrayModifier(expr);
|
IASTArrayModifier arrayModifier = nodeFactory.newArrayModifier(expr);
|
||||||
setOffsetAndLength(arrayModifier);
|
setOffsetAndLength(arrayModifier);
|
||||||
astStack.push(arrayModifier);
|
astStack.push(arrayModifier);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1255,8 +1094,6 @@ public abstract class BuildASTParserAction {
|
||||||
* Special care is taken for nested declarators.
|
* Special care is taken for nested declarators.
|
||||||
*/
|
*/
|
||||||
protected void addArrayModifier(IASTArrayModifier arrayModifier) {
|
protected void addArrayModifier(IASTArrayModifier arrayModifier) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTDeclarator node = (IASTDeclarator) astStack.pop();
|
IASTDeclarator node = (IASTDeclarator) astStack.pop();
|
||||||
|
|
||||||
// Its a nested declarator so create an new ArrayDeclarator
|
// Its a nested declarator so create an new ArrayDeclarator
|
||||||
|
@ -1292,8 +1129,6 @@ public abstract class BuildASTParserAction {
|
||||||
decl.addArrayModifier(arrayModifier);
|
decl.addArrayModifier(arrayModifier);
|
||||||
astStack.push(decl);
|
astStack.push(decl);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1330,11 +1165,9 @@ public abstract class BuildASTParserAction {
|
||||||
setOffsetAndLength(declarator, offset, endOffset - offset);
|
setOffsetAndLength(declarator, offset, endOffset - offset);
|
||||||
astStack.push(declarator);
|
astStack.push(declarator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO why is this here
|
||||||
// /**
|
// /**
|
||||||
// * direct_declarator ::= direct_declarator array_modifier
|
// * direct_declarator ::= direct_declarator array_modifier
|
||||||
// * consume the direct_declarator part and add the array modifier
|
// * consume the direct_declarator part and add the array modifier
|
||||||
|
@ -1346,14 +1179,13 @@ public abstract class BuildASTParserAction {
|
||||||
// addArrayModifier(arrayModifier);
|
// addArrayModifier(arrayModifier);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* direct_abstract_declarator
|
* direct_abstract_declarator
|
||||||
* ::= array_modifier
|
* ::= array_modifier
|
||||||
* | direct_abstract_declarator array_modifier
|
* | direct_abstract_declarator array_modifier
|
||||||
*/
|
*/
|
||||||
public void consumeDirectDeclaratorArrayDeclarator(boolean hasDeclarator) {
|
public void consumeDirectDeclaratorArrayDeclarator(boolean hasDeclarator) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTArrayModifier arrayModifier = (IASTArrayModifier) astStack.pop();
|
IASTArrayModifier arrayModifier = (IASTArrayModifier) astStack.pop();
|
||||||
|
|
||||||
if(hasDeclarator) {
|
if(hasDeclarator) {
|
||||||
|
@ -1364,8 +1196,6 @@ public abstract class BuildASTParserAction {
|
||||||
decl.addArrayModifier(arrayModifier);
|
decl.addArrayModifier(arrayModifier);
|
||||||
setOffsetAndLength(decl);
|
setOffsetAndLength(decl);
|
||||||
astStack.push(decl);
|
astStack.push(decl);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1377,8 +1207,6 @@ public abstract class BuildASTParserAction {
|
||||||
* | 'enum' enum_identifier '{' <openscope> enumerator_list_opt '}'
|
* | 'enum' enum_identifier '{' <openscope> enumerator_list_opt '}'
|
||||||
*/
|
*/
|
||||||
public void consumeTypeSpecifierEnumeration(boolean hasIdent) {
|
public void consumeTypeSpecifierEnumeration(boolean hasIdent) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTName name = (hasIdent) ? createName(parser.getRuleTokens().get(1)) : nodeFactory.newName();
|
IASTName name = (hasIdent) ? createName(parser.getRuleTokens().get(1)) : nodeFactory.newName();
|
||||||
|
|
||||||
IASTEnumerationSpecifier enumSpec = nodeFactory.newEnumerationSpecifier(name);
|
IASTEnumerationSpecifier enumSpec = nodeFactory.newEnumerationSpecifier(name);
|
||||||
|
@ -1388,8 +1216,6 @@ public abstract class BuildASTParserAction {
|
||||||
|
|
||||||
setOffsetAndLength(enumSpec);
|
setOffsetAndLength(enumSpec);
|
||||||
astStack.push(enumSpec);
|
astStack.push(enumSpec);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1398,8 +1224,6 @@ public abstract class BuildASTParserAction {
|
||||||
* | enum_identifier '=' constant_expression
|
* | enum_identifier '=' constant_expression
|
||||||
*/
|
*/
|
||||||
public void consumeEnumerator(boolean hasInitializer) {
|
public void consumeEnumerator(boolean hasInitializer) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTName name = createName(parser.getLeftIToken());
|
IASTName name = createName(parser.getLeftIToken());
|
||||||
|
|
||||||
IASTExpression value = null;
|
IASTExpression value = null;
|
||||||
|
@ -1409,8 +1233,6 @@ public abstract class BuildASTParserAction {
|
||||||
IASTEnumerator enumerator = nodeFactory.newEnumerator(name, value);
|
IASTEnumerator enumerator = nodeFactory.newEnumerator(name, value);
|
||||||
setOffsetAndLength(enumerator);
|
setOffsetAndLength(enumerator);
|
||||||
astStack.push(enumerator);
|
astStack.push(enumerator);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1428,8 +1250,6 @@ public abstract class BuildASTParserAction {
|
||||||
* initializer ::= assignment_expression
|
* initializer ::= assignment_expression
|
||||||
*/
|
*/
|
||||||
public void consumeInitializer() {
|
public void consumeInitializer() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTExpression expr = (IASTExpression) astStack.pop();
|
IASTExpression expr = (IASTExpression) astStack.pop();
|
||||||
if(discardInitializer(expr)) {
|
if(discardInitializer(expr)) {
|
||||||
astStack.push(null);
|
astStack.push(null);
|
||||||
|
@ -1439,8 +1259,6 @@ public abstract class BuildASTParserAction {
|
||||||
IASTInitializerExpression initializer = nodeFactory.newInitializerExpression(expr);
|
IASTInitializerExpression initializer = nodeFactory.newInitializerExpression(expr);
|
||||||
setOffsetAndLength(initializer);
|
setOffsetAndLength(initializer);
|
||||||
astStack.push(initializer);
|
astStack.push(initializer);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1457,8 +1275,6 @@ public abstract class BuildASTParserAction {
|
||||||
* | '{' <openscope> initializer_list ',' '}'
|
* | '{' <openscope> initializer_list ',' '}'
|
||||||
*/
|
*/
|
||||||
public void consumeInitializerList() {
|
public void consumeInitializerList() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTInitializerList list = nodeFactory.newInitializerList();
|
IASTInitializerList list = nodeFactory.newInitializerList();
|
||||||
|
|
||||||
for(Object o : astStack.closeScope())
|
for(Object o : astStack.closeScope())
|
||||||
|
@ -1466,8 +1282,6 @@ public abstract class BuildASTParserAction {
|
||||||
|
|
||||||
setOffsetAndLength(list);
|
setOffsetAndLength(list);
|
||||||
astStack.push(list);
|
astStack.push(list);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1480,8 +1294,6 @@ public abstract class BuildASTParserAction {
|
||||||
* | declarator ':' constant_expression
|
* | declarator ':' constant_expression
|
||||||
*/
|
*/
|
||||||
public void consumeBitField(boolean hasDeclarator) {
|
public void consumeBitField(boolean hasDeclarator) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTExpression expr = (IASTExpression)astStack.pop();
|
IASTExpression expr = (IASTExpression)astStack.pop();
|
||||||
|
|
||||||
IASTName name;
|
IASTName name;
|
||||||
|
@ -1493,8 +1305,6 @@ public abstract class BuildASTParserAction {
|
||||||
IASTFieldDeclarator fieldDecl = nodeFactory.newFieldDeclarator(name, expr);
|
IASTFieldDeclarator fieldDecl = nodeFactory.newFieldDeclarator(name, expr);
|
||||||
setOffsetAndLength(fieldDecl);
|
setOffsetAndLength(fieldDecl);
|
||||||
astStack.push(fieldDecl);
|
astStack.push(fieldDecl);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1503,8 +1313,6 @@ public abstract class BuildASTParserAction {
|
||||||
* statement ::= ERROR_TOKEN
|
* statement ::= ERROR_TOKEN
|
||||||
*/
|
*/
|
||||||
public void consumeStatementProblem() {
|
public void consumeStatementProblem() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
consumeProblem(nodeFactory.newProblemStatement(null));
|
consumeProblem(nodeFactory.newProblemStatement(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1513,8 +1321,6 @@ public abstract class BuildASTParserAction {
|
||||||
* constant_expression ::= ERROR_TOKEN
|
* constant_expression ::= ERROR_TOKEN
|
||||||
*/
|
*/
|
||||||
public void consumeExpressionProblem() {
|
public void consumeExpressionProblem() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
consumeProblem(nodeFactory.newProblemExpression(null));
|
consumeProblem(nodeFactory.newProblemExpression(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1522,8 +1328,6 @@ public abstract class BuildASTParserAction {
|
||||||
* external_declaration ::= ERROR_TOKEN
|
* external_declaration ::= ERROR_TOKEN
|
||||||
*/
|
*/
|
||||||
public void consumeDeclarationProblem() {
|
public void consumeDeclarationProblem() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
consumeProblem(nodeFactory.newProblemDeclaration(null));
|
consumeProblem(nodeFactory.newProblemDeclaration(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1534,8 +1338,6 @@ public abstract class BuildASTParserAction {
|
||||||
setOffsetAndLength(problem);
|
setOffsetAndLength(problem);
|
||||||
setOffsetAndLength((ASTNode)problemHolder);
|
setOffsetAndLength((ASTNode)problemHolder);
|
||||||
astStack.push(problemHolder);
|
astStack.push(problemHolder);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -63,7 +63,6 @@ import org.eclipse.cdt.core.dom.lrparser.action.BuildASTParserAction;
|
||||||
import org.eclipse.cdt.core.dom.lrparser.action.ITokenMap;
|
import org.eclipse.cdt.core.dom.lrparser.action.ITokenMap;
|
||||||
import org.eclipse.cdt.core.dom.lrparser.action.TokenMap;
|
import org.eclipse.cdt.core.dom.lrparser.action.TokenMap;
|
||||||
import org.eclipse.cdt.core.parser.util.CollectionUtils;
|
import org.eclipse.cdt.core.parser.util.CollectionUtils;
|
||||||
import org.eclipse.cdt.core.parser.util.DebugUtil;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.lrparser.c99.C99ExpressionParser;
|
import org.eclipse.cdt.internal.core.dom.lrparser.c99.C99ExpressionParser;
|
||||||
import org.eclipse.cdt.internal.core.dom.lrparser.c99.C99NoCastExpressionParser;
|
import org.eclipse.cdt.internal.core.dom.lrparser.c99.C99NoCastExpressionParser;
|
||||||
import org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym;
|
import org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym;
|
||||||
|
@ -143,16 +142,12 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
* postfix_expression ::= postfix_expression '->' ident
|
* postfix_expression ::= postfix_expression '->' ident
|
||||||
*/
|
*/
|
||||||
public void consumeExpressionFieldReference(boolean isPointerDereference) {
|
public void consumeExpressionFieldReference(boolean isPointerDereference) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTName name = createName(parser.getRightIToken());
|
IASTName name = createName(parser.getRightIToken());
|
||||||
IASTExpression owner = (IASTExpression) astStack.pop();
|
IASTExpression owner = (IASTExpression) astStack.pop();
|
||||||
IASTFieldReference expr = nodeFactory.newFieldReference(name, owner);
|
IASTFieldReference expr = nodeFactory.newFieldReference(name, owner);
|
||||||
expr.setIsPointerDereference(isPointerDereference);
|
expr.setIsPointerDereference(isPointerDereference);
|
||||||
setOffsetAndLength(expr);
|
setOffsetAndLength(expr);
|
||||||
astStack.push(expr);
|
astStack.push(expr);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -161,18 +156,15 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
* postfix_expression ::= '(' type_name ')' '{' <openscope> initializer_list ',' '}'
|
* postfix_expression ::= '(' type_name ')' '{' <openscope> initializer_list ',' '}'
|
||||||
*/
|
*/
|
||||||
public void consumeExpressionTypeIdInitializer() {
|
public void consumeExpressionTypeIdInitializer() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
consumeInitializerList(); // closes the scope
|
consumeInitializerList(); // closes the scope
|
||||||
IASTInitializerList list = (IASTInitializerList) astStack.pop();
|
IASTInitializerList list = (IASTInitializerList) astStack.pop();
|
||||||
IASTTypeId typeId = (IASTTypeId) astStack.pop();
|
IASTTypeId typeId = (IASTTypeId) astStack.pop();
|
||||||
ICASTTypeIdInitializerExpression expr = nodeFactory.newTypeIdInitializerExpression(typeId, list);
|
ICASTTypeIdInitializerExpression expr = nodeFactory.newTypeIdInitializerExpression(typeId, list);
|
||||||
setOffsetAndLength(expr);
|
setOffsetAndLength(expr);
|
||||||
astStack.push(expr);
|
astStack.push(expr);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO why is this here?
|
||||||
// /**
|
// /**
|
||||||
// * Lots of rules, no need to list them.
|
// * Lots of rules, no need to list them.
|
||||||
// * @param operator From IASTUnaryExpression
|
// * @param operator From IASTUnaryExpression
|
||||||
|
@ -276,8 +268,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
*/
|
*/
|
||||||
public void consumeDirectDeclaratorModifiedArrayModifier(boolean isStatic,
|
public void consumeDirectDeclaratorModifiedArrayModifier(boolean isStatic,
|
||||||
boolean isVarSized, boolean hasTypeQualifierList, boolean hasAssignmentExpr) {
|
boolean isVarSized, boolean hasTypeQualifierList, boolean hasAssignmentExpr) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
assert isStatic || isVarSized || hasTypeQualifierList;
|
assert isStatic || isVarSized || hasTypeQualifierList;
|
||||||
|
|
||||||
ICASTArrayModifier arrayModifier = nodeFactory.newModifiedArrayModifier(null);
|
ICASTArrayModifier arrayModifier = nodeFactory.newModifiedArrayModifier(null);
|
||||||
|
@ -294,8 +284,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
|
|
||||||
setOffsetAndLength(arrayModifier);
|
setOffsetAndLength(arrayModifier);
|
||||||
astStack.push(arrayModifier);
|
astStack.push(arrayModifier);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -304,8 +292,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
* direct_declarator ::= direct_declarator '(' <openscope> identifier_list ')'
|
* direct_declarator ::= direct_declarator '(' <openscope> identifier_list ')'
|
||||||
*/
|
*/
|
||||||
public void consumeDirectDeclaratorFunctionDeclaratorKnR() {
|
public void consumeDirectDeclaratorFunctionDeclaratorKnR() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
ICASTKnRFunctionDeclarator declarator = nodeFactory.newKnRFunctionDeclarator(null, null);
|
ICASTKnRFunctionDeclarator declarator = nodeFactory.newKnRFunctionDeclarator(null, null);
|
||||||
IASTName[] names = astStack.topScope().toArray(new IASTName[0]);
|
IASTName[] names = astStack.topScope().toArray(new IASTName[0]);
|
||||||
declarator.setParameterNames(names);
|
declarator.setParameterNames(names);
|
||||||
|
@ -321,8 +307,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
* | identifier_list ',' 'identifier'
|
* | identifier_list ',' 'identifier'
|
||||||
*/
|
*/
|
||||||
public void consumeIdentifierKnR() {
|
public void consumeIdentifierKnR() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTName name = createName(parser.getRightIToken());
|
IASTName name = createName(parser.getRightIToken());
|
||||||
astStack.push(name);
|
astStack.push(name);
|
||||||
}
|
}
|
||||||
|
@ -335,14 +319,10 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
* | pointer '*'
|
* | pointer '*'
|
||||||
*/
|
*/
|
||||||
public void consumePointer() {
|
public void consumePointer() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTPointer pointer = nodeFactory.newPointer();
|
IASTPointer pointer = nodeFactory.newPointer();
|
||||||
IToken star = parser.getRightIToken();
|
IToken star = parser.getRightIToken();
|
||||||
setOffsetAndLength(pointer, star);
|
setOffsetAndLength(pointer, star);
|
||||||
astStack.push(pointer);
|
astStack.push(pointer);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -351,8 +331,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
* | pointer '*' <openscope> type_qualifier_list
|
* | pointer '*' <openscope> type_qualifier_list
|
||||||
*/
|
*/
|
||||||
public void consumePointerTypeQualifierList() {
|
public void consumePointerTypeQualifierList() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
ICASTPointer pointer = nodeFactory.newPointer();
|
ICASTPointer pointer = nodeFactory.newPointer();
|
||||||
|
|
||||||
for(Object o : astStack.closeScope()) {
|
for(Object o : astStack.closeScope()) {
|
||||||
|
@ -367,8 +345,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
|
|
||||||
setOffsetAndLength(pointer);
|
setOffsetAndLength(pointer);
|
||||||
astStack.push(pointer);
|
astStack.push(pointer);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -381,8 +357,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
* | direct_abstract_declarator '(' <openscope> parameter_type_list ')'
|
* | direct_abstract_declarator '(' <openscope> parameter_type_list ')'
|
||||||
*/
|
*/
|
||||||
public void consumeDirectDeclaratorFunctionDeclarator(boolean hasDeclarator, boolean hasParameters) {
|
public void consumeDirectDeclaratorFunctionDeclarator(boolean hasDeclarator, boolean hasParameters) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTName name = nodeFactory.newName();
|
IASTName name = nodeFactory.newName();
|
||||||
IASTStandardFunctionDeclarator declarator = nodeFactory.newFunctionDeclarator(name);
|
IASTStandardFunctionDeclarator declarator = nodeFactory.newFunctionDeclarator(name);
|
||||||
|
|
||||||
|
@ -401,8 +375,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
setOffsetAndLength(declarator);
|
setOffsetAndLength(declarator);
|
||||||
astStack.push(declarator);
|
astStack.push(declarator);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -411,8 +383,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
* designated_initializer ::= <openscope> designation initializer
|
* designated_initializer ::= <openscope> designation initializer
|
||||||
*/
|
*/
|
||||||
public void consumeInitializerDesignated() {
|
public void consumeInitializerDesignated() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTInitializer initializer = (IASTInitializer)astStack.pop();
|
IASTInitializer initializer = (IASTInitializer)astStack.pop();
|
||||||
ICASTDesignatedInitializer result = nodeFactory.newDesignatedInitializer(initializer);
|
ICASTDesignatedInitializer result = nodeFactory.newDesignatedInitializer(initializer);
|
||||||
|
|
||||||
|
@ -421,8 +391,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
|
|
||||||
setOffsetAndLength(result);
|
setOffsetAndLength(result);
|
||||||
astStack.push(result);
|
astStack.push(result);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -430,14 +398,10 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
* designator ::= '[' constant_expression ']'
|
* designator ::= '[' constant_expression ']'
|
||||||
*/
|
*/
|
||||||
public void consumeDesignatorArray() {
|
public void consumeDesignatorArray() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTExpression expr = (IASTExpression) astStack.pop();
|
IASTExpression expr = (IASTExpression) astStack.pop();
|
||||||
ICASTArrayDesignator designator = nodeFactory.newArrayDesignator(expr);
|
ICASTArrayDesignator designator = nodeFactory.newArrayDesignator(expr);
|
||||||
setOffsetAndLength(designator);
|
setOffsetAndLength(designator);
|
||||||
astStack.push(designator);
|
astStack.push(designator);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -445,14 +409,10 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
* designator ::= '.' 'identifier'
|
* designator ::= '.' 'identifier'
|
||||||
*/
|
*/
|
||||||
public void consumeDesignatorField() {
|
public void consumeDesignatorField() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTName name = createName(parser.getRightIToken());
|
IASTName name = createName(parser.getRightIToken());
|
||||||
ICASTFieldDesignator designator = nodeFactory.newFieldDesignator(name);
|
ICASTFieldDesignator designator = nodeFactory.newFieldDesignator(name);
|
||||||
setOffsetAndLength(designator);
|
setOffsetAndLength(designator);
|
||||||
astStack.push(designator);
|
astStack.push(designator);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -460,8 +420,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
* declaration_specifiers ::= <openscope> simple_declaration_specifiers
|
* declaration_specifiers ::= <openscope> simple_declaration_specifiers
|
||||||
*/
|
*/
|
||||||
public void consumeDeclarationSpecifiersSimple() {
|
public void consumeDeclarationSpecifiersSimple() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
ICASTSimpleDeclSpecifier declSpec = nodeFactory.newSimpleDeclSpecifier();
|
ICASTSimpleDeclSpecifier declSpec = nodeFactory.newSimpleDeclSpecifier();
|
||||||
|
|
||||||
for(Object specifier : astStack.closeScope())
|
for(Object specifier : astStack.closeScope())
|
||||||
|
@ -469,8 +427,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
|
|
||||||
setOffsetAndLength(declSpec);
|
setOffsetAndLength(declSpec);
|
||||||
astStack.push(declSpec);
|
astStack.push(declSpec);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -479,8 +435,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
* declaration_specifiers ::= <openscope> enum_declaration_specifiers
|
* declaration_specifiers ::= <openscope> enum_declaration_specifiers
|
||||||
*/
|
*/
|
||||||
public void consumeDeclarationSpecifiersStructUnionEnum() {
|
public void consumeDeclarationSpecifiersStructUnionEnum() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
List<Object> topScope = astStack.closeScope();
|
List<Object> topScope = astStack.closeScope();
|
||||||
ICASTDeclSpecifier declSpec = CollectionUtils.findFirstAndRemove(topScope, ICASTDeclSpecifier.class);
|
ICASTDeclSpecifier declSpec = CollectionUtils.findFirstAndRemove(topScope, ICASTDeclSpecifier.class);
|
||||||
|
|
||||||
|
@ -490,8 +444,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
|
|
||||||
setOffsetAndLength(declSpec);
|
setOffsetAndLength(declSpec);
|
||||||
astStack.push(declSpec);
|
astStack.push(declSpec);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -499,8 +451,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
* declaration_specifiers ::= <openscope> typdef_name_declaration_specifiers
|
* declaration_specifiers ::= <openscope> typdef_name_declaration_specifiers
|
||||||
*/
|
*/
|
||||||
public void consumeDeclarationSpecifiersTypedefName() {
|
public void consumeDeclarationSpecifiersTypedefName() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
ICASTTypedefNameSpecifier declSpec = nodeFactory.newTypedefNameSpecifier(null);
|
ICASTTypedefNameSpecifier declSpec = nodeFactory.newTypedefNameSpecifier(null);
|
||||||
|
|
||||||
for(Object o : astStack.topScope()) {
|
for(Object o : astStack.topScope()) {
|
||||||
|
@ -522,8 +472,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
astStack.closeScope();
|
astStack.closeScope();
|
||||||
setOffsetAndLength(declSpec);
|
setOffsetAndLength(declSpec);
|
||||||
astStack.push(declSpec);
|
astStack.push(declSpec);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -533,8 +481,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
* declaration ::= declaration_specifiers ';'
|
* declaration ::= declaration_specifiers ';'
|
||||||
*/
|
*/
|
||||||
public void consumeDeclarationSimple(boolean hasDeclaratorList) {
|
public void consumeDeclarationSimple(boolean hasDeclaratorList) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
List<Object> declarators = (hasDeclaratorList) ? astStack.closeScope() : Collections.emptyList();
|
List<Object> declarators = (hasDeclaratorList) ? astStack.closeScope() : Collections.emptyList();
|
||||||
IASTDeclSpecifier declSpecifier = (IASTDeclSpecifier) astStack.pop();
|
IASTDeclSpecifier declSpecifier = (IASTDeclSpecifier) astStack.pop();
|
||||||
|
|
||||||
|
@ -549,8 +495,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
|
|
||||||
setOffsetAndLength(declaration);
|
setOffsetAndLength(declaration);
|
||||||
astStack.push(declaration);
|
astStack.push(declaration);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -561,10 +505,7 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
* TODO: doesn't the declaration need a name?
|
* TODO: doesn't the declaration need a name?
|
||||||
*/
|
*/
|
||||||
public void consumeDeclarationEmpty() {
|
public void consumeDeclarationEmpty() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
// Don't generate declaration nodes for extra EOC tokens
|
// Don't generate declaration nodes for extra EOC tokens
|
||||||
// TODO: the token type must be converted
|
|
||||||
if(baseKind(parser.getLeftIToken()) == C99Parsersym.TK_EndOfCompletion)
|
if(baseKind(parser.getLeftIToken()) == C99Parsersym.TK_EndOfCompletion)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -573,8 +514,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
setOffsetAndLength(declSpecifier);
|
setOffsetAndLength(declSpecifier);
|
||||||
setOffsetAndLength(declaration);
|
setOffsetAndLength(declaration);
|
||||||
astStack.push(declaration);
|
astStack.push(declaration);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -588,8 +527,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
* a struct declarator is a regular declarator plus bit fields
|
* a struct declarator is a regular declarator plus bit fields
|
||||||
*/
|
*/
|
||||||
public void consumeStructDeclaration(boolean hasDeclaration) {
|
public void consumeStructDeclaration(boolean hasDeclaration) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
consumeDeclarationSimple(hasDeclaration); // TODO this is ok as long as bit fields implement IASTDeclarator (see consumeDeclaration())
|
consumeDeclarationSimple(hasDeclaration); // TODO this is ok as long as bit fields implement IASTDeclarator (see consumeDeclaration())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -604,8 +541,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
* @param key either k_struct or k_union from IASTCompositeTypeSpecifier
|
* @param key either k_struct or k_union from IASTCompositeTypeSpecifier
|
||||||
*/
|
*/
|
||||||
public void consumeTypeSpecifierComposite(boolean hasName, int key) {
|
public void consumeTypeSpecifierComposite(boolean hasName, int key) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTName name = (hasName) ? createName(parser.getRuleTokens().get(1)) : nodeFactory.newName();
|
IASTName name = (hasName) ? createName(parser.getRuleTokens().get(1)) : nodeFactory.newName();
|
||||||
|
|
||||||
ICASTCompositeTypeSpecifier typeSpec = nodeFactory.newCompositeTypeSpecifier(key, name);
|
ICASTCompositeTypeSpecifier typeSpec = nodeFactory.newCompositeTypeSpecifier(key, name);
|
||||||
|
@ -615,8 +550,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
|
|
||||||
setOffsetAndLength(typeSpec);
|
setOffsetAndLength(typeSpec);
|
||||||
astStack.push(typeSpec);
|
astStack.push(typeSpec);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -628,14 +561,10 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
* enum_specifier ::= 'enum' enum_identifier
|
* enum_specifier ::= 'enum' enum_identifier
|
||||||
*/
|
*/
|
||||||
public void consumeTypeSpecifierElaborated(int kind) {
|
public void consumeTypeSpecifierElaborated(int kind) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTName name = createName(parser.getRuleTokens().get(1));
|
IASTName name = createName(parser.getRuleTokens().get(1));
|
||||||
IASTElaboratedTypeSpecifier typeSpec = nodeFactory.newElaboratedTypeSpecifier(kind, name);
|
IASTElaboratedTypeSpecifier typeSpec = nodeFactory.newElaboratedTypeSpecifier(kind, name);
|
||||||
setOffsetAndLength(typeSpec);
|
setOffsetAndLength(typeSpec);
|
||||||
astStack.push(typeSpec);
|
astStack.push(typeSpec);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -645,15 +574,11 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
* iteration_statement ::= 'while' '(' expression ')' statement
|
* iteration_statement ::= 'while' '(' expression ')' statement
|
||||||
*/
|
*/
|
||||||
public void consumeStatementWhileLoop() {
|
public void consumeStatementWhileLoop() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTStatement body = (IASTStatement) astStack.pop();
|
IASTStatement body = (IASTStatement) astStack.pop();
|
||||||
IASTExpression condition = (IASTExpression) astStack.pop();
|
IASTExpression condition = (IASTExpression) astStack.pop();
|
||||||
IASTWhileStatement whileStatement = nodeFactory.newWhileStatement(condition, body);
|
IASTWhileStatement whileStatement = nodeFactory.newWhileStatement(condition, body);
|
||||||
setOffsetAndLength(whileStatement);
|
setOffsetAndLength(whileStatement);
|
||||||
astStack.push(whileStatement);
|
astStack.push(whileStatement);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -663,8 +588,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
* ::= 'for' '(' expression_opt ';' expression_opt ';' expression_opt ')' statement
|
* ::= 'for' '(' expression_opt ';' expression_opt ';' expression_opt ')' statement
|
||||||
*/
|
*/
|
||||||
public void consumeStatementForLoop() {
|
public void consumeStatementForLoop() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTStatement body = (IASTStatement) astStack.pop();
|
IASTStatement body = (IASTStatement) astStack.pop();
|
||||||
// these two expressions may be null, see consumeExpressionOptional()
|
// these two expressions may be null, see consumeExpressionOptional()
|
||||||
IASTExpression expr3 = (IASTExpression) astStack.pop();
|
IASTExpression expr3 = (IASTExpression) astStack.pop();
|
||||||
|
@ -699,8 +622,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
IASTForStatement forStat = nodeFactory.newForStatement(initializer, expr2, expr3, body);
|
IASTForStatement forStat = nodeFactory.newForStatement(initializer, expr2, expr3, body);
|
||||||
setOffsetAndLength(forStat);
|
setOffsetAndLength(forStat);
|
||||||
astStack.push(forStat);
|
astStack.push(forStat);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -709,21 +630,15 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
* selection_statement ::= switch '(' expression ')' statement
|
* selection_statement ::= switch '(' expression ')' statement
|
||||||
*/
|
*/
|
||||||
public void consumeStatementSwitch() {
|
public void consumeStatementSwitch() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTStatement body = (IASTStatement) astStack.pop();
|
IASTStatement body = (IASTStatement) astStack.pop();
|
||||||
IASTExpression expr = (IASTExpression) astStack.pop();
|
IASTExpression expr = (IASTExpression) astStack.pop();
|
||||||
IASTSwitchStatement stat = nodeFactory.newSwitchStatement(expr, body);
|
IASTSwitchStatement stat = nodeFactory.newSwitchStatement(expr, body);
|
||||||
setOffsetAndLength(stat);
|
setOffsetAndLength(stat);
|
||||||
astStack.push(stat);
|
astStack.push(stat);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void consumeStatementIf(boolean hasElse) {
|
public void consumeStatementIf(boolean hasElse) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTStatement elseClause = null;
|
IASTStatement elseClause = null;
|
||||||
if(hasElse)
|
if(hasElse)
|
||||||
elseClause = (IASTStatement) astStack.pop();
|
elseClause = (IASTStatement) astStack.pop();
|
||||||
|
@ -734,8 +649,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
IASTIfStatement ifStatement = nodeFactory.newIfStatement(condition, thenClause, elseClause);
|
IASTIfStatement ifStatement = nodeFactory.newIfStatement(condition, thenClause, elseClause);
|
||||||
setOffsetAndLength(ifStatement);
|
setOffsetAndLength(ifStatement);
|
||||||
astStack.push(ifStatement);
|
astStack.push(ifStatement);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -748,8 +661,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
* prevent a shift/reduce conflict in the grammar.
|
* prevent a shift/reduce conflict in the grammar.
|
||||||
*/
|
*/
|
||||||
public void consumeFunctionDefinition(boolean hasDeclSpecifiers) {
|
public void consumeFunctionDefinition(boolean hasDeclSpecifiers) {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace(String.valueOf(hasDeclSpecifiers));
|
|
||||||
|
|
||||||
IASTCompoundStatement body = (IASTCompoundStatement) astStack.pop();
|
IASTCompoundStatement body = (IASTCompoundStatement) astStack.pop();
|
||||||
IASTFunctionDeclarator decl = (IASTFunctionDeclarator) astStack.pop();
|
IASTFunctionDeclarator decl = (IASTFunctionDeclarator) astStack.pop();
|
||||||
astStack.closeScope();
|
astStack.closeScope();
|
||||||
|
@ -765,8 +676,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
IASTFunctionDefinition def = nodeFactory.newFunctionDefinition(declSpecifier, decl, body);
|
IASTFunctionDefinition def = nodeFactory.newFunctionDefinition(declSpecifier, decl, body);
|
||||||
setOffsetAndLength(def);
|
setOffsetAndLength(def);
|
||||||
astStack.push(def);
|
astStack.push(def);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -777,8 +686,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
* <openscope> declaration_list compound_statement
|
* <openscope> declaration_list compound_statement
|
||||||
*/
|
*/
|
||||||
public void consumeFunctionDefinitionKnR() {
|
public void consumeFunctionDefinitionKnR() {
|
||||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
|
||||||
|
|
||||||
IASTCompoundStatement body = (IASTCompoundStatement) astStack.pop();
|
IASTCompoundStatement body = (IASTCompoundStatement) astStack.pop();
|
||||||
|
|
||||||
IASTDeclaration[] declarations = astStack.topScope().toArray(new IASTDeclaration[0]);
|
IASTDeclaration[] declarations = astStack.topScope().toArray(new IASTDeclaration[0]);
|
||||||
|
@ -798,8 +705,6 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
IASTFunctionDefinition def = nodeFactory.newFunctionDefinition(declSpecifier, decl, body);
|
IASTFunctionDefinition def = nodeFactory.newFunctionDefinition(declSpecifier, decl, body);
|
||||||
setOffsetAndLength(def);
|
setOffsetAndLength(def);
|
||||||
astStack.push(def);
|
astStack.push(def);
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -212,8 +212,9 @@ public String[] getOrderedTerminalSymbols() {
|
||||||
return C99ExpressionParsersym.orderedTerminalSymbols;
|
return C99ExpressionParsersym.orderedTerminalSymbols;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("nls")
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "C99ExpressionParser"; //$NON-NLS-1$
|
return "C99ExpressionParser";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -212,8 +212,9 @@ public String[] getOrderedTerminalSymbols() {
|
||||||
return C99NoCastExpressionParsersym.orderedTerminalSymbols;
|
return C99NoCastExpressionParsersym.orderedTerminalSymbols;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("nls")
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "C99NoCastExpressionParser"; //$NON-NLS-1$
|
return "C99NoCastExpressionParser";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -212,8 +212,9 @@ public String[] getOrderedTerminalSymbols() {
|
||||||
return C99Parsersym.orderedTerminalSymbols;
|
return C99Parsersym.orderedTerminalSymbols;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("nls")
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "C99Parser"; //$NON-NLS-1$
|
return "C99Parser";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -212,8 +212,9 @@ public String[] getOrderedTerminalSymbols() {
|
||||||
return C99SizeofExpressionParsersym.orderedTerminalSymbols;
|
return C99SizeofExpressionParsersym.orderedTerminalSymbols;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("nls")
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "C99SizeofExpressionParser"; //$NON-NLS-1$
|
return "C99SizeofExpressionParser";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,7 @@
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl_v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl_v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,7 @@
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl_v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl_v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,7 @@
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl_v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl_v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,7 @@
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl_v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl_v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,7 @@
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl_v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl_v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,7 @@
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl_v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl_v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
|
|
Loading…
Add table
Reference in a new issue