Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'lrparser/org.eclipse.cdt.core.lrparser/grammar')
-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
16 files changed, 94 insertions, 36 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;
}

Back to the top