Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'lrparser/org.eclipse.cdt.core.lrparser')
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99ExpressionParser.g6
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99NoCastExpressionParser.g6
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99Parser.g4
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99SizeofExpressionParser.g6
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPExpressionParser.g6
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPNoCastExpressionParser.g6
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPNoFunctionDeclaratorParser.g6
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPParser.g4
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPSizeofExpressionParser.g6
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPTemplateTypeParameterParser.g12
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/grammar/gcc/GCCParser.g4
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/grammar/gcc/GCCSizeofExpressionParser.g5
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/grammar/gnu/GNUExtensions.g2
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/grammar/gpp/GPPParser.g4
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/grammar/gpp/GPPSizeofExpressionParser.g6
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/grammar/template/FixedBtParserTemplateD.g47
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/BaseExtensibleLanguage.java75
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/CPreprocessorAdapter.java4
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/IParser.java12
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ASTCompletionNode.java15
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/AbstractParserAction.java58
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java35
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ISecondaryParserFactory.java7
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99BuildASTParserAction.java5
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99SecondaryParserFactory.java7
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPBuildASTParserAction.java73
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPSecondaryParserFactory.java13
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/ICPPSecondaryParserFactory.java6
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GCCBuildASTParserAction.java5
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GCCSecondaryParserFactory.java7
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GNUBuildASTParserAction.java5
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GPPBuildASTParserAction.java5
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GPPSecondaryParserFactory.java13
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/c99/C99Language.java9
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/cpp/ISOCPPLanguage.java12
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/GCCLanguage.java9
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/GPPLanguage.java9
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99ExpressionParser.java47
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99NoCastExpressionParser.java47
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99Parser.java45
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99SizeofExpressionParser.java47
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPExpressionParser.java47
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPNoCastExpressionParser.java47
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPNoFunctionDeclaratorParser.java47
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParser.java45
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPSizeofExpressionParser.java47
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPTemplateTypeParameterParser.java49
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/gcc/GCCParser.java47
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/gcc/GCCSizeofExpressionParser.java49
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/gpp/GPPParser.java47
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/gpp/GPPSizeofExpressionParser.java49
51 files changed, 564 insertions, 610 deletions
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99ExpressionParser.g b/lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99ExpressionParser.g
index 80919514f3..ba2ae8d25b 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99ExpressionParser.g
+++ b/lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99ExpressionParser.g
@@ -20,6 +20,10 @@ $Import
C99Grammar.g
$End
+$Define
+ $ast_class /. IASTExpression ./
+$End
+
$Start
expression_parser_start
$End
@@ -29,6 +33,6 @@ $Rules
expression_parser_start
::= expression
| ERROR_TOKEN
- /. $Build consumeExpressionProblem(); $EndBuild ./
+ /. $Build consumeEmpty(); $EndBuild ./
$End \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99NoCastExpressionParser.g b/lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99NoCastExpressionParser.g
index a09c257f44..7948a0aea5 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99NoCastExpressionParser.g
+++ b/lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99NoCastExpressionParser.g
@@ -22,6 +22,10 @@ $DropRules
$End
+$Define
+ $ast_class /. IASTExpression ./
+$End
+
$Start
no_cast_start
$End
@@ -31,6 +35,6 @@ $Rules
no_cast_start
::= expression
| ERROR_TOKEN
- /. $Build consumeExpressionProblem(); $EndBuild ./
+ /. $Build consumeEmpty(); $EndBuild ./
$End \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99Parser.g b/lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99Parser.g
index f89f4493f3..38195cc4a0 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99Parser.g
+++ b/lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99Parser.g
@@ -20,6 +20,10 @@ $Import
C99Grammar.g
$End
+$Define
+ $ast_class /. IASTTranslationUnit ./
+$End
+
$Start
translation_unit
$End \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99SizeofExpressionParser.g b/lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99SizeofExpressionParser.g
index 764953a5ad..14084dc832 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99SizeofExpressionParser.g
+++ b/lrparser/org.eclipse.cdt.core.lrparser/grammar/c99/C99SizeofExpressionParser.g
@@ -23,6 +23,10 @@ $DropRules
$End
+$Define
+ $ast_class /. IASTExpression ./
+$End
+
$Start
no_sizeof_type_id_start
$End
@@ -32,6 +36,6 @@ $Rules
no_sizeof_type_id_start
::= expression
| ERROR_TOKEN
- /. $Build consumeExpressionProblem(); $EndBuild ./
+ /. $Build consumeEmpty(); $EndBuild ./
$End \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPExpressionParser.g b/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPExpressionParser.g
index 3af8f68ce6..b9ab4957b7 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPExpressionParser.g
+++ b/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPExpressionParser.g
@@ -19,6 +19,10 @@ $Import
CPPGrammar.g
$End
+$Define
+ $ast_class /. IASTExpression ./
+$End
+
$Start
expression_parser_start
$End
@@ -28,6 +32,6 @@ $Rules
expression_parser_start
::= expression
| ERROR_TOKEN
- /. $Build consumeExpressionProblem(); $EndBuild ./
+ /. $Build consumeEmpty(); $EndBuild ./
$End \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPNoCastExpressionParser.g b/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPNoCastExpressionParser.g
index 7340ce79e0..ea1a9d944d 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPNoCastExpressionParser.g
+++ b/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPNoCastExpressionParser.g
@@ -22,6 +22,10 @@ $DropRules
$End
+$Define
+ $ast_class /. IASTExpression ./
+$End
+
$Start
no_cast_start
$End
@@ -31,6 +35,6 @@ $Rules
no_cast_start
::= expression
| ERROR_TOKEN
- /. $Build consumeExpressionProblem(); $EndBuild ./
+ /. $Build consumeEmpty(); $EndBuild ./
$End \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPNoFunctionDeclaratorParser.g b/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPNoFunctionDeclaratorParser.g
index bdbaf96e24..6e0bcc4cd3 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPNoFunctionDeclaratorParser.g
+++ b/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPNoFunctionDeclaratorParser.g
@@ -25,6 +25,10 @@ $DropRules
$End
+$Define
+ $ast_class /. IASTDeclarator ./
+$End
+
$Start
no_function_declarator_start
$End
@@ -34,7 +38,7 @@ $Rules
no_function_declarator_start
::= init_declarator_complete
| ERROR_TOKEN
- /. $Build consumeDeclarationProblem(); $EndBuild ./
+ /. $Build consumeEmpty(); $EndBuild ./
-- redeclare this rule with no semantic action, prevents recursion
init_declarator_complete
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPParser.g b/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPParser.g
index 47e91f6a41..8f4d80864d 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPParser.g
+++ b/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPParser.g
@@ -21,6 +21,10 @@ $Import
CPPGrammar.g
$End
+$Define
+ $ast_class /. IASTTranslationUnit ./
+$End
+
$Start
translation_unit
$End \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPSizeofExpressionParser.g b/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPSizeofExpressionParser.g
index ac3994d60c..124f023bb3 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPSizeofExpressionParser.g
+++ b/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPSizeofExpressionParser.g
@@ -26,6 +26,10 @@ $DropRules
$End
+$Define
+ $ast_class /. IASTExpression ./
+$End
+
$Start
no_sizeof_type_id_start
$End
@@ -35,6 +39,6 @@ $Rules
no_sizeof_type_id_start
::= expression
| ERROR_TOKEN
- /. $Build consumeExpressionProblem(); $EndBuild ./
+ /. $Build consumeEmpty(); $EndBuild ./
$End \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPTemplateTypeParameterParser.g b/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPTemplateTypeParameterParser.g
index 6095b8b464..dfacf88d8e 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPTemplateTypeParameterParser.g
+++ b/lrparser/org.eclipse.cdt.core.lrparser/grammar/cpp/CPPTemplateTypeParameterParser.g
@@ -33,6 +33,16 @@ $Import
CPPGrammar.g
$End
+$Globals
+/.
+ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
+./
+$End
+
+$Define
+ $ast_class /. ICPPASTTemplateParameter ./
+$End
+
$Start
type_parameter_start
$End
@@ -42,6 +52,6 @@ $Rules
type_parameter_start
::= type_parameter
| ERROR_TOKEN
- /. $Build consumeDeclarationProblem(); $EndBuild ./
+ /. $Build consumeEmpty(); $EndBuild ./
$End \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/grammar/gcc/GCCParser.g b/lrparser/org.eclipse.cdt.core.lrparser/grammar/gcc/GCCParser.g
index b93fb6a77c..1ae760dd6d 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/grammar/gcc/GCCParser.g
+++ b/lrparser/org.eclipse.cdt.core.lrparser/grammar/gcc/GCCParser.g
@@ -21,6 +21,10 @@ $Import
GCCGrammar.g
$End
+$Define
+ $ast_class /. IASTTranslationUnit ./
+$End
+
$Start
translation_unit
$End \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/grammar/gcc/GCCSizeofExpressionParser.g b/lrparser/org.eclipse.cdt.core.lrparser/grammar/gcc/GCCSizeofExpressionParser.g
index 36eac42269..a3c6000fed 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/grammar/gcc/GCCSizeofExpressionParser.g
+++ b/lrparser/org.eclipse.cdt.core.lrparser/grammar/gcc/GCCSizeofExpressionParser.g
@@ -25,6 +25,9 @@ $DropRules
$End
+$Define
+ $ast_class /. IASTExpression ./
+$End
$Start
no_sizeof_type_name_start
@@ -35,6 +38,6 @@ $Rules
no_sizeof_type_name_start
::= expression
| ERROR_TOKEN
- /. $Build consumeExpressionProblem(); $EndBuild ./
+ /. $Build consumeEmpty(); $EndBuild ./
$End \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/grammar/gnu/GNUExtensions.g b/lrparser/org.eclipse.cdt.core.lrparser/grammar/gnu/GNUExtensions.g
index de45b9fb32..6afaf8418d 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/grammar/gnu/GNUExtensions.g
+++ b/lrparser/org.eclipse.cdt.core.lrparser/grammar/gnu/GNUExtensions.g
@@ -43,7 +43,7 @@ $Define
$action_initializations /.
- gnuAction = new $gnu_action_class (this, tu, astStack, $node_factory_create_expression);
+ gnuAction = new $gnu_action_class (this, astStack, $node_factory_create_expression);
gnuAction.setParserOptions(options);
gnuAction.setBaseAction(action);
./
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/grammar/gpp/GPPParser.g b/lrparser/org.eclipse.cdt.core.lrparser/grammar/gpp/GPPParser.g
index 22c2ad79dc..f2dd3ebf20 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/grammar/gpp/GPPParser.g
+++ b/lrparser/org.eclipse.cdt.core.lrparser/grammar/gpp/GPPParser.g
@@ -21,6 +21,10 @@ $Import
GPPGrammar.g
$End
+$Define
+ $ast_class /. IASTTranslationUnit ./
+$End
+
$Start
translation_unit
$End \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/grammar/gpp/GPPSizeofExpressionParser.g b/lrparser/org.eclipse.cdt.core.lrparser/grammar/gpp/GPPSizeofExpressionParser.g
index 285a239138..68bb20848a 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/grammar/gpp/GPPSizeofExpressionParser.g
+++ b/lrparser/org.eclipse.cdt.core.lrparser/grammar/gpp/GPPSizeofExpressionParser.g
@@ -28,6 +28,10 @@ $DropRules
$End
+$Define
+ $ast_class /. IASTExpression ./
+$End
+
$Start
no_sizeof_type_id_start
$End
@@ -37,6 +41,6 @@ $Rules
no_sizeof_type_id_start
::= expression
| ERROR_TOKEN
- /. $Build consumeExpressionProblem(); $EndBuild ./
+ /. $Build consumeEmpty(); $EndBuild ./
$End \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/grammar/template/FixedBtParserTemplateD.g b/lrparser/org.eclipse.cdt.core.lrparser/grammar/template/FixedBtParserTemplateD.g
index 4293508126..ea7a5bf27e 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/grammar/template/FixedBtParserTemplateD.g
+++ b/lrparser/org.eclipse.cdt.core.lrparser/grammar/template/FixedBtParserTemplateD.g
@@ -232,22 +232,22 @@ $Headers
super.reportError((firsttok > lasttok ? ParseErrorCodes.INSERTION_CODE : ParseErrorCodes.SUBSTITUTION_CODE), location, msg);
}
- public $ast_class parser()
+ public void parser()
{
- return parser(null, 0);
+ parser(null, 0);
}
- public $ast_class parser(Monitor monitor)
+ public void parser(Monitor monitor)
{
- return parser(monitor, 0);
+ parser(monitor, 0);
}
- public $ast_class parser(int error_repair_count)
+ public void parser(int error_repair_count)
{
- return parser(null, error_repair_count);
+ parser(null, error_repair_count);
}
- public $ast_class parser(Monitor monitor, int error_repair_count)
+ public void parser(Monitor monitor, int error_repair_count)
{
try
{
@@ -265,7 +265,7 @@ $Headers
try
{
- return ($ast_class) btParser.parse(error_repair_count);
+ btParser.parse(error_repair_count);
}
catch (BadParseException e)
{
@@ -273,8 +273,6 @@ $Headers
DiagnoseParser diagnoseParser = new DiagnoseParser(this, prs);
diagnoseParser.diagnose(e.error_token);
}
-
- return null;
}
./
@@ -314,10 +312,10 @@ $End
$Define
-- These macros allow the template and header code to be customized by an extending parser.
- $ast_class /.Object./
+ $ast_class /. IASTNode ./ -- override with more specific node type
$extra_interfaces /. ./ -- can override this macro to provide additional interfaces
- $additional_interfaces /. , IParserActionTokenProvider, IParser $extra_interfaces ./
+ $additional_interfaces /. , IParserActionTokenProvider, IParser<$ast_class> $extra_interfaces ./
$build_action_class /. ./ -- name of the class that has the AST building callbacks
$node_factory_create_expression /. ./ -- expression that will create the INodeFactory
@@ -344,13 +342,15 @@ $End
$Headers
/.
private $build_action_class action;
- private ScopedStack<Object> astStack = new ScopedStack<Object>();
+ private IASTCompletionNode compNode;
public $action_type() { // constructor
}
- private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
- action = new $build_action_class(this, tu, astStack, $node_factory_create_expression, $parser_factory_create_expression);
+ private void initActions(Set<IParser.Options> options) {
+ ScopedStack<Object> astStack = new ScopedStack<Object>();
+
+ action = new $build_action_class(this, astStack, $node_factory_create_expression, $parser_factory_create_expression);
action.setParserOptions(options);
$action_initializations
@@ -363,20 +363,21 @@ $Headers
}
- public IASTCompletionNode parse(IASTTranslationUnit tu, Set<IParser.Options> options) {
+ public $ast_class parse(Set<IParser.Options> options) {
// this has to be done, or... kaboom!
setStreamLength(getSize());
- initActions(tu, options);
+ initActions(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.getASTCompletionNode();
+ compNode = action.getASTCompletionNode(); // the completion node may be null
+ return ($ast_class) action.getParseResult();
+ }
+
- //action = null;
- //parserAction = null;
+ public IASTCompletionNode getCompletionNode() {
return compNode;
}
@@ -385,10 +386,6 @@ $Headers
return getTokens().subList(getLeftSpan(), getRightSpan() + 1);
}
- public IASTNode getSecondaryParseResult() {
- return (IASTNode) astStack.pop();
- }
-
public String[] getOrderedTerminalSymbols() {
return $sym_type.orderedTerminalSymbols;
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/BaseExtensibleLanguage.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/BaseExtensibleLanguage.java
index 7df47652e9..3bbac21499 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/BaseExtensibleLanguage.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/BaseExtensibleLanguage.java
@@ -17,6 +17,7 @@ import java.util.Set;
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
@@ -35,9 +36,6 @@ import org.eclipse.cdt.core.parser.util.ASTPrinter;
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.ASTTranslationUnit;
-import org.eclipse.cdt.internal.core.dom.parser.c.CASTTranslationUnit;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTranslationUnit;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPNodeFactory;
import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCLinkageFactory;
@@ -65,7 +63,7 @@ public abstract class BaseExtensibleLanguage extends AbstractLanguage {
* Can be overridden in subclasses to provide a different parser
* for a language extension.
*/
- protected abstract IParser getParser();
+ protected abstract IParser<IASTTranslationUnit> getParser();
/**
@@ -76,19 +74,6 @@ public abstract class BaseExtensibleLanguage extends AbstractLanguage {
/**
- * Normally all the AST nodes are created by the parser, but we
- * need the root node ahead of time.
- *
- * The preprocessor is responsible for creating preprocessor AST nodes,
- * so the preprocessor needs access to the translation unit so that it can
- * set the parent pointers on the AST nodes it creates.
- *
- * @return an IASTTranslationUnit object thats empty and will be filled in by the parser
- */
- protected abstract IASTTranslationUnit createASTTranslationUnit();
-
-
- /**
* Returns the ParserLanguage value that is to be used when creating
* an instance of CPreprocessor.
*
@@ -127,14 +112,13 @@ public abstract class BaseExtensibleLanguage extends AbstractLanguage {
ParserLanguage pl = getParserLanguage();
IScanner preprocessor = new CPreprocessor(reader, scanInfo, pl, log, config, fileCreator);
- preprocessor.setScanComments((options & OPTION_ADD_COMMENTS) != 0);
preprocessor.setComputeImageLocations((options & ILanguage.OPTION_NO_IMAGE_LOCATIONS) == 0);
// The translation unit has to be created here so that the preprocessor
// can fill in the preprocessor AST nodes.
- IASTTranslationUnit tu = getASTTranslationUnit(index, preprocessor);
- IParser parser = getParser();
- CPreprocessorAdapter.runCPreprocessor(preprocessor, parser, getTokenMap(), tu);
+ //IASTTranslationUnit tu = getASTTranslationUnit(index, preprocessor);
+ IParser<IASTTranslationUnit> parser = getParser();
+ CPreprocessorAdapter.runCPreprocessor(preprocessor, parser, getTokenMap());
Set<IParser.Options> parserOptions = new HashSet<IParser.Options>();
//if((options & OPTION_SKIP_FUNCTION_BODIES) != 0)
@@ -145,10 +129,9 @@ public abstract class BaseExtensibleLanguage extends AbstractLanguage {
if(!parserOptions.isEmpty())
parserOptions = EnumSet.copyOf(parserOptions);
- parser.parse(tu, parserOptions); // The parser will fill in the rest of the AST
-
- // the TU is marked as either a source file or a header file
- tu.setIsHeaderUnit((options & OPTION_IS_SOURCE_UNIT) == 0);
+ IASTTranslationUnit tu = parser.parse(parserOptions);
+ tu.setIsHeaderUnit((options & OPTION_IS_SOURCE_UNIT) == 0); // the TU is marked as either a source file or a header file
+ setUpTranslationUnit(tu, preprocessor, index);
if(DEBUG_PRINT_AST) {
System.out.println("Base Extensible Language AST:");
@@ -159,6 +142,28 @@ public abstract class BaseExtensibleLanguage extends AbstractLanguage {
}
+
+ private static void setUpTranslationUnit(IASTTranslationUnit tu, IScanner preprocessor, IIndex index) {
+ tu.setIndex(index);
+ if(tu instanceof ASTTranslationUnit) {
+ ((ASTTranslationUnit)tu).setLocationResolver(preprocessor.getLocationResolver());
+ }
+ for(IASTNode node : tu.getAllPreprocessorStatements()) {
+ node.setParent(tu);
+ }
+ for(IASTNode node : tu.getComments()) {
+ node.setParent(tu);
+ }
+ for(IASTNode node : tu.getMacroDefinitions()) {
+ node.setParent(tu);
+ }
+ for(IASTNode node : tu.getMacroExpansions()) {
+ node.setParent(tu);
+ }
+ }
+
+
+
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader,
IScannerInfo scanInfo, ICodeReaderFactory fileCreator,
IIndex index, IParserLogService log) throws CoreException {
@@ -190,14 +195,15 @@ public abstract class BaseExtensibleLanguage extends AbstractLanguage {
IScanner preprocessor = new CPreprocessor(reader, scanInfo, pl, log, config, fileCreator);
preprocessor.setContentAssistMode(offset);
- IParser parser = getParser();
- IASTTranslationUnit tu = getASTTranslationUnit(index, preprocessor);
-
- CPreprocessorAdapter.runCPreprocessor(preprocessor, parser, getTokenMap(), tu);
+ IParser<IASTTranslationUnit> parser = getParser();
+ CPreprocessorAdapter.runCPreprocessor(preprocessor, parser, getTokenMap());
// the parser will fill in the rest of the AST
Set<IParser.Options> parserOptions = EnumSet.of(IParser.Options.OPTION_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS);
- IASTCompletionNode completionNode = parser.parse(tu, parserOptions);
+ IASTTranslationUnit tu = parser.parse(parserOptions);
+ setUpTranslationUnit(tu, preprocessor, index);
+
+ IASTCompletionNode completionNode = parser.getCompletionNode();
if(DEBUG_PRINT_AST) {
System.out.println("Base Extensible Language AST:");
@@ -208,15 +214,6 @@ public abstract class BaseExtensibleLanguage extends AbstractLanguage {
}
- private IASTTranslationUnit getASTTranslationUnit(IIndex index, IScanner preprocessor) {
- IASTTranslationUnit tu = createASTTranslationUnit();
- tu.setIndex(index);
- if(tu instanceof ASTTranslationUnit) {
- ((ASTTranslationUnit)tu).setLocationResolver(preprocessor.getLocationResolver());
- }
- return tu;
- }
-
/*
* For debugging.
*/
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/CPreprocessorAdapter.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/CPreprocessorAdapter.java
index 66d024a120..a9d3d5b15e 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/CPreprocessorAdapter.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/CPreprocessorAdapter.java
@@ -13,7 +13,6 @@ package org.eclipse.cdt.core.dom.lrparser;
import lpg.lpgjavaruntime.IToken;
import lpg.lpgjavaruntime.Token;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.parser.EndOfFileException;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.core.parser.OffsetLimitReachedException;
@@ -45,8 +44,7 @@ class CPreprocessorAdapter {
* Collect the tokens generated by the preprocessor.
* TODO: should preprocessor.nextTokenRaw() be called instead?
*/
- @SuppressWarnings("restriction")
- public static void runCPreprocessor(IScanner preprocessor, ITokenCollector tokenCollector, IDOMTokenMap tokenMap, IASTTranslationUnit tu) {
+ public static void runCPreprocessor(IScanner preprocessor, ITokenCollector tokenCollector, IDOMTokenMap tokenMap) {
// LPG requires that the token stream start with a dummy token
tokenCollector.addToken(createDummyToken());
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/IParser.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/IParser.java
index 3ccb1b18c2..3b54e34e4f 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/IParser.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/IParser.java
@@ -15,7 +15,6 @@ import java.util.Set;
import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
import org.eclipse.cdt.core.dom.ast.IASTNode;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.model.ILanguage;
@@ -24,7 +23,7 @@ import org.eclipse.cdt.core.model.ILanguage;
*
* @author Mike Kucera
*/
-public interface IParser extends ITokenCollector {
+public interface IParser<N extends IASTNode> extends ITokenCollector {
/**
* Options used by implementations of IParser. Some of the options
@@ -70,12 +69,15 @@ public interface IParser extends ITokenCollector {
* @throws NullPointerException if either parameter is null
* @see EnumSet
*/
- public IASTCompletionNode parse(IASTTranslationUnit tu, Set<Options> options);
+ public N parse(Set<Options> options);
/**
- * Returns the result of a secondary parser.
+ * Returns the completion node if a completion token was encountered
+ * during the parse, null otherwise.
*/
- public IASTNode getSecondaryParseResult();
+ public IASTCompletionNode getCompletionNode();
+
+
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ASTCompletionNode.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ASTCompletionNode.java
index 803d1341d5..104239da8c 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ASTCompletionNode.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ASTCompletionNode.java
@@ -41,7 +41,7 @@ public class ASTCompletionNode implements IASTCompletionNode {
private final List<IASTName> names = new LinkedList<IASTName>();
private final String prefix;
- private final IASTTranslationUnit tu;
+ private IASTTranslationUnit tu;
/**
@@ -52,12 +52,14 @@ public class ASTCompletionNode implements IASTCompletionNode {
public ASTCompletionNode(String prefix, IASTTranslationUnit tu) {
if("".equals(prefix)) //$NON-NLS-1$
throw new IllegalArgumentException("prefix cannot be the empty string"); //$NON-NLS-1$
- if(tu == null)
- throw new NullPointerException("tu is null"); //$NON-NLS-1$
this.prefix = prefix;
this.tu = tu;
}
+
+ public ASTCompletionNode(String prefix) {
+ this(prefix, null);
+ }
public void addName(IASTName name) {
@@ -89,7 +91,14 @@ public class ASTCompletionNode implements IASTCompletionNode {
}
public IASTTranslationUnit getTranslationUnit() {
+ if(names.isEmpty())
+ return null;
+
+ if(tu == null)
+ tu = names.get(0).getTranslationUnit();
+
return tu;
}
+
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/AbstractParserAction.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/AbstractParserAction.java
index ddf394ad72..973e5de5cd 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/AbstractParserAction.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/AbstractParserAction.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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
+ *******************************************************************************/
package org.eclipse.cdt.core.dom.lrparser.action;
import java.util.EnumSet;
@@ -9,7 +19,6 @@ import lpg.lpgjavaruntime.IToken;
import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.lrparser.IParser;
import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
@@ -40,9 +49,6 @@ public abstract class AbstractParserAction {
/** The completion node, only generated during a completion parse */
protected ASTCompletionNode completionNode;
- /** The root node is created outside the parser because it is also needed by the preprocessor */
- protected final IASTTranslationUnit tu;
-
/** Options that change the behavior of the parser actions */
protected Set<IParser.Options> options = EnumSet.noneOf(IParser.Options.class);
@@ -64,16 +70,13 @@ public abstract class AbstractParserAction {
* @param tu Root node of the AST, its list of declarations should be empty.
* @throws NullPointerException if any of the parameters are null
*/
- public AbstractParserAction(IParserActionTokenProvider parser, IASTTranslationUnit tu, ScopedStack<Object> astStack) {
+ public AbstractParserAction(IParserActionTokenProvider parser, ScopedStack<Object> astStack) {
if(parser == null)
throw new NullPointerException("parser is null"); //$NON-NLS-1$
- if(tu == null)
- throw new NullPointerException("tu is null"); //$NON-NLS-1$
if(astStack == null)
throw new NullPointerException("astStack is null"); //$NON-NLS-1$
this.parser = parser;
- this.tu = tu;
this.astStack = astStack;
}
@@ -110,26 +113,14 @@ public abstract class AbstractParserAction {
protected void addNameToCompletionNode(IASTName name, String prefix) {
if(completionNode == null) {
prefix = (prefix == null || prefix.length() == 0) ? null : prefix;
- completionNode = newCompletionNode(prefix, tu);
+ completionNode = newCompletionNode(prefix);
}
completionNode.addName(name);
}
- public ASTCompletionNode newCompletionNode(String prefix, IASTTranslationUnit tu) {
- return new ASTCompletionNode((prefix == null || prefix.length() == 0) ? null : prefix, tu);
- }
-
- /**
- * Used to combine completion nodes from secondary parsers into
- * the main completion node.
- */
- protected void addNameToCompletionNode(IASTCompletionNode node) {
- if(node == null)
- return;
-
- for(IASTName name : node.getNames())
- addNameToCompletionNode(name, node.getPrefix());
+ public ASTCompletionNode newCompletionNode(String prefix) {
+ return new ASTCompletionNode((prefix == null || prefix.length() == 0) ? null : prefix);
}
@@ -140,12 +131,19 @@ public abstract class AbstractParserAction {
return completionNode;
}
+ /**
+ * Returns the parse result.
+ * @return
+ */
+ public IASTNode getParseResult() {
+ return (IASTNode) astStack.peek();
+ }
/**
* Runs the given parser on the given token list.
*
*/
- protected IASTNode runSecondaryParser(IParser secondaryParser) {
+ protected <N extends IASTNode> N runSecondaryParser(IParser<N> secondaryParser) {
return runSecondaryParser(secondaryParser, parser.getRuleTokens());
}
@@ -153,7 +151,7 @@ public abstract class AbstractParserAction {
/**
* Runs the given parser on the tokens that make up the current rule.
*/
- protected IASTNode runSecondaryParser(IParser secondaryParser, List<IToken> tokens) {
+ protected <N extends IASTNode> N runSecondaryParser(IParser<N> secondaryParser, List<IToken> tokens) {
// the secondary parser will alter the token kinds, which will need to be undone
int[] savedKinds = new int[tokens.size()];
@@ -162,11 +160,13 @@ public abstract class AbstractParserAction {
savedKinds[i++] = token.getKind();
secondaryParser.setTokens(tokens);
+ N result = secondaryParser.parse(options);
- // need to pass tu because any new completion nodes need to be linked directly to the root
- IASTCompletionNode compNode = secondaryParser.parse(tu, options);
- addNameToCompletionNode(compNode);
- IASTNode result = secondaryParser.getSecondaryParseResult();
+ IASTCompletionNode compNode = secondaryParser.getCompletionNode();
+ if(compNode != null) {
+ for(IASTName name : compNode.getNames())
+ addNameToCompletionNode(name, compNode.getPrefix());
+ }
// restore the token kinds
i = 0;
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java
index d66e66389c..aa37e6848f 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java
@@ -55,7 +55,6 @@ import org.eclipse.cdt.core.dom.ast.IASTNullStatement;
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
import org.eclipse.cdt.core.dom.ast.IASTProblem;
-import org.eclipse.cdt.core.dom.ast.IASTProblemExpression;
import org.eclipse.cdt.core.dom.ast.IASTProblemHolder;
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
@@ -108,8 +107,8 @@ public abstract class BuildASTParserAction extends AbstractParserAction {
* @param tu Root node of the AST, its list of declarations should be empty.
* @throws NullPointerException if any of the parameters are null
*/
- public BuildASTParserAction(IParserActionTokenProvider parser, IASTTranslationUnit tu, ScopedStack<Object> astStack, INodeFactory nodeFactory, ISecondaryParserFactory parserFactory) {
- super(parser, tu, astStack);
+ public BuildASTParserAction(IParserActionTokenProvider parser, ScopedStack<Object> astStack, INodeFactory nodeFactory, ISecondaryParserFactory parserFactory) {
+ super(parser, astStack);
if(nodeFactory == null)
throw new NullPointerException("nodeFactory is null"); //$NON-NLS-1$
@@ -124,6 +123,8 @@ public abstract class BuildASTParserAction extends AbstractParserAction {
public void consumeTranslationUnit() {
// can't close the outermost scope
// the outermost scope may be empty if there are no tokens in the file
+ IASTTranslationUnit tu = nodeFactory.newTranslationUnit();
+
for(Object o : astStack.topScope()) {
tu.addDeclaration((IASTDeclaration)o);
}
@@ -135,8 +136,10 @@ public abstract class BuildASTParserAction extends AbstractParserAction {
ParserUtil.setOffsetAndLength(tu, 0, offset(d) + length(d));
}
- resolveAmbiguityNodes();
+ resolveAmbiguityNodes(tu);
tu.freeze();
+
+ astStack.push(tu);
}
@@ -145,7 +148,7 @@ public abstract class BuildASTParserAction extends AbstractParserAction {
*
* @see AbstractGNUSourceCodeParser#resolveAmbiguities()
*/
- private void resolveAmbiguityNodes() {
+ private void resolveAmbiguityNodes(IASTTranslationUnit tu) {
if (tu instanceof ASTTranslationUnit) {
((ASTTranslationUnit)tu).resolveAmbiguities();
}
@@ -175,10 +178,10 @@ public abstract class BuildASTParserAction extends AbstractParserAction {
List<IToken> expressionTokens = parser.getRuleTokens();
expressionTokens = expressionTokens.subList(0, expressionTokens.size()-1); // remove the semicolon at the end
- IParser expressionParser = parserFactory.getExpressionParser(parser);
- IASTExpression expr = (IASTExpression) runSecondaryParser(expressionParser, expressionTokens);
+ IParser<IASTExpression> expressionParser = parserFactory.getExpressionParser(parser);
+ IASTExpression expr = runSecondaryParser(expressionParser, expressionTokens);
- if(expr != null && !(expr instanceof IASTProblemExpression)) { // the parse may fail
+ if(expr != null) { // the parse may fail
expressionStatement = nodeFactory.newExpressionStatement(expr);
setOffsetAndLength(expressionStatement);
}
@@ -349,17 +352,17 @@ public abstract class BuildASTParserAction extends AbstractParserAction {
IASTCastExpression expr = nodeFactory.newCastExpression(operator, typeId, operand);
setOffsetAndLength(expr);
- IASTNode alternateExpr = null;
+ IASTExpression alternateExpr = null;
if(operator == IASTCastExpression.op_cast) { // don't reparse for dynamic_cast etc as those are not ambiguous
// try parsing as non-cast to resolve ambiguities
- IParser secondaryParser = parserFactory.getNoCastExpressionParser(parser);
+ IParser<IASTExpression> secondaryParser = parserFactory.getNoCastExpressionParser(parser);
alternateExpr = runSecondaryParser(secondaryParser);
}
- if(alternateExpr == null || alternateExpr instanceof IASTProblemExpression)
+ if(alternateExpr == null)
astStack.push(expr);
else {
- IASTNode ambiguityNode = createAmbiguousExpression(expr, (IASTExpression)alternateExpr);
+ IASTNode ambiguityNode = createAmbiguousExpression(expr, alternateExpr);
setOffsetAndLength(ambiguityNode);
astStack.push(ambiguityNode);
}
@@ -392,13 +395,13 @@ public abstract class BuildASTParserAction extends AbstractParserAction {
setOffsetAndLength(expr);
// try parsing as an expression to resolve ambiguities
- IParser secondaryParser = parserFactory.getSizeofExpressionParser(parser);
- IASTNode alternateExpr = runSecondaryParser(secondaryParser);
+ IParser<IASTExpression> secondaryParser = parserFactory.getSizeofExpressionParser(parser);
+ IASTExpression alternateExpr = runSecondaryParser(secondaryParser);
- if(alternateExpr == null || alternateExpr instanceof IASTProblemExpression)
+ if(alternateExpr == null)
astStack.push(expr);
else {
- IASTNode ambiguityNode = createAmbiguousExpression(expr, (IASTExpression)alternateExpr);
+ IASTNode ambiguityNode = createAmbiguousExpression(expr, alternateExpr);
setOffsetAndLength(ambiguityNode);
astStack.push(ambiguityNode);
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ISecondaryParserFactory.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ISecondaryParserFactory.java
index cf02851234..b0ed1bc947 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ISecondaryParserFactory.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ISecondaryParserFactory.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.lrparser.action;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.lrparser.IParser;
import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
@@ -27,20 +28,20 @@ public interface ISecondaryParserFactory {
/**
* Get the parser that will recognize expressions.
*/
- IParser getExpressionParser(IParserActionTokenProvider parser);
+ IParser<IASTExpression> getExpressionParser(IParserActionTokenProvider parser);
/**
* Expression parser that does not recognize cast expressions,
* used to disambiguate casts.
*/
- IParser getNoCastExpressionParser(IParserActionTokenProvider parser);
+ IParser<IASTExpression> getNoCastExpressionParser(IParserActionTokenProvider parser);
/**
* Expression parser that treats all sizeof and typeid expressions
* as unary expressions.
*/
- IParser getSizeofExpressionParser(IParserActionTokenProvider parser);
+ IParser<IASTExpression> getSizeofExpressionParser(IParserActionTokenProvider parser);
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99BuildASTParserAction.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99BuildASTParserAction.java
index 4c0a94f782..45457c831c 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99BuildASTParserAction.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99BuildASTParserAction.java
@@ -46,7 +46,6 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayDesignator;
@@ -95,8 +94,8 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
* @param orderedTerminalSymbols When an instance of this class is created for a parser
* that parsers token kinds will be mapped back to the base C99 parser's token kinds.
*/
- public C99BuildASTParserAction(IParserActionTokenProvider parser, IASTTranslationUnit tu, ScopedStack<Object> astStack, ICNodeFactory nodeFactory, ISecondaryParserFactory parserFactory) {
- super(parser, tu, astStack, nodeFactory, parserFactory);
+ public C99BuildASTParserAction(IParserActionTokenProvider parser, ScopedStack<Object> astStack, ICNodeFactory nodeFactory, ISecondaryParserFactory parserFactory) {
+ super(parser, astStack, nodeFactory, parserFactory);
this.nodeFactory = nodeFactory;
this.tokenMap = new TokenMap(C99Parsersym.orderedTerminalSymbols, parser.getOrderedTerminalSymbols());
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99SecondaryParserFactory.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99SecondaryParserFactory.java
index 6f9127c7a1..83e0eef10f 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99SecondaryParserFactory.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/c99/C99SecondaryParserFactory.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.lrparser.action.c99;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.lrparser.IParser;
import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
import org.eclipse.cdt.core.dom.lrparser.action.ISecondaryParserFactory;
@@ -26,15 +27,15 @@ public class C99SecondaryParserFactory implements ISecondaryParserFactory {
}
- public IParser getExpressionParser(IParserActionTokenProvider parser) {
+ public IParser<IASTExpression> getExpressionParser(IParserActionTokenProvider parser) {
return new C99ExpressionParser(parser);
}
- public IParser getNoCastExpressionParser(IParserActionTokenProvider parser) {
+ public IParser<IASTExpression> getNoCastExpressionParser(IParserActionTokenProvider parser) {
return new C99NoCastExpressionParser(parser);
}
- public IParser getSizeofExpressionParser(IParserActionTokenProvider parser) {
+ public IParser<IASTExpression> getSizeofExpressionParser(IParserActionTokenProvider parser) {
return new C99SizeofExpressionParser(parser);
}
} \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPBuildASTParserAction.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPBuildASTParserAction.java
index 13268fed81..74179e0518 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPBuildASTParserAction.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPBuildASTParserAction.java
@@ -10,57 +10,10 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.lrparser.action.cpp;
-import static org.eclipse.cdt.core.dom.lrparser.action.ParserUtil.endOffset;
-import static org.eclipse.cdt.core.dom.lrparser.action.ParserUtil.length;
-import static org.eclipse.cdt.core.dom.lrparser.action.ParserUtil.matchTokens;
-import static org.eclipse.cdt.core.dom.lrparser.action.ParserUtil.offset;
+import static org.eclipse.cdt.core.dom.lrparser.action.ParserUtil.*;
import static org.eclipse.cdt.core.parser.util.CollectionUtils.findFirstAndRemove;
import static org.eclipse.cdt.core.parser.util.CollectionUtils.reverseIterable;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_ColonColon;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_Completion;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_EndOfCompletion;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_GT;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_LT;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_LeftBracket;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_LeftParen;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_RightBracket;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_RightParen;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_Tilde;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_auto;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_bool;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_char;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_class;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_const;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_delete;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_double;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_enum;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_explicit;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_extern;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_float;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_for;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_friend;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_identifier;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_inline;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_int;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_long;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_mutable;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_new;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_private;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_protected;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_public;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_register;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_short;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_signed;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_static;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_struct;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_typedef;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_typename;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_union;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_unsigned;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_virtual;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_void;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_volatile;
-import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.TK_wchar_t;
+import static org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym.*;
import java.util.Arrays;
import java.util.Collections;
@@ -88,12 +41,10 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTPointer;
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
-import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
@@ -183,8 +134,8 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
* @param orderedTerminalSymbols When an instance of this class is created for a parser
* that parsers token kinds will be mapped back to the base C99 parser's token kinds.
*/
- public CPPBuildASTParserAction(IParserActionTokenProvider parser, IASTTranslationUnit tu, ScopedStack<Object> astStack, ICPPNodeFactory nodeFactory, ICPPSecondaryParserFactory parserFactory) {
- super(parser, tu, astStack, nodeFactory, parserFactory);
+ public CPPBuildASTParserAction(IParserActionTokenProvider parser, ScopedStack<Object> astStack, ICPPNodeFactory nodeFactory, ICPPSecondaryParserFactory parserFactory) {
+ super(parser, astStack, nodeFactory, parserFactory);
this.nodeFactory = nodeFactory;
this.parserFactory = parserFactory;
@@ -457,8 +408,8 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
*/
public void consumeTemplateArgumentTypeId() {
// TODO is this necessary? It should be able to tell if it looks like an id expression
- IParser secondaryParser = parserFactory.getExpressionParser(parser);
- IASTNode result = runSecondaryParser(secondaryParser);
+ IParser<IASTExpression> secondaryParser = parserFactory.getExpressionParser(parser);
+ IASTExpression result = runSecondaryParser(secondaryParser);
// The grammar rule allows assignment_expression, but the ambiguity
// only arises with id_expressions.
@@ -1363,15 +1314,15 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
if(!(declarator instanceof IASTFunctionDeclarator))
return;
- IParser secondaryParser = parserFactory.getNoFunctionDeclaratorParser(parser);
- IASTNode notFunctionDeclarator = runSecondaryParser(secondaryParser);
+ IParser<IASTDeclarator> secondaryParser = parserFactory.getNoFunctionDeclaratorParser(parser);
+ IASTDeclarator notFunctionDeclarator = runSecondaryParser(secondaryParser);
- if(notFunctionDeclarator == null || notFunctionDeclarator instanceof IASTProblemDeclaration)
+ if(notFunctionDeclarator == null)
return;
astStack.pop();
- IASTNode ambiguityNode = new CPPASTAmbiguousDeclarator(declarator, (IASTDeclarator)notFunctionDeclarator);
+ IASTNode ambiguityNode = new CPPASTAmbiguousDeclarator(declarator, notFunctionDeclarator);
setOffsetAndLength(ambiguityNode);
astStack.push(ambiguityNode);
@@ -1772,10 +1723,10 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
* Yes its a hack.
*/
public void consumeTemplateParamterDeclaration() {
- IParser typeParameterParser = parserFactory.getTemplateTypeParameterParser(parser);
+ IParser<ICPPASTTemplateParameter> typeParameterParser = parserFactory.getTemplateTypeParameterParser(parser);
IASTNode alternate = runSecondaryParser(typeParameterParser);
- if(alternate == null || alternate instanceof IASTProblemDeclaration)
+ if(alternate == null)
return;
astStack.pop(); // throw away the incorrect AST
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPSecondaryParserFactory.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPSecondaryParserFactory.java
index f5e109bda2..1448d3e5fb 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPSecondaryParserFactory.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPSecondaryParserFactory.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.lrparser.action.cpp;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
import org.eclipse.cdt.core.dom.lrparser.IParser;
import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
import org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPExpressionParser;
@@ -28,23 +31,23 @@ public class CPPSecondaryParserFactory implements ICPPSecondaryParserFactory {
}
- public IParser getTemplateTypeParameterParser(IParserActionTokenProvider parser) {
+ public IParser<ICPPASTTemplateParameter> getTemplateTypeParameterParser(IParserActionTokenProvider parser) {
return new CPPTemplateTypeParameterParser(parser);
}
- public IParser getNoFunctionDeclaratorParser(IParserActionTokenProvider parser) {
+ public IParser<IASTDeclarator> getNoFunctionDeclaratorParser(IParserActionTokenProvider parser) {
return new CPPNoFunctionDeclaratorParser(parser);
}
- public IParser getExpressionParser(IParserActionTokenProvider parser) {
+ public IParser<IASTExpression> getExpressionParser(IParserActionTokenProvider parser) {
return new CPPExpressionParser(parser);
}
- public IParser getNoCastExpressionParser(IParserActionTokenProvider parser) {
+ public IParser<IASTExpression> getNoCastExpressionParser(IParserActionTokenProvider parser) {
return new CPPNoCastExpressionParser(parser);
}
- public IParser getSizeofExpressionParser(IParserActionTokenProvider parser) {
+ public IParser<IASTExpression> getSizeofExpressionParser(IParserActionTokenProvider parser) {
return new CPPSizeofExpressionParser(parser);
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/ICPPSecondaryParserFactory.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/ICPPSecondaryParserFactory.java
index 84f31f9ccf..c22032b84c 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/ICPPSecondaryParserFactory.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/ICPPSecondaryParserFactory.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.lrparser.action.cpp;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
import org.eclipse.cdt.core.dom.lrparser.IParser;
import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
import org.eclipse.cdt.core.dom.lrparser.action.ISecondaryParserFactory;
@@ -22,8 +24,8 @@ import org.eclipse.cdt.core.dom.lrparser.action.ISecondaryParserFactory;
*/
public interface ICPPSecondaryParserFactory extends ISecondaryParserFactory {
- IParser getTemplateTypeParameterParser(IParserActionTokenProvider parser);
+ IParser<ICPPASTTemplateParameter> getTemplateTypeParameterParser(IParserActionTokenProvider parser);
- IParser getNoFunctionDeclaratorParser(IParserActionTokenProvider parser);
+ IParser<IASTDeclarator> getNoFunctionDeclaratorParser(IParserActionTokenProvider parser);
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GCCBuildASTParserAction.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GCCBuildASTParserAction.java
index 9ef4ef8c1b..ad5b85070e 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GCCBuildASTParserAction.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GCCBuildASTParserAction.java
@@ -16,7 +16,6 @@ import java.util.List;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTName;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.c.ICASTFieldDesignator;
import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICNodeFactory;
@@ -31,8 +30,8 @@ public class GCCBuildASTParserAction extends GNUBuildASTParserAction {
private C99BuildASTParserAction baseAction;
- public GCCBuildASTParserAction(IParserActionTokenProvider parser, IASTTranslationUnit tu, ScopedStack<Object> astStack, ICNodeFactory nodeFactory) {
- super(parser, tu, astStack, nodeFactory);
+ public GCCBuildASTParserAction(IParserActionTokenProvider parser, ScopedStack<Object> astStack, ICNodeFactory nodeFactory) {
+ super(parser, astStack, nodeFactory);
this.nodeFactory = nodeFactory;
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GCCSecondaryParserFactory.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GCCSecondaryParserFactory.java
index 62c3cfc4b3..1fdc3ee6f0 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GCCSecondaryParserFactory.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GCCSecondaryParserFactory.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.lrparser.action.gnu;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.lrparser.IParser;
import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
import org.eclipse.cdt.core.dom.lrparser.action.ISecondaryParserFactory;
@@ -26,15 +27,15 @@ public class GCCSecondaryParserFactory implements ISecondaryParserFactory {
}
- public IParser getExpressionParser(IParserActionTokenProvider parser) {
+ public IParser<IASTExpression> getExpressionParser(IParserActionTokenProvider parser) {
return new C99ExpressionParser(parser);
}
- public IParser getNoCastExpressionParser(IParserActionTokenProvider parser) {
+ public IParser<IASTExpression> getNoCastExpressionParser(IParserActionTokenProvider parser) {
return new C99NoCastExpressionParser(parser);
}
- public IParser getSizeofExpressionParser(IParserActionTokenProvider parser) {
+ public IParser<IASTExpression> getSizeofExpressionParser(IParserActionTokenProvider parser) {
return new GCCSizeofExpressionParser(parser);
}
} \ No newline at end of file
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GNUBuildASTParserAction.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GNUBuildASTParserAction.java
index 40d1ed867e..d71b2d1c97 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GNUBuildASTParserAction.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GNUBuildASTParserAction.java
@@ -16,7 +16,6 @@ import lpg.lpgjavaruntime.IToken;
import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTName;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.INodeFactory;
import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
import org.eclipse.cdt.core.dom.lrparser.action.AbstractParserAction;
@@ -30,8 +29,8 @@ public class GNUBuildASTParserAction extends AbstractParserAction {
private final TokenMap tokenMap;
- public GNUBuildASTParserAction(IParserActionTokenProvider parser, IASTTranslationUnit tu, ScopedStack<Object> astStack, INodeFactory nodeFactory) {
- super(parser, tu, astStack);
+ public GNUBuildASTParserAction(IParserActionTokenProvider parser, ScopedStack<Object> astStack, INodeFactory nodeFactory) {
+ super(parser, astStack);
this.nodeFactory = nodeFactory;
this.tokenMap = new TokenMap(GCCParsersym.orderedTerminalSymbols, parser.getOrderedTerminalSymbols());
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GPPBuildASTParserAction.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GPPBuildASTParserAction.java
index 63934db414..18ec92f518 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GPPBuildASTParserAction.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GPPBuildASTParserAction.java
@@ -17,7 +17,6 @@ import java.util.List;
import lpg.lpgjavaruntime.IToken;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNodeFactory;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
@@ -33,8 +32,8 @@ public class GPPBuildASTParserAction extends GNUBuildASTParserAction {
private CPPBuildASTParserAction baseAction;
- public GPPBuildASTParserAction(IParserActionTokenProvider parser, IASTTranslationUnit tu, ScopedStack<Object> astStack, ICPPNodeFactory nodeFactory) {
- super(parser, tu, astStack, nodeFactory);
+ public GPPBuildASTParserAction(IParserActionTokenProvider parser, ScopedStack<Object> astStack, ICPPNodeFactory nodeFactory) {
+ super(parser, astStack, nodeFactory);
this.nodeFactory = nodeFactory;
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GPPSecondaryParserFactory.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GPPSecondaryParserFactory.java
index 50368557b6..4e59e9e5a3 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GPPSecondaryParserFactory.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/gnu/GPPSecondaryParserFactory.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.lrparser.action.gnu;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
import org.eclipse.cdt.core.dom.lrparser.IParser;
import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
import org.eclipse.cdt.core.dom.lrparser.action.cpp.ICPPSecondaryParserFactory;
@@ -29,23 +32,23 @@ public class GPPSecondaryParserFactory implements ICPPSecondaryParserFactory {
}
- public IParser getTemplateTypeParameterParser(IParserActionTokenProvider parser) {
+ public IParser<ICPPASTTemplateParameter> getTemplateTypeParameterParser(IParserActionTokenProvider parser) {
return new CPPTemplateTypeParameterParser(parser);
}
- public IParser getNoFunctionDeclaratorParser(IParserActionTokenProvider parser) {
+ public IParser<IASTDeclarator> getNoFunctionDeclaratorParser(IParserActionTokenProvider parser) {
return new CPPNoFunctionDeclaratorParser(parser);
}
- public IParser getExpressionParser(IParserActionTokenProvider parser) {
+ public IParser<IASTExpression> getExpressionParser(IParserActionTokenProvider parser) {
return new CPPExpressionParser(parser);
}
- public IParser getNoCastExpressionParser(IParserActionTokenProvider parser) {
+ public IParser<IASTExpression> getNoCastExpressionParser(IParserActionTokenProvider parser) {
return new CPPNoCastExpressionParser(parser);
}
- public IParser getSizeofExpressionParser(IParserActionTokenProvider parser) {
+ public IParser<IASTExpression> getSizeofExpressionParser(IParserActionTokenProvider parser) {
return new GPPSizeofExpressionParser(parser);
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/c99/C99Language.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/c99/C99Language.java
index 769a11d512..df858af37d 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/c99/C99Language.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/c99/C99Language.java
@@ -21,14 +21,12 @@ import org.eclipse.cdt.core.model.IContributedModelBuilder;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parser;
-import org.eclipse.cdt.internal.core.dom.parser.c.CNodeFactory;
/**
* ILanguage implementation for the C99 parser.
*
* @author Mike Kucera
*/
-@SuppressWarnings("restriction")
public class C99Language extends BaseExtensibleLanguage {
public static final String ID = "org.eclipse.cdt.core.lrparser.c99"; //$NON-NLS-1$
@@ -41,7 +39,7 @@ public class C99Language extends BaseExtensibleLanguage {
}
@Override
- protected IParser getParser() {
+ protected IParser<IASTTranslationUnit> getParser() {
return new C99Parser();
}
@@ -72,9 +70,4 @@ public class C99Language extends BaseExtensibleLanguage {
return ParserLanguage.C;
}
- @Override
- protected IASTTranslationUnit createASTTranslationUnit() {
- return CNodeFactory.getDefault().newTranslationUnit();
- }
-
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/cpp/ISOCPPLanguage.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/cpp/ISOCPPLanguage.java
index e287abcbf1..a07d32465b 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/cpp/ISOCPPLanguage.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/cpp/ISOCPPLanguage.java
@@ -21,14 +21,12 @@ import org.eclipse.cdt.core.model.IContributedModelBuilder;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParser;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPNodeFactory;
/**
* ILanguage implementation for the C++ parser.
*
* @author Mike Kucera
*/
-@SuppressWarnings("restriction")
public class ISOCPPLanguage extends BaseExtensibleLanguage {
public static final String ID = "org.eclipse.cdt.core.lrparser.isocpp"; //$NON-NLS-1$
@@ -40,7 +38,7 @@ public class ISOCPPLanguage extends BaseExtensibleLanguage {
}
@Override
- protected IParser getParser() {
+ protected IParser<IASTTranslationUnit> getParser() {
return new CPPParser();
}
@@ -70,14 +68,6 @@ public class ISOCPPLanguage extends BaseExtensibleLanguage {
protected ParserLanguage getParserLanguage() {
return ParserLanguage.CPP;
}
-
- /**
- * Gets the translation unit object and sets the index and the location resolver.
- */
- @Override
- protected IASTTranslationUnit createASTTranslationUnit() {
- return CPPNodeFactory.getDefault().newTranslationUnit();
- }
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/GCCLanguage.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/GCCLanguage.java
index 8d8826d98e..6cbfc2272f 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/GCCLanguage.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/GCCLanguage.java
@@ -21,14 +21,12 @@ import org.eclipse.cdt.core.model.IContributedModelBuilder;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.internal.core.dom.lrparser.gcc.GCCParser;
-import org.eclipse.cdt.internal.core.dom.parser.c.CNodeFactory;
/**
* ILanguage implementation for the C99 parser.
*
* @author Mike Kucera
*/
-@SuppressWarnings("restriction")
public class GCCLanguage extends BaseExtensibleLanguage {
public static final String ID = "org.eclipse.cdt.core.lrparser.gcc"; //$NON-NLS-1$
@@ -40,7 +38,7 @@ public class GCCLanguage extends BaseExtensibleLanguage {
}
@Override
- protected IParser getParser() {
+ protected IParser<IASTTranslationUnit> getParser() {
return new GCCParser();
}
@@ -71,9 +69,4 @@ public class GCCLanguage extends BaseExtensibleLanguage {
return ParserLanguage.C;
}
- @Override
- protected IASTTranslationUnit createASTTranslationUnit() {
- return CNodeFactory.getDefault().newTranslationUnit();
- }
-
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/GPPLanguage.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/GPPLanguage.java
index 3962f7f9c2..219f540088 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/GPPLanguage.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/gnu/GPPLanguage.java
@@ -21,14 +21,12 @@ import org.eclipse.cdt.core.model.IContributedModelBuilder;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.internal.core.dom.lrparser.gpp.GPPParser;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPNodeFactory;
/**
* ILanguage implementation for the GPP parser.
*
* @author Mike Kucera
*/
-@SuppressWarnings("restriction")
public class GPPLanguage extends BaseExtensibleLanguage {
public static final String ID = "org.eclipse.cdt.core.lrparser.gpp"; //$NON-NLS-1$
@@ -40,7 +38,7 @@ public class GPPLanguage extends BaseExtensibleLanguage {
}
@Override
- protected IParser getParser() {
+ protected IParser<IASTTranslationUnit> getParser() {
return new GPPParser();
}
@@ -71,9 +69,4 @@ public class GPPLanguage extends BaseExtensibleLanguage {
return ParserLanguage.CPP;
}
- @Override
- protected IASTTranslationUnit createASTTranslationUnit() {
- return CPPNodeFactory.getDefault().newTranslationUnit();
- }
-
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99ExpressionParser.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99ExpressionParser.java
index f8e132874b..a0bc2fc7b8 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99ExpressionParser.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99ExpressionParser.java
@@ -29,7 +29,7 @@ import org.eclipse.cdt.internal.core.dom.parser.c.CNodeFactory;
import org.eclipse.cdt.core.dom.lrparser.action.c99.C99BuildASTParserAction;
import org.eclipse.cdt.core.dom.lrparser.action.c99.C99SecondaryParserFactory;
-public class C99ExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser
+public class C99ExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser< IASTExpression >
{
private static ParseTable prs = new C99ExpressionParserprs();
private FixedBacktrackingParser btParser;
@@ -120,22 +120,22 @@ public class C99ExpressionParser extends PrsStream implements RuleAction , IPars
super.reportError((firsttok > lasttok ? ParseErrorCodes.INSERTION_CODE : ParseErrorCodes.SUBSTITUTION_CODE), location, msg);
}
- public Object parser()
+ public void parser()
{
- return parser(null, 0);
+ parser(null, 0);
}
- public Object parser(Monitor monitor)
+ public void parser(Monitor monitor)
{
- return parser(monitor, 0);
+ parser(monitor, 0);
}
- public Object parser(int error_repair_count)
+ public void parser(int error_repair_count)
{
- return parser(null, error_repair_count);
+ parser(null, error_repair_count);
}
- public Object parser(Monitor monitor, int error_repair_count)
+ public void parser(Monitor monitor, int error_repair_count)
{
try
{
@@ -153,7 +153,7 @@ public class C99ExpressionParser extends PrsStream implements RuleAction , IPars
try
{
- return (Object) btParser.parse(error_repair_count);
+ btParser.parse(error_repair_count);
}
catch (BadParseException e)
{
@@ -161,19 +161,19 @@ public class C99ExpressionParser extends PrsStream implements RuleAction , IPars
DiagnoseParser diagnoseParser = new DiagnoseParser(this, prs);
diagnoseParser.diagnose(e.error_token);
}
-
- return null;
}
private C99BuildASTParserAction action;
-private ScopedStack<Object> astStack = new ScopedStack<Object>();
+private IASTCompletionNode compNode;
public C99ExpressionParser() { // constructor
}
-private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
- action = new C99BuildASTParserAction (this, tu, astStack, CNodeFactory.getDefault() , C99SecondaryParserFactory.getDefault() );
+private void initActions(Set<IParser.Options> options) {
+ ScopedStack<Object> astStack = new ScopedStack<Object>();
+
+ action = new C99BuildASTParserAction (this, astStack, CNodeFactory.getDefault() , C99SecondaryParserFactory.getDefault() );
action.setParserOptions(options);
@@ -186,20 +186,21 @@ public void addToken(IToken token) {
}
-public IASTCompletionNode parse(IASTTranslationUnit tu, Set<IParser.Options> options) {
+public IASTExpression parse(Set<IParser.Options> options) {
// this has to be done, or... kaboom!
setStreamLength(getSize());
- initActions(tu, options);
+ initActions(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.getASTCompletionNode();
+ compNode = action.getASTCompletionNode(); // the completion node may be null
+ return ( IASTExpression ) action.getParseResult();
+}
+
- //action = null;
- //parserAction = null;
+public IASTCompletionNode getCompletionNode() {
return compNode;
}
@@ -208,10 +209,6 @@ public List<IToken> getRuleTokens() {
return getTokens().subList(getLeftSpan(), getRightSpan() + 1);
}
-public IASTNode getSecondaryParseResult() {
- return (IASTNode) astStack.pop();
-}
-
public String[] getOrderedTerminalSymbols() {
return C99ExpressionParsersym.orderedTerminalSymbols;
}
@@ -1257,7 +1254,7 @@ public C99ExpressionParser(IParserActionTokenProvider parser) { // constructor
//
// Rule 313: expression_parser_start ::= ERROR_TOKEN
//
- case 313: { action. consumeExpressionProblem(); break;
+ case 313: { action. consumeEmpty(); break;
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99NoCastExpressionParser.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99NoCastExpressionParser.java
index 7ef412cbbd..41b85c4762 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99NoCastExpressionParser.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99NoCastExpressionParser.java
@@ -29,7 +29,7 @@ import org.eclipse.cdt.internal.core.dom.parser.c.CNodeFactory;
import org.eclipse.cdt.core.dom.lrparser.action.c99.C99BuildASTParserAction;
import org.eclipse.cdt.core.dom.lrparser.action.c99.C99SecondaryParserFactory;
-public class C99NoCastExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser
+public class C99NoCastExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser< IASTExpression >
{
private static ParseTable prs = new C99NoCastExpressionParserprs();
private FixedBacktrackingParser btParser;
@@ -120,22 +120,22 @@ public class C99NoCastExpressionParser extends PrsStream implements RuleAction ,
super.reportError((firsttok > lasttok ? ParseErrorCodes.INSERTION_CODE : ParseErrorCodes.SUBSTITUTION_CODE), location, msg);
}
- public Object parser()
+ public void parser()
{
- return parser(null, 0);
+ parser(null, 0);
}
- public Object parser(Monitor monitor)
+ public void parser(Monitor monitor)
{
- return parser(monitor, 0);
+ parser(monitor, 0);
}
- public Object parser(int error_repair_count)
+ public void parser(int error_repair_count)
{
- return parser(null, error_repair_count);
+ parser(null, error_repair_count);
}
- public Object parser(Monitor monitor, int error_repair_count)
+ public void parser(Monitor monitor, int error_repair_count)
{
try
{
@@ -153,7 +153,7 @@ public class C99NoCastExpressionParser extends PrsStream implements RuleAction ,
try
{
- return (Object) btParser.parse(error_repair_count);
+ btParser.parse(error_repair_count);
}
catch (BadParseException e)
{
@@ -161,19 +161,19 @@ public class C99NoCastExpressionParser extends PrsStream implements RuleAction ,
DiagnoseParser diagnoseParser = new DiagnoseParser(this, prs);
diagnoseParser.diagnose(e.error_token);
}
-
- return null;
}
private C99BuildASTParserAction action;
-private ScopedStack<Object> astStack = new ScopedStack<Object>();
+private IASTCompletionNode compNode;
public C99NoCastExpressionParser() { // constructor
}
-private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
- action = new C99BuildASTParserAction (this, tu, astStack, CNodeFactory.getDefault() , C99SecondaryParserFactory.getDefault() );
+private void initActions(Set<IParser.Options> options) {
+ ScopedStack<Object> astStack = new ScopedStack<Object>();
+
+ action = new C99BuildASTParserAction (this, astStack, CNodeFactory.getDefault() , C99SecondaryParserFactory.getDefault() );
action.setParserOptions(options);
@@ -186,20 +186,21 @@ public void addToken(IToken token) {
}
-public IASTCompletionNode parse(IASTTranslationUnit tu, Set<IParser.Options> options) {
+public IASTExpression parse(Set<IParser.Options> options) {
// this has to be done, or... kaboom!
setStreamLength(getSize());
- initActions(tu, options);
+ initActions(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.getASTCompletionNode();
+ compNode = action.getASTCompletionNode(); // the completion node may be null
+ return ( IASTExpression ) action.getParseResult();
+}
+
- //action = null;
- //parserAction = null;
+public IASTCompletionNode getCompletionNode() {
return compNode;
}
@@ -208,10 +209,6 @@ public List<IToken> getRuleTokens() {
return getTokens().subList(getLeftSpan(), getRightSpan() + 1);
}
-public IASTNode getSecondaryParseResult() {
- return (IASTNode) astStack.pop();
-}
-
public String[] getOrderedTerminalSymbols() {
return C99NoCastExpressionParsersym.orderedTerminalSymbols;
}
@@ -1251,7 +1248,7 @@ public C99NoCastExpressionParser(IParserActionTokenProvider parser) { // constr
//
// Rule 312: no_cast_start ::= ERROR_TOKEN
//
- case 312: { action. consumeExpressionProblem(); break;
+ case 312: { action. consumeEmpty(); break;
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99Parser.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99Parser.java
index 7b0005c565..2828af95ef 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99Parser.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99Parser.java
@@ -29,7 +29,7 @@ import org.eclipse.cdt.internal.core.dom.parser.c.CNodeFactory;
import org.eclipse.cdt.core.dom.lrparser.action.c99.C99BuildASTParserAction;
import org.eclipse.cdt.core.dom.lrparser.action.c99.C99SecondaryParserFactory;
-public class C99Parser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser
+public class C99Parser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser< IASTTranslationUnit >
{
private static ParseTable prs = new C99Parserprs();
private FixedBacktrackingParser btParser;
@@ -120,22 +120,22 @@ public class C99Parser extends PrsStream implements RuleAction , IParserActionTo
super.reportError((firsttok > lasttok ? ParseErrorCodes.INSERTION_CODE : ParseErrorCodes.SUBSTITUTION_CODE), location, msg);
}
- public Object parser()
+ public void parser()
{
- return parser(null, 0);
+ parser(null, 0);
}
- public Object parser(Monitor monitor)
+ public void parser(Monitor monitor)
{
- return parser(monitor, 0);
+ parser(monitor, 0);
}
- public Object parser(int error_repair_count)
+ public void parser(int error_repair_count)
{
- return parser(null, error_repair_count);
+ parser(null, error_repair_count);
}
- public Object parser(Monitor monitor, int error_repair_count)
+ public void parser(Monitor monitor, int error_repair_count)
{
try
{
@@ -153,7 +153,7 @@ public class C99Parser extends PrsStream implements RuleAction , IParserActionTo
try
{
- return (Object) btParser.parse(error_repair_count);
+ btParser.parse(error_repair_count);
}
catch (BadParseException e)
{
@@ -161,19 +161,19 @@ public class C99Parser extends PrsStream implements RuleAction , IParserActionTo
DiagnoseParser diagnoseParser = new DiagnoseParser(this, prs);
diagnoseParser.diagnose(e.error_token);
}
-
- return null;
}
private C99BuildASTParserAction action;
-private ScopedStack<Object> astStack = new ScopedStack<Object>();
+private IASTCompletionNode compNode;
public C99Parser() { // constructor
}
-private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
- action = new C99BuildASTParserAction (this, tu, astStack, CNodeFactory.getDefault() , C99SecondaryParserFactory.getDefault() );
+private void initActions(Set<IParser.Options> options) {
+ ScopedStack<Object> astStack = new ScopedStack<Object>();
+
+ action = new C99BuildASTParserAction (this, astStack, CNodeFactory.getDefault() , C99SecondaryParserFactory.getDefault() );
action.setParserOptions(options);
@@ -186,20 +186,21 @@ public void addToken(IToken token) {
}
-public IASTCompletionNode parse(IASTTranslationUnit tu, Set<IParser.Options> options) {
+public IASTTranslationUnit parse(Set<IParser.Options> options) {
// this has to be done, or... kaboom!
setStreamLength(getSize());
- initActions(tu, options);
+ initActions(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.getASTCompletionNode();
+ compNode = action.getASTCompletionNode(); // the completion node may be null
+ return ( IASTTranslationUnit ) action.getParseResult();
+}
+
- //action = null;
- //parserAction = null;
+public IASTCompletionNode getCompletionNode() {
return compNode;
}
@@ -208,10 +209,6 @@ public List<IToken> getRuleTokens() {
return getTokens().subList(getLeftSpan(), getRightSpan() + 1);
}
-public IASTNode getSecondaryParseResult() {
- return (IASTNode) astStack.pop();
-}
-
public String[] getOrderedTerminalSymbols() {
return C99Parsersym.orderedTerminalSymbols;
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99SizeofExpressionParser.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99SizeofExpressionParser.java
index 8aef9cfbad..c103a41018 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99SizeofExpressionParser.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/c99/C99SizeofExpressionParser.java
@@ -29,7 +29,7 @@ import org.eclipse.cdt.internal.core.dom.parser.c.CNodeFactory;
import org.eclipse.cdt.core.dom.lrparser.action.c99.C99BuildASTParserAction;
import org.eclipse.cdt.core.dom.lrparser.action.c99.C99SecondaryParserFactory;
-public class C99SizeofExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser
+public class C99SizeofExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser< IASTExpression >
{
private static ParseTable prs = new C99SizeofExpressionParserprs();
private FixedBacktrackingParser btParser;
@@ -120,22 +120,22 @@ public class C99SizeofExpressionParser extends PrsStream implements RuleAction ,
super.reportError((firsttok > lasttok ? ParseErrorCodes.INSERTION_CODE : ParseErrorCodes.SUBSTITUTION_CODE), location, msg);
}
- public Object parser()
+ public void parser()
{
- return parser(null, 0);
+ parser(null, 0);
}
- public Object parser(Monitor monitor)
+ public void parser(Monitor monitor)
{
- return parser(monitor, 0);
+ parser(monitor, 0);
}
- public Object parser(int error_repair_count)
+ public void parser(int error_repair_count)
{
- return parser(null, error_repair_count);
+ parser(null, error_repair_count);
}
- public Object parser(Monitor monitor, int error_repair_count)
+ public void parser(Monitor monitor, int error_repair_count)
{
try
{
@@ -153,7 +153,7 @@ public class C99SizeofExpressionParser extends PrsStream implements RuleAction ,
try
{
- return (Object) btParser.parse(error_repair_count);
+ btParser.parse(error_repair_count);
}
catch (BadParseException e)
{
@@ -161,19 +161,19 @@ public class C99SizeofExpressionParser extends PrsStream implements RuleAction ,
DiagnoseParser diagnoseParser = new DiagnoseParser(this, prs);
diagnoseParser.diagnose(e.error_token);
}
-
- return null;
}
private C99BuildASTParserAction action;
-private ScopedStack<Object> astStack = new ScopedStack<Object>();
+private IASTCompletionNode compNode;
public C99SizeofExpressionParser() { // constructor
}
-private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
- action = new C99BuildASTParserAction (this, tu, astStack, CNodeFactory.getDefault() , C99SecondaryParserFactory.getDefault() );
+private void initActions(Set<IParser.Options> options) {
+ ScopedStack<Object> astStack = new ScopedStack<Object>();
+
+ action = new C99BuildASTParserAction (this, astStack, CNodeFactory.getDefault() , C99SecondaryParserFactory.getDefault() );
action.setParserOptions(options);
@@ -186,20 +186,21 @@ public void addToken(IToken token) {
}
-public IASTCompletionNode parse(IASTTranslationUnit tu, Set<IParser.Options> options) {
+public IASTExpression parse(Set<IParser.Options> options) {
// this has to be done, or... kaboom!
setStreamLength(getSize());
- initActions(tu, options);
+ initActions(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.getASTCompletionNode();
+ compNode = action.getASTCompletionNode(); // the completion node may be null
+ return ( IASTExpression ) action.getParseResult();
+}
+
- //action = null;
- //parserAction = null;
+public IASTCompletionNode getCompletionNode() {
return compNode;
}
@@ -208,10 +209,6 @@ public List<IToken> getRuleTokens() {
return getTokens().subList(getLeftSpan(), getRightSpan() + 1);
}
-public IASTNode getSecondaryParseResult() {
- return (IASTNode) astStack.pop();
-}
-
public String[] getOrderedTerminalSymbols() {
return C99SizeofExpressionParsersym.orderedTerminalSymbols;
}
@@ -1251,7 +1248,7 @@ public C99SizeofExpressionParser(IParserActionTokenProvider parser) { // constr
//
// Rule 312: no_sizeof_type_id_start ::= ERROR_TOKEN
//
- case 312: { action. consumeExpressionProblem(); break;
+ case 312: { action. consumeEmpty(); break;
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPExpressionParser.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPExpressionParser.java
index 317285d79d..57e3d63332 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPExpressionParser.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPExpressionParser.java
@@ -30,7 +30,7 @@ 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.CPPSecondaryParserFactory;
-public class CPPExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser
+public class CPPExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser< IASTExpression >
{
private static ParseTable prs = new CPPExpressionParserprs();
private FixedBacktrackingParser btParser;
@@ -121,22 +121,22 @@ public class CPPExpressionParser extends PrsStream implements RuleAction , IPars
super.reportError((firsttok > lasttok ? ParseErrorCodes.INSERTION_CODE : ParseErrorCodes.SUBSTITUTION_CODE), location, msg);
}
- public Object parser()
+ public void parser()
{
- return parser(null, 0);
+ parser(null, 0);
}
- public Object parser(Monitor monitor)
+ public void parser(Monitor monitor)
{
- return parser(monitor, 0);
+ parser(monitor, 0);
}
- public Object parser(int error_repair_count)
+ public void parser(int error_repair_count)
{
- return parser(null, error_repair_count);
+ parser(null, error_repair_count);
}
- public Object parser(Monitor monitor, int error_repair_count)
+ public void parser(Monitor monitor, int error_repair_count)
{
try
{
@@ -154,7 +154,7 @@ public class CPPExpressionParser extends PrsStream implements RuleAction , IPars
try
{
- return (Object) btParser.parse(error_repair_count);
+ btParser.parse(error_repair_count);
}
catch (BadParseException e)
{
@@ -162,19 +162,19 @@ public class CPPExpressionParser extends PrsStream implements RuleAction , IPars
DiagnoseParser diagnoseParser = new DiagnoseParser(this, prs);
diagnoseParser.diagnose(e.error_token);
}
-
- return null;
}
private CPPBuildASTParserAction action;
-private ScopedStack<Object> astStack = new ScopedStack<Object>();
+private IASTCompletionNode compNode;
public CPPExpressionParser() { // constructor
}
-private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
- action = new CPPBuildASTParserAction (this, tu, astStack, CPPNodeFactory.getDefault() , CPPSecondaryParserFactory.getDefault() );
+private void initActions(Set<IParser.Options> options) {
+ ScopedStack<Object> astStack = new ScopedStack<Object>();
+
+ action = new CPPBuildASTParserAction (this, astStack, CPPNodeFactory.getDefault() , CPPSecondaryParserFactory.getDefault() );
action.setParserOptions(options);
@@ -187,20 +187,21 @@ public void addToken(IToken token) {
}
-public IASTCompletionNode parse(IASTTranslationUnit tu, Set<IParser.Options> options) {
+public IASTExpression parse(Set<IParser.Options> options) {
// this has to be done, or... kaboom!
setStreamLength(getSize());
- initActions(tu, options);
+ initActions(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.getASTCompletionNode();
+ compNode = action.getASTCompletionNode(); // the completion node may be null
+ return ( IASTExpression ) action.getParseResult();
+}
+
- //action = null;
- //parserAction = null;
+public IASTCompletionNode getCompletionNode() {
return compNode;
}
@@ -209,10 +210,6 @@ public List<IToken> getRuleTokens() {
return getTokens().subList(getLeftSpan(), getRightSpan() + 1);
}
-public IASTNode getSecondaryParseResult() {
- return (IASTNode) astStack.pop();
-}
-
public String[] getOrderedTerminalSymbols() {
return CPPExpressionParsersym.orderedTerminalSymbols;
}
@@ -1972,7 +1969,7 @@ public CPPExpressionParser(IParserActionTokenProvider parser) { // constructor
//
// Rule 536: expression_parser_start ::= ERROR_TOKEN
//
- case 536: { action. consumeExpressionProblem(); break;
+ case 536: { action. consumeEmpty(); break;
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPNoCastExpressionParser.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPNoCastExpressionParser.java
index ce4b0ccfca..f5dd2ddd43 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPNoCastExpressionParser.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPNoCastExpressionParser.java
@@ -30,7 +30,7 @@ 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.CPPSecondaryParserFactory;
-public class CPPNoCastExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser
+public class CPPNoCastExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser< IASTExpression >
{
private static ParseTable prs = new CPPNoCastExpressionParserprs();
private FixedBacktrackingParser btParser;
@@ -121,22 +121,22 @@ public class CPPNoCastExpressionParser extends PrsStream implements RuleAction ,
super.reportError((firsttok > lasttok ? ParseErrorCodes.INSERTION_CODE : ParseErrorCodes.SUBSTITUTION_CODE), location, msg);
}
- public Object parser()
+ public void parser()
{
- return parser(null, 0);
+ parser(null, 0);
}
- public Object parser(Monitor monitor)
+ public void parser(Monitor monitor)
{
- return parser(monitor, 0);
+ parser(monitor, 0);
}
- public Object parser(int error_repair_count)
+ public void parser(int error_repair_count)
{
- return parser(null, error_repair_count);
+ parser(null, error_repair_count);
}
- public Object parser(Monitor monitor, int error_repair_count)
+ public void parser(Monitor monitor, int error_repair_count)
{
try
{
@@ -154,7 +154,7 @@ public class CPPNoCastExpressionParser extends PrsStream implements RuleAction ,
try
{
- return (Object) btParser.parse(error_repair_count);
+ btParser.parse(error_repair_count);
}
catch (BadParseException e)
{
@@ -162,19 +162,19 @@ public class CPPNoCastExpressionParser extends PrsStream implements RuleAction ,
DiagnoseParser diagnoseParser = new DiagnoseParser(this, prs);
diagnoseParser.diagnose(e.error_token);
}
-
- return null;
}
private CPPBuildASTParserAction action;
-private ScopedStack<Object> astStack = new ScopedStack<Object>();
+private IASTCompletionNode compNode;
public CPPNoCastExpressionParser() { // constructor
}
-private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
- action = new CPPBuildASTParserAction (this, tu, astStack, CPPNodeFactory.getDefault() , CPPSecondaryParserFactory.getDefault() );
+private void initActions(Set<IParser.Options> options) {
+ ScopedStack<Object> astStack = new ScopedStack<Object>();
+
+ action = new CPPBuildASTParserAction (this, astStack, CPPNodeFactory.getDefault() , CPPSecondaryParserFactory.getDefault() );
action.setParserOptions(options);
@@ -187,20 +187,21 @@ public void addToken(IToken token) {
}
-public IASTCompletionNode parse(IASTTranslationUnit tu, Set<IParser.Options> options) {
+public IASTExpression parse(Set<IParser.Options> options) {
// this has to be done, or... kaboom!
setStreamLength(getSize());
- initActions(tu, options);
+ initActions(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.getASTCompletionNode();
+ compNode = action.getASTCompletionNode(); // the completion node may be null
+ return ( IASTExpression ) action.getParseResult();
+}
+
- //action = null;
- //parserAction = null;
+public IASTCompletionNode getCompletionNode() {
return compNode;
}
@@ -209,10 +210,6 @@ public List<IToken> getRuleTokens() {
return getTokens().subList(getLeftSpan(), getRightSpan() + 1);
}
-public IASTNode getSecondaryParseResult() {
- return (IASTNode) astStack.pop();
-}
-
public String[] getOrderedTerminalSymbols() {
return CPPNoCastExpressionParsersym.orderedTerminalSymbols;
}
@@ -1966,7 +1963,7 @@ public CPPNoCastExpressionParser(IParserActionTokenProvider parser) { // constr
//
// Rule 535: no_cast_start ::= ERROR_TOKEN
//
- case 535: { action. consumeExpressionProblem(); break;
+ case 535: { action. consumeEmpty(); break;
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPNoFunctionDeclaratorParser.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPNoFunctionDeclaratorParser.java
index e3ae530ddc..56486ceaee 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPNoFunctionDeclaratorParser.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPNoFunctionDeclaratorParser.java
@@ -30,7 +30,7 @@ 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.CPPSecondaryParserFactory;
-public class CPPNoFunctionDeclaratorParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser
+public class CPPNoFunctionDeclaratorParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser< IASTDeclarator >
{
private static ParseTable prs = new CPPNoFunctionDeclaratorParserprs();
private FixedBacktrackingParser btParser;
@@ -121,22 +121,22 @@ public class CPPNoFunctionDeclaratorParser extends PrsStream implements RuleActi
super.reportError((firsttok > lasttok ? ParseErrorCodes.INSERTION_CODE : ParseErrorCodes.SUBSTITUTION_CODE), location, msg);
}
- public Object parser()
+ public void parser()
{
- return parser(null, 0);
+ parser(null, 0);
}
- public Object parser(Monitor monitor)
+ public void parser(Monitor monitor)
{
- return parser(monitor, 0);
+ parser(monitor, 0);
}
- public Object parser(int error_repair_count)
+ public void parser(int error_repair_count)
{
- return parser(null, error_repair_count);
+ parser(null, error_repair_count);
}
- public Object parser(Monitor monitor, int error_repair_count)
+ public void parser(Monitor monitor, int error_repair_count)
{
try
{
@@ -154,7 +154,7 @@ public class CPPNoFunctionDeclaratorParser extends PrsStream implements RuleActi
try
{
- return (Object) btParser.parse(error_repair_count);
+ btParser.parse(error_repair_count);
}
catch (BadParseException e)
{
@@ -162,19 +162,19 @@ public class CPPNoFunctionDeclaratorParser extends PrsStream implements RuleActi
DiagnoseParser diagnoseParser = new DiagnoseParser(this, prs);
diagnoseParser.diagnose(e.error_token);
}
-
- return null;
}
private CPPBuildASTParserAction action;
-private ScopedStack<Object> astStack = new ScopedStack<Object>();
+private IASTCompletionNode compNode;
public CPPNoFunctionDeclaratorParser() { // constructor
}
-private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
- action = new CPPBuildASTParserAction (this, tu, astStack, CPPNodeFactory.getDefault() , CPPSecondaryParserFactory.getDefault() );
+private void initActions(Set<IParser.Options> options) {
+ ScopedStack<Object> astStack = new ScopedStack<Object>();
+
+ action = new CPPBuildASTParserAction (this, astStack, CPPNodeFactory.getDefault() , CPPSecondaryParserFactory.getDefault() );
action.setParserOptions(options);
@@ -187,20 +187,21 @@ public void addToken(IToken token) {
}
-public IASTCompletionNode parse(IASTTranslationUnit tu, Set<IParser.Options> options) {
+public IASTDeclarator parse(Set<IParser.Options> options) {
// this has to be done, or... kaboom!
setStreamLength(getSize());
- initActions(tu, options);
+ initActions(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.getASTCompletionNode();
+ compNode = action.getASTCompletionNode(); // the completion node may be null
+ return ( IASTDeclarator ) action.getParseResult();
+}
+
- //action = null;
- //parserAction = null;
+public IASTCompletionNode getCompletionNode() {
return compNode;
}
@@ -209,10 +210,6 @@ public List<IToken> getRuleTokens() {
return getTokens().subList(getLeftSpan(), getRightSpan() + 1);
}
-public IASTNode getSecondaryParseResult() {
- return (IASTNode) astStack.pop();
-}
-
public String[] getOrderedTerminalSymbols() {
return CPPNoFunctionDeclaratorParsersym.orderedTerminalSymbols;
}
@@ -1966,7 +1963,7 @@ public CPPNoFunctionDeclaratorParser(IParserActionTokenProvider parser) { // co
//
// Rule 534: no_function_declarator_start ::= ERROR_TOKEN
//
- case 534: { action. consumeDeclarationProblem(); break;
+ case 534: { action. consumeEmpty(); break;
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParser.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParser.java
index 37fceff429..de990bb187 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParser.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPParser.java
@@ -30,7 +30,7 @@ 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.CPPSecondaryParserFactory;
-public class CPPParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser
+public class CPPParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser< IASTTranslationUnit >
{
private static ParseTable prs = new CPPParserprs();
private FixedBacktrackingParser btParser;
@@ -121,22 +121,22 @@ public class CPPParser extends PrsStream implements RuleAction , IParserActionTo
super.reportError((firsttok > lasttok ? ParseErrorCodes.INSERTION_CODE : ParseErrorCodes.SUBSTITUTION_CODE), location, msg);
}
- public Object parser()
+ public void parser()
{
- return parser(null, 0);
+ parser(null, 0);
}
- public Object parser(Monitor monitor)
+ public void parser(Monitor monitor)
{
- return parser(monitor, 0);
+ parser(monitor, 0);
}
- public Object parser(int error_repair_count)
+ public void parser(int error_repair_count)
{
- return parser(null, error_repair_count);
+ parser(null, error_repair_count);
}
- public Object parser(Monitor monitor, int error_repair_count)
+ public void parser(Monitor monitor, int error_repair_count)
{
try
{
@@ -154,7 +154,7 @@ public class CPPParser extends PrsStream implements RuleAction , IParserActionTo
try
{
- return (Object) btParser.parse(error_repair_count);
+ btParser.parse(error_repair_count);
}
catch (BadParseException e)
{
@@ -162,19 +162,19 @@ public class CPPParser extends PrsStream implements RuleAction , IParserActionTo
DiagnoseParser diagnoseParser = new DiagnoseParser(this, prs);
diagnoseParser.diagnose(e.error_token);
}
-
- return null;
}
private CPPBuildASTParserAction action;
-private ScopedStack<Object> astStack = new ScopedStack<Object>();
+private IASTCompletionNode compNode;
public CPPParser() { // constructor
}
-private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
- action = new CPPBuildASTParserAction (this, tu, astStack, CPPNodeFactory.getDefault() , CPPSecondaryParserFactory.getDefault() );
+private void initActions(Set<IParser.Options> options) {
+ ScopedStack<Object> astStack = new ScopedStack<Object>();
+
+ action = new CPPBuildASTParserAction (this, astStack, CPPNodeFactory.getDefault() , CPPSecondaryParserFactory.getDefault() );
action.setParserOptions(options);
@@ -187,20 +187,21 @@ public void addToken(IToken token) {
}
-public IASTCompletionNode parse(IASTTranslationUnit tu, Set<IParser.Options> options) {
+public IASTTranslationUnit parse(Set<IParser.Options> options) {
// this has to be done, or... kaboom!
setStreamLength(getSize());
- initActions(tu, options);
+ initActions(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.getASTCompletionNode();
+ compNode = action.getASTCompletionNode(); // the completion node may be null
+ return ( IASTTranslationUnit ) action.getParseResult();
+}
+
- //action = null;
- //parserAction = null;
+public IASTCompletionNode getCompletionNode() {
return compNode;
}
@@ -209,10 +210,6 @@ public List<IToken> getRuleTokens() {
return getTokens().subList(getLeftSpan(), getRightSpan() + 1);
}
-public IASTNode getSecondaryParseResult() {
- return (IASTNode) astStack.pop();
-}
-
public String[] getOrderedTerminalSymbols() {
return CPPParsersym.orderedTerminalSymbols;
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPSizeofExpressionParser.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPSizeofExpressionParser.java
index 4b39af10c1..a9eb31e37b 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPSizeofExpressionParser.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPSizeofExpressionParser.java
@@ -30,7 +30,7 @@ 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.CPPSecondaryParserFactory;
-public class CPPSizeofExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser
+public class CPPSizeofExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser< IASTExpression >
{
private static ParseTable prs = new CPPSizeofExpressionParserprs();
private FixedBacktrackingParser btParser;
@@ -121,22 +121,22 @@ public class CPPSizeofExpressionParser extends PrsStream implements RuleAction ,
super.reportError((firsttok > lasttok ? ParseErrorCodes.INSERTION_CODE : ParseErrorCodes.SUBSTITUTION_CODE), location, msg);
}
- public Object parser()
+ public void parser()
{
- return parser(null, 0);
+ parser(null, 0);
}
- public Object parser(Monitor monitor)
+ public void parser(Monitor monitor)
{
- return parser(monitor, 0);
+ parser(monitor, 0);
}
- public Object parser(int error_repair_count)
+ public void parser(int error_repair_count)
{
- return parser(null, error_repair_count);
+ parser(null, error_repair_count);
}
- public Object parser(Monitor monitor, int error_repair_count)
+ public void parser(Monitor monitor, int error_repair_count)
{
try
{
@@ -154,7 +154,7 @@ public class CPPSizeofExpressionParser extends PrsStream implements RuleAction ,
try
{
- return (Object) btParser.parse(error_repair_count);
+ btParser.parse(error_repair_count);
}
catch (BadParseException e)
{
@@ -162,19 +162,19 @@ public class CPPSizeofExpressionParser extends PrsStream implements RuleAction ,
DiagnoseParser diagnoseParser = new DiagnoseParser(this, prs);
diagnoseParser.diagnose(e.error_token);
}
-
- return null;
}
private CPPBuildASTParserAction action;
-private ScopedStack<Object> astStack = new ScopedStack<Object>();
+private IASTCompletionNode compNode;
public CPPSizeofExpressionParser() { // constructor
}
-private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
- action = new CPPBuildASTParserAction (this, tu, astStack, CPPNodeFactory.getDefault() , CPPSecondaryParserFactory.getDefault() );
+private void initActions(Set<IParser.Options> options) {
+ ScopedStack<Object> astStack = new ScopedStack<Object>();
+
+ action = new CPPBuildASTParserAction (this, astStack, CPPNodeFactory.getDefault() , CPPSecondaryParserFactory.getDefault() );
action.setParserOptions(options);
@@ -187,20 +187,21 @@ public void addToken(IToken token) {
}
-public IASTCompletionNode parse(IASTTranslationUnit tu, Set<IParser.Options> options) {
+public IASTExpression parse(Set<IParser.Options> options) {
// this has to be done, or... kaboom!
setStreamLength(getSize());
- initActions(tu, options);
+ initActions(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.getASTCompletionNode();
+ compNode = action.getASTCompletionNode(); // the completion node may be null
+ return ( IASTExpression ) action.getParseResult();
+}
+
- //action = null;
- //parserAction = null;
+public IASTCompletionNode getCompletionNode() {
return compNode;
}
@@ -209,10 +210,6 @@ public List<IToken> getRuleTokens() {
return getTokens().subList(getLeftSpan(), getRightSpan() + 1);
}
-public IASTNode getSecondaryParseResult() {
- return (IASTNode) astStack.pop();
-}
-
public String[] getOrderedTerminalSymbols() {
return CPPSizeofExpressionParsersym.orderedTerminalSymbols;
}
@@ -1960,7 +1957,7 @@ public CPPSizeofExpressionParser(IParserActionTokenProvider parser) { // constr
//
// Rule 534: no_sizeof_type_id_start ::= ERROR_TOKEN
//
- case 534: { action. consumeExpressionProblem(); break;
+ case 534: { action. consumeEmpty(); break;
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPTemplateTypeParameterParser.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPTemplateTypeParameterParser.java
index d138047ed6..abf6e595f0 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPTemplateTypeParameterParser.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/cpp/CPPTemplateTypeParameterParser.java
@@ -30,7 +30,9 @@ 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.CPPSecondaryParserFactory;
-public class CPPTemplateTypeParameterParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
+
+public class CPPTemplateTypeParameterParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser< ICPPASTTemplateParameter >
{
private static ParseTable prs = new CPPTemplateTypeParameterParserprs();
private FixedBacktrackingParser btParser;
@@ -121,22 +123,22 @@ public class CPPTemplateTypeParameterParser extends PrsStream implements RuleAct
super.reportError((firsttok > lasttok ? ParseErrorCodes.INSERTION_CODE : ParseErrorCodes.SUBSTITUTION_CODE), location, msg);
}
- public Object parser()
+ public void parser()
{
- return parser(null, 0);
+ parser(null, 0);
}
- public Object parser(Monitor monitor)
+ public void parser(Monitor monitor)
{
- return parser(monitor, 0);
+ parser(monitor, 0);
}
- public Object parser(int error_repair_count)
+ public void parser(int error_repair_count)
{
- return parser(null, error_repair_count);
+ parser(null, error_repair_count);
}
- public Object parser(Monitor monitor, int error_repair_count)
+ public void parser(Monitor monitor, int error_repair_count)
{
try
{
@@ -154,7 +156,7 @@ public class CPPTemplateTypeParameterParser extends PrsStream implements RuleAct
try
{
- return (Object) btParser.parse(error_repair_count);
+ btParser.parse(error_repair_count);
}
catch (BadParseException e)
{
@@ -162,19 +164,19 @@ public class CPPTemplateTypeParameterParser extends PrsStream implements RuleAct
DiagnoseParser diagnoseParser = new DiagnoseParser(this, prs);
diagnoseParser.diagnose(e.error_token);
}
-
- return null;
}
private CPPBuildASTParserAction action;
-private ScopedStack<Object> astStack = new ScopedStack<Object>();
+private IASTCompletionNode compNode;
public CPPTemplateTypeParameterParser() { // constructor
}
-private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
- action = new CPPBuildASTParserAction (this, tu, astStack, CPPNodeFactory.getDefault() , CPPSecondaryParserFactory.getDefault() );
+private void initActions(Set<IParser.Options> options) {
+ ScopedStack<Object> astStack = new ScopedStack<Object>();
+
+ action = new CPPBuildASTParserAction (this, astStack, CPPNodeFactory.getDefault() , CPPSecondaryParserFactory.getDefault() );
action.setParserOptions(options);
@@ -187,20 +189,21 @@ public void addToken(IToken token) {
}
-public IASTCompletionNode parse(IASTTranslationUnit tu, Set<IParser.Options> options) {
+public ICPPASTTemplateParameter parse(Set<IParser.Options> options) {
// this has to be done, or... kaboom!
setStreamLength(getSize());
- initActions(tu, options);
+ initActions(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.getASTCompletionNode();
+ compNode = action.getASTCompletionNode(); // the completion node may be null
+ return ( ICPPASTTemplateParameter ) action.getParseResult();
+}
- //action = null;
- //parserAction = null;
+
+public IASTCompletionNode getCompletionNode() {
return compNode;
}
@@ -209,10 +212,6 @@ public List<IToken> getRuleTokens() {
return getTokens().subList(getLeftSpan(), getRightSpan() + 1);
}
-public IASTNode getSecondaryParseResult() {
- return (IASTNode) astStack.pop();
-}
-
public String[] getOrderedTerminalSymbols() {
return CPPTemplateTypeParameterParsersym.orderedTerminalSymbols;
}
@@ -1972,7 +1971,7 @@ public CPPTemplateTypeParameterParser(IParserActionTokenProvider parser) { // c
//
// Rule 536: type_parameter_start ::= ERROR_TOKEN
//
- case 536: { action. consumeDeclarationProblem(); break;
+ case 536: { action. consumeEmpty(); break;
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/gcc/GCCParser.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/gcc/GCCParser.java
index f02dc0d1dc..1608352608 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/gcc/GCCParser.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/gcc/GCCParser.java
@@ -32,7 +32,7 @@ import org.eclipse.cdt.core.dom.lrparser.action.c99.C99SecondaryParserFactory;
import org.eclipse.cdt.core.dom.lrparser.action.gnu.GCCBuildASTParserAction;
import org.eclipse.cdt.core.dom.lrparser.action.gnu.GCCSecondaryParserFactory;
-public class GCCParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser
+public class GCCParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser< IASTTranslationUnit >
{
private static ParseTable prs = new GCCParserprs();
private FixedBacktrackingParser btParser;
@@ -123,22 +123,22 @@ public class GCCParser extends PrsStream implements RuleAction , IParserActionTo
super.reportError((firsttok > lasttok ? ParseErrorCodes.INSERTION_CODE : ParseErrorCodes.SUBSTITUTION_CODE), location, msg);
}
- public Object parser()
+ public void parser()
{
- return parser(null, 0);
+ parser(null, 0);
}
- public Object parser(Monitor monitor)
+ public void parser(Monitor monitor)
{
- return parser(monitor, 0);
+ parser(monitor, 0);
}
- public Object parser(int error_repair_count)
+ public void parser(int error_repair_count)
{
- return parser(null, error_repair_count);
+ parser(null, error_repair_count);
}
- public Object parser(Monitor monitor, int error_repair_count)
+ public void parser(Monitor monitor, int error_repair_count)
{
try
{
@@ -156,7 +156,7 @@ public class GCCParser extends PrsStream implements RuleAction , IParserActionTo
try
{
- return (Object) btParser.parse(error_repair_count);
+ btParser.parse(error_repair_count);
}
catch (BadParseException e)
{
@@ -164,24 +164,24 @@ public class GCCParser extends PrsStream implements RuleAction , IParserActionTo
DiagnoseParser diagnoseParser = new DiagnoseParser(this, prs);
diagnoseParser.diagnose(e.error_token);
}
-
- return null;
}
private C99BuildASTParserAction action;
-private ScopedStack<Object> astStack = new ScopedStack<Object>();
+private IASTCompletionNode compNode;
public GCCParser() { // constructor
}
-private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
- action = new C99BuildASTParserAction (this, tu, astStack, CNodeFactory.getDefault() , GCCSecondaryParserFactory.getDefault() );
+private void initActions(Set<IParser.Options> options) {
+ ScopedStack<Object> astStack = new ScopedStack<Object>();
+
+ action = new C99BuildASTParserAction (this, astStack, CNodeFactory.getDefault() , GCCSecondaryParserFactory.getDefault() );
action.setParserOptions(options);
- gnuAction = new GCCBuildASTParserAction (this, tu, astStack, CNodeFactory.getDefault() );
+ gnuAction = new GCCBuildASTParserAction (this, astStack, CNodeFactory.getDefault() );
gnuAction.setParserOptions(options);
gnuAction.setBaseAction(action);
@@ -194,20 +194,21 @@ public void addToken(IToken token) {
}
-public IASTCompletionNode parse(IASTTranslationUnit tu, Set<IParser.Options> options) {
+public IASTTranslationUnit parse(Set<IParser.Options> options) {
// this has to be done, or... kaboom!
setStreamLength(getSize());
- initActions(tu, options);
+ initActions(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.getASTCompletionNode();
+ compNode = action.getASTCompletionNode(); // the completion node may be null
+ return ( IASTTranslationUnit ) action.getParseResult();
+}
+
- //action = null;
- //parserAction = null;
+public IASTCompletionNode getCompletionNode() {
return compNode;
}
@@ -216,10 +217,6 @@ public List<IToken> getRuleTokens() {
return getTokens().subList(getLeftSpan(), getRightSpan() + 1);
}
-public IASTNode getSecondaryParseResult() {
- return (IASTNode) astStack.pop();
-}
-
public String[] getOrderedTerminalSymbols() {
return GCCParsersym.orderedTerminalSymbols;
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/gcc/GCCSizeofExpressionParser.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/gcc/GCCSizeofExpressionParser.java
index 9572159c28..31684826f4 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/gcc/GCCSizeofExpressionParser.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/gcc/GCCSizeofExpressionParser.java
@@ -32,7 +32,7 @@ import org.eclipse.cdt.core.dom.lrparser.action.c99.C99SecondaryParserFactory;
import org.eclipse.cdt.core.dom.lrparser.action.gnu.GCCBuildASTParserAction;
import org.eclipse.cdt.core.dom.lrparser.action.gnu.GCCSecondaryParserFactory;
-public class GCCSizeofExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser
+public class GCCSizeofExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser< IASTExpression >
{
private static ParseTable prs = new GCCSizeofExpressionParserprs();
private FixedBacktrackingParser btParser;
@@ -123,22 +123,22 @@ public class GCCSizeofExpressionParser extends PrsStream implements RuleAction ,
super.reportError((firsttok > lasttok ? ParseErrorCodes.INSERTION_CODE : ParseErrorCodes.SUBSTITUTION_CODE), location, msg);
}
- public Object parser()
+ public void parser()
{
- return parser(null, 0);
+ parser(null, 0);
}
- public Object parser(Monitor monitor)
+ public void parser(Monitor monitor)
{
- return parser(monitor, 0);
+ parser(monitor, 0);
}
- public Object parser(int error_repair_count)
+ public void parser(int error_repair_count)
{
- return parser(null, error_repair_count);
+ parser(null, error_repair_count);
}
- public Object parser(Monitor monitor, int error_repair_count)
+ public void parser(Monitor monitor, int error_repair_count)
{
try
{
@@ -156,7 +156,7 @@ public class GCCSizeofExpressionParser extends PrsStream implements RuleAction ,
try
{
- return (Object) btParser.parse(error_repair_count);
+ btParser.parse(error_repair_count);
}
catch (BadParseException e)
{
@@ -164,24 +164,24 @@ public class GCCSizeofExpressionParser extends PrsStream implements RuleAction ,
DiagnoseParser diagnoseParser = new DiagnoseParser(this, prs);
diagnoseParser.diagnose(e.error_token);
}
-
- return null;
}
private C99BuildASTParserAction action;
-private ScopedStack<Object> astStack = new ScopedStack<Object>();
+private IASTCompletionNode compNode;
public GCCSizeofExpressionParser() { // constructor
}
-private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
- action = new C99BuildASTParserAction (this, tu, astStack, CNodeFactory.getDefault() , GCCSecondaryParserFactory.getDefault() );
+private void initActions(Set<IParser.Options> options) {
+ ScopedStack<Object> astStack = new ScopedStack<Object>();
+
+ action = new C99BuildASTParserAction (this, astStack, CNodeFactory.getDefault() , GCCSecondaryParserFactory.getDefault() );
action.setParserOptions(options);
- gnuAction = new GCCBuildASTParserAction (this, tu, astStack, CNodeFactory.getDefault() );
+ gnuAction = new GCCBuildASTParserAction (this, astStack, CNodeFactory.getDefault() );
gnuAction.setParserOptions(options);
gnuAction.setBaseAction(action);
@@ -194,20 +194,21 @@ public void addToken(IToken token) {
}
-public IASTCompletionNode parse(IASTTranslationUnit tu, Set<IParser.Options> options) {
+public IASTExpression parse(Set<IParser.Options> options) {
// this has to be done, or... kaboom!
setStreamLength(getSize());
- initActions(tu, options);
+ initActions(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.getASTCompletionNode();
+ compNode = action.getASTCompletionNode(); // the completion node may be null
+ return ( IASTExpression ) action.getParseResult();
+}
+
- //action = null;
- //parserAction = null;
+public IASTCompletionNode getCompletionNode() {
return compNode;
}
@@ -216,10 +217,6 @@ public List<IToken> getRuleTokens() {
return getTokens().subList(getLeftSpan(), getRightSpan() + 1);
}
-public IASTNode getSecondaryParseResult() {
- return (IASTNode) astStack.pop();
-}
-
public String[] getOrderedTerminalSymbols() {
return GCCSizeofExpressionParsersym.orderedTerminalSymbols;
}
@@ -1321,7 +1318,7 @@ private GCCBuildASTParserAction gnuAction;
//
// Rule 376: no_sizeof_type_name_start ::= ERROR_TOKEN
//
- case 376: { action. consumeExpressionProblem(); break;
+ case 376: { action. consumeEmpty(); break;
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/gpp/GPPParser.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/gpp/GPPParser.java
index 75fbd7f839..ced9742b32 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/gpp/GPPParser.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/gpp/GPPParser.java
@@ -33,7 +33,7 @@ import org.eclipse.cdt.core.dom.lrparser.action.cpp.CPPSecondaryParserFactory;
import org.eclipse.cdt.core.dom.lrparser.action.gnu.GPPBuildASTParserAction;
import org.eclipse.cdt.core.dom.lrparser.action.gnu.GPPSecondaryParserFactory;
-public class GPPParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser
+public class GPPParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser< IASTTranslationUnit >
{
private static ParseTable prs = new GPPParserprs();
private FixedBacktrackingParser btParser;
@@ -124,22 +124,22 @@ public class GPPParser extends PrsStream implements RuleAction , IParserActionTo
super.reportError((firsttok > lasttok ? ParseErrorCodes.INSERTION_CODE : ParseErrorCodes.SUBSTITUTION_CODE), location, msg);
}
- public Object parser()
+ public void parser()
{
- return parser(null, 0);
+ parser(null, 0);
}
- public Object parser(Monitor monitor)
+ public void parser(Monitor monitor)
{
- return parser(monitor, 0);
+ parser(monitor, 0);
}
- public Object parser(int error_repair_count)
+ public void parser(int error_repair_count)
{
- return parser(null, error_repair_count);
+ parser(null, error_repair_count);
}
- public Object parser(Monitor monitor, int error_repair_count)
+ public void parser(Monitor monitor, int error_repair_count)
{
try
{
@@ -157,7 +157,7 @@ public class GPPParser extends PrsStream implements RuleAction , IParserActionTo
try
{
- return (Object) btParser.parse(error_repair_count);
+ btParser.parse(error_repair_count);
}
catch (BadParseException e)
{
@@ -165,24 +165,24 @@ public class GPPParser extends PrsStream implements RuleAction , IParserActionTo
DiagnoseParser diagnoseParser = new DiagnoseParser(this, prs);
diagnoseParser.diagnose(e.error_token);
}
-
- return null;
}
private CPPBuildASTParserAction action;
-private ScopedStack<Object> astStack = new ScopedStack<Object>();
+private IASTCompletionNode compNode;
public GPPParser() { // constructor
}
-private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
- action = new CPPBuildASTParserAction (this, tu, astStack, CPPNodeFactory.getDefault() , GPPSecondaryParserFactory.getDefault() );
+private void initActions(Set<IParser.Options> options) {
+ ScopedStack<Object> astStack = new ScopedStack<Object>();
+
+ action = new CPPBuildASTParserAction (this, astStack, CPPNodeFactory.getDefault() , GPPSecondaryParserFactory.getDefault() );
action.setParserOptions(options);
- gnuAction = new GPPBuildASTParserAction (this, tu, astStack, CPPNodeFactory.getDefault() );
+ gnuAction = new GPPBuildASTParserAction (this, astStack, CPPNodeFactory.getDefault() );
gnuAction.setParserOptions(options);
gnuAction.setBaseAction(action);
@@ -195,20 +195,21 @@ public void addToken(IToken token) {
}
-public IASTCompletionNode parse(IASTTranslationUnit tu, Set<IParser.Options> options) {
+public IASTTranslationUnit parse(Set<IParser.Options> options) {
// this has to be done, or... kaboom!
setStreamLength(getSize());
- initActions(tu, options);
+ initActions(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.getASTCompletionNode();
+ compNode = action.getASTCompletionNode(); // the completion node may be null
+ return ( IASTTranslationUnit ) action.getParseResult();
+}
+
- //action = null;
- //parserAction = null;
+public IASTCompletionNode getCompletionNode() {
return compNode;
}
@@ -217,10 +218,6 @@ public List<IToken> getRuleTokens() {
return getTokens().subList(getLeftSpan(), getRightSpan() + 1);
}
-public IASTNode getSecondaryParseResult() {
- return (IASTNode) astStack.pop();
-}
-
public String[] getOrderedTerminalSymbols() {
return GPPParsersym.orderedTerminalSymbols;
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/gpp/GPPSizeofExpressionParser.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/gpp/GPPSizeofExpressionParser.java
index 05cc17c49b..890dd8f9ec 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/gpp/GPPSizeofExpressionParser.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/internal/core/dom/lrparser/gpp/GPPSizeofExpressionParser.java
@@ -33,7 +33,7 @@ import org.eclipse.cdt.core.dom.lrparser.action.cpp.CPPSecondaryParserFactory;
import org.eclipse.cdt.core.dom.lrparser.action.gnu.GPPBuildASTParserAction;
import org.eclipse.cdt.core.dom.lrparser.action.gnu.GPPSecondaryParserFactory;
-public class GPPSizeofExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser
+public class GPPSizeofExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser< IASTExpression >
{
private static ParseTable prs = new GPPSizeofExpressionParserprs();
private FixedBacktrackingParser btParser;
@@ -124,22 +124,22 @@ public class GPPSizeofExpressionParser extends PrsStream implements RuleAction ,
super.reportError((firsttok > lasttok ? ParseErrorCodes.INSERTION_CODE : ParseErrorCodes.SUBSTITUTION_CODE), location, msg);
}
- public Object parser()
+ public void parser()
{
- return parser(null, 0);
+ parser(null, 0);
}
- public Object parser(Monitor monitor)
+ public void parser(Monitor monitor)
{
- return parser(monitor, 0);
+ parser(monitor, 0);
}
- public Object parser(int error_repair_count)
+ public void parser(int error_repair_count)
{
- return parser(null, error_repair_count);
+ parser(null, error_repair_count);
}
- public Object parser(Monitor monitor, int error_repair_count)
+ public void parser(Monitor monitor, int error_repair_count)
{
try
{
@@ -157,7 +157,7 @@ public class GPPSizeofExpressionParser extends PrsStream implements RuleAction ,
try
{
- return (Object) btParser.parse(error_repair_count);
+ btParser.parse(error_repair_count);
}
catch (BadParseException e)
{
@@ -165,24 +165,24 @@ public class GPPSizeofExpressionParser extends PrsStream implements RuleAction ,
DiagnoseParser diagnoseParser = new DiagnoseParser(this, prs);
diagnoseParser.diagnose(e.error_token);
}
-
- return null;
}
private CPPBuildASTParserAction action;
-private ScopedStack<Object> astStack = new ScopedStack<Object>();
+private IASTCompletionNode compNode;
public GPPSizeofExpressionParser() { // constructor
}
-private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
- action = new CPPBuildASTParserAction (this, tu, astStack, CPPNodeFactory.getDefault() , GPPSecondaryParserFactory.getDefault() );
+private void initActions(Set<IParser.Options> options) {
+ ScopedStack<Object> astStack = new ScopedStack<Object>();
+
+ action = new CPPBuildASTParserAction (this, astStack, CPPNodeFactory.getDefault() , GPPSecondaryParserFactory.getDefault() );
action.setParserOptions(options);
- gnuAction = new GPPBuildASTParserAction (this, tu, astStack, CPPNodeFactory.getDefault() );
+ gnuAction = new GPPBuildASTParserAction (this, astStack, CPPNodeFactory.getDefault() );
gnuAction.setParserOptions(options);
gnuAction.setBaseAction(action);
@@ -195,20 +195,21 @@ public void addToken(IToken token) {
}
-public IASTCompletionNode parse(IASTTranslationUnit tu, Set<IParser.Options> options) {
+public IASTExpression parse(Set<IParser.Options> options) {
// this has to be done, or... kaboom!
setStreamLength(getSize());
- initActions(tu, options);
+ initActions(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.getASTCompletionNode();
+ compNode = action.getASTCompletionNode(); // the completion node may be null
+ return ( IASTExpression ) action.getParseResult();
+}
+
- //action = null;
- //parserAction = null;
+public IASTCompletionNode getCompletionNode() {
return compNode;
}
@@ -217,10 +218,6 @@ public List<IToken> getRuleTokens() {
return getTokens().subList(getLeftSpan(), getRightSpan() + 1);
}
-public IASTNode getSecondaryParseResult() {
- return (IASTNode) astStack.pop();
-}
-
public String[] getOrderedTerminalSymbols() {
return GPPSizeofExpressionParsersym.orderedTerminalSymbols;
}
@@ -2024,7 +2021,7 @@ private GPPBuildASTParserAction gnuAction;
//
// Rule 595: no_sizeof_type_id_start ::= ERROR_TOKEN
//
- case 595: { action. consumeExpressionProblem(); break;
+ case 595: { action. consumeEmpty(); break;
}

Back to the top