mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-25 18:05:33 +02:00
improved several interfaces in LR parser
This commit is contained in:
parent
bd7f096c7c
commit
75756374e3
58 changed files with 686 additions and 725 deletions
|
@ -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
|
|
@ -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
|
|
@ -20,6 +20,10 @@ $Import
|
|||
C99Grammar.g
|
||||
$End
|
||||
|
||||
$Define
|
||||
$ast_class /. IASTTranslationUnit ./
|
||||
$End
|
||||
|
||||
$Start
|
||||
translation_unit
|
||||
$End
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -21,6 +21,10 @@ $Import
|
|||
CPPGrammar.g
|
||||
$End
|
||||
|
||||
$Define
|
||||
$ast_class /. IASTTranslationUnit ./
|
||||
$End
|
||||
|
||||
$Start
|
||||
translation_unit
|
||||
$End
|
|
@ -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
|
|
@ -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
|
|
@ -21,6 +21,10 @@ $Import
|
|||
GCCGrammar.g
|
||||
$End
|
||||
|
||||
$Define
|
||||
$ast_class /. IASTTranslationUnit ./
|
||||
$End
|
||||
|
||||
$Start
|
||||
translation_unit
|
||||
$End
|
|
@ -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
|
|
@ -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);
|
||||
./
|
||||
|
|
|
@ -21,6 +21,10 @@ $Import
|
|||
GPPGrammar.g
|
||||
$End
|
||||
|
||||
$Define
|
||||
$ast_class /. IASTTranslationUnit ./
|
||||
$End
|
||||
|
||||
$Start
|
||||
translation_unit
|
||||
$End
|
|
@ -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
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
||||
/**
|
||||
|
@ -75,19 +73,6 @@ public abstract class BaseExtensibleLanguage extends AbstractLanguage {
|
|||
protected abstract IDOMTokenMap getTokenMap();
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -11,13 +11,15 @@
|
|||
package org.eclipse.cdt.core.dom.parser.upc;
|
||||
|
||||
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.upc.UPCParsersym.*;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.upc.UPCParsersym.TK_Completion;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.upc.UPCParsersym.TK_relaxed;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.upc.UPCParsersym.TK_shared;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.upc.UPCParsersym.TK_strict;
|
||||
import lpg.lpgjavaruntime.IToken;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier;
|
||||
|
@ -46,8 +48,8 @@ public class UPCParserAction extends C99BuildASTParserAction {
|
|||
* @param parser
|
||||
* @param tu
|
||||
*/
|
||||
public UPCParserAction(IParserActionTokenProvider parser, IASTTranslationUnit tu, ScopedStack<Object> astStack, IUPCNodeFactory nodeFactory, ISecondaryParserFactory parserFactory) {
|
||||
super(parser, tu, astStack, nodeFactory, parserFactory);
|
||||
public UPCParserAction(IParserActionTokenProvider parser, ScopedStack<Object> astStack, IUPCNodeFactory nodeFactory, ISecondaryParserFactory parserFactory) {
|
||||
super(parser, astStack, nodeFactory, parserFactory);
|
||||
this.nodeFactory = nodeFactory;
|
||||
nodeFactory.setUseC99SizeofExpressions();
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
package org.eclipse.cdt.core.dom.parser.upc;
|
||||
|
||||
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 UPCSecondaryParserFactory implements ISecondaryParserFactory{
|
|||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
public IParser getExpressionParser(IParserActionTokenProvider parser) {
|
||||
public IParser<IASTExpression> getExpressionParser(IParserActionTokenProvider parser) {
|
||||
return new UPCExpressionParser(parser);
|
||||
}
|
||||
|
||||
public IParser getNoCastExpressionParser(IParserActionTokenProvider parser) {
|
||||
public IParser<IASTExpression> getNoCastExpressionParser(IParserActionTokenProvider parser) {
|
||||
return new UPCNoCastExpressionParser(parser);
|
||||
}
|
||||
|
||||
public IParser getSizeofExpressionParser(IParserActionTokenProvider parser) {
|
||||
public IParser<IASTExpression> getSizeofExpressionParser(IParserActionTokenProvider parser) {
|
||||
return new UPCSizeofExpressionParser(parser);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ public class UPCLanguage extends BaseExtensibleLanguage {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IParser getParser() {
|
||||
public IParser<IASTTranslationUnit> getParser() {
|
||||
return new UPCParser();
|
||||
}
|
||||
|
||||
|
@ -85,14 +85,6 @@ public class UPCLanguage extends BaseExtensibleLanguage {
|
|||
return ParserLanguage.C;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the translation unit object and sets the index and the location resolver.
|
||||
*/
|
||||
@Override
|
||||
protected IASTTranslationUnit createASTTranslationUnit() {
|
||||
return CNodeFactory.getDefault().newTranslationUnit();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IScannerExtensionConfiguration getScannerExtensionConfiguration() {
|
||||
return ScannerExtensionConfiguration.createC();
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.eclipse.cdt.core.dom.upc.ast.IUPCASTSynchronizationStatement;
|
|||
import org.eclipse.cdt.core.dom.upc.ast.IUPCASTUnarySizeofExpression;
|
||||
import org.eclipse.cdt.core.dom.lrparser.lpgextensions.FixedBacktrackingParser;
|
||||
|
||||
public class UPCExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser
|
||||
public class UPCExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser< IASTExpression >
|
||||
{
|
||||
private static ParseTable prs = new UPCExpressionParserprs();
|
||||
private FixedBacktrackingParser btParser;
|
||||
|
@ -128,22 +128,22 @@ public class UPCExpressionParser 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
|
||||
{
|
||||
|
@ -161,7 +161,7 @@ public class UPCExpressionParser extends PrsStream implements RuleAction , IPars
|
|||
|
||||
try
|
||||
{
|
||||
return (Object) btParser.parse(error_repair_count);
|
||||
btParser.parse(error_repair_count);
|
||||
}
|
||||
catch (BadParseException e)
|
||||
{
|
||||
|
@ -169,19 +169,19 @@ public class UPCExpressionParser extends PrsStream implements RuleAction , IPars
|
|||
DiagnoseParser diagnoseParser = new DiagnoseParser(this, prs);
|
||||
diagnoseParser.diagnose(e.error_token);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private UPCParserAction action;
|
||||
private ScopedStack<Object> astStack = new ScopedStack<Object>();
|
||||
private IASTCompletionNode compNode;
|
||||
|
||||
public UPCExpressionParser() { // constructor
|
||||
}
|
||||
|
||||
private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
|
||||
action = new UPCParserAction (this, tu, astStack, new UPCASTNodeFactory() , UPCSecondaryParserFactory.getDefault() );
|
||||
private void initActions(Set<IParser.Options> options) {
|
||||
ScopedStack<Object> astStack = new ScopedStack<Object>();
|
||||
|
||||
action = new UPCParserAction (this, astStack, new UPCASTNodeFactory() , UPCSecondaryParserFactory.getDefault() );
|
||||
action.setParserOptions(options);
|
||||
|
||||
|
||||
|
@ -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 UPCExpressionParsersym.orderedTerminalSymbols;
|
||||
}
|
||||
|
@ -788,6 +785,12 @@ public UPCExpressionParser(IParserActionTokenProvider parser) { // constructor
|
|||
case 165: { action. consumeToken(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 178: type_name_specifier ::= identifier_token
|
||||
//
|
||||
case 178: { action. consumeToken(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 179: struct_or_union_specifier ::= struct_or_union struct_or_union_specifier_hook { <openscope-ast> struct_declaration_list_opt }
|
||||
//
|
||||
|
@ -1259,7 +1262,7 @@ public UPCExpressionParser(IParserActionTokenProvider parser) { // constructor
|
|||
//
|
||||
// Rule 313: expression_parser_start ::= ERROR_TOKEN
|
||||
//
|
||||
case 313: { action. consumeExpressionProblem(); break;
|
||||
case 313: { action. consumeEmpty(); break;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.eclipse.cdt.core.dom.upc.ast.IUPCASTSynchronizationStatement;
|
|||
import org.eclipse.cdt.core.dom.upc.ast.IUPCASTUnarySizeofExpression;
|
||||
import org.eclipse.cdt.core.dom.lrparser.lpgextensions.FixedBacktrackingParser;
|
||||
|
||||
public class UPCNoCastExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser
|
||||
public class UPCNoCastExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser< IASTExpression >
|
||||
{
|
||||
private static ParseTable prs = new UPCNoCastExpressionParserprs();
|
||||
private FixedBacktrackingParser btParser;
|
||||
|
@ -128,22 +128,22 @@ public class UPCNoCastExpressionParser 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
|
||||
{
|
||||
|
@ -161,7 +161,7 @@ public class UPCNoCastExpressionParser extends PrsStream implements RuleAction ,
|
|||
|
||||
try
|
||||
{
|
||||
return (Object) btParser.parse(error_repair_count);
|
||||
btParser.parse(error_repair_count);
|
||||
}
|
||||
catch (BadParseException e)
|
||||
{
|
||||
|
@ -169,19 +169,19 @@ public class UPCNoCastExpressionParser extends PrsStream implements RuleAction ,
|
|||
DiagnoseParser diagnoseParser = new DiagnoseParser(this, prs);
|
||||
diagnoseParser.diagnose(e.error_token);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private UPCParserAction action;
|
||||
private ScopedStack<Object> astStack = new ScopedStack<Object>();
|
||||
private IASTCompletionNode compNode;
|
||||
|
||||
public UPCNoCastExpressionParser() { // constructor
|
||||
}
|
||||
|
||||
private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
|
||||
action = new UPCParserAction (this, tu, astStack, new UPCASTNodeFactory() , UPCSecondaryParserFactory.getDefault() );
|
||||
private void initActions(Set<IParser.Options> options) {
|
||||
ScopedStack<Object> astStack = new ScopedStack<Object>();
|
||||
|
||||
action = new UPCParserAction (this, astStack, new UPCASTNodeFactory() , UPCSecondaryParserFactory.getDefault() );
|
||||
action.setParserOptions(options);
|
||||
|
||||
|
||||
|
@ -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 UPCNoCastExpressionParsersym.orderedTerminalSymbols;
|
||||
}
|
||||
|
@ -782,6 +779,12 @@ public UPCNoCastExpressionParser(IParserActionTokenProvider parser) { // constr
|
|||
case 164: { action. consumeToken(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 177: type_name_specifier ::= identifier_token
|
||||
//
|
||||
case 177: { action. consumeToken(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 178: struct_or_union_specifier ::= struct_or_union struct_or_union_specifier_hook { <openscope-ast> struct_declaration_list_opt }
|
||||
//
|
||||
|
@ -1253,7 +1256,7 @@ public UPCNoCastExpressionParser(IParserActionTokenProvider parser) { // constr
|
|||
//
|
||||
// Rule 312: no_cast_start ::= ERROR_TOKEN
|
||||
//
|
||||
case 312: { action. consumeExpressionProblem(); break;
|
||||
case 312: { action. consumeEmpty(); break;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.eclipse.cdt.core.dom.upc.ast.IUPCASTSynchronizationStatement;
|
|||
import org.eclipse.cdt.core.dom.upc.ast.IUPCASTUnarySizeofExpression;
|
||||
import org.eclipse.cdt.core.dom.lrparser.lpgextensions.FixedBacktrackingParser;
|
||||
|
||||
public class UPCParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser
|
||||
public class UPCParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser< IASTTranslationUnit >
|
||||
{
|
||||
private static ParseTable prs = new UPCParserprs();
|
||||
private FixedBacktrackingParser btParser;
|
||||
|
@ -128,22 +128,22 @@ public class UPCParser 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
|
||||
{
|
||||
|
@ -161,7 +161,7 @@ public class UPCParser extends PrsStream implements RuleAction , IParserActionTo
|
|||
|
||||
try
|
||||
{
|
||||
return (Object) btParser.parse(error_repair_count);
|
||||
btParser.parse(error_repair_count);
|
||||
}
|
||||
catch (BadParseException e)
|
||||
{
|
||||
|
@ -169,19 +169,19 @@ public class UPCParser extends PrsStream implements RuleAction , IParserActionTo
|
|||
DiagnoseParser diagnoseParser = new DiagnoseParser(this, prs);
|
||||
diagnoseParser.diagnose(e.error_token);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private UPCParserAction action;
|
||||
private ScopedStack<Object> astStack = new ScopedStack<Object>();
|
||||
private IASTCompletionNode compNode;
|
||||
|
||||
public UPCParser() { // constructor
|
||||
}
|
||||
|
||||
private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
|
||||
action = new UPCParserAction (this, tu, astStack, new UPCASTNodeFactory() , UPCSecondaryParserFactory.getDefault() );
|
||||
private void initActions(Set<IParser.Options> options) {
|
||||
ScopedStack<Object> astStack = new ScopedStack<Object>();
|
||||
|
||||
action = new UPCParserAction (this, astStack, new UPCASTNodeFactory() , UPCSecondaryParserFactory.getDefault() );
|
||||
action.setParserOptions(options);
|
||||
|
||||
|
||||
|
@ -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 UPCParsersym.orderedTerminalSymbols;
|
||||
}
|
||||
|
@ -788,6 +785,12 @@ public UPCParser(IParserActionTokenProvider parser) { // constructor
|
|||
case 165: { action. consumeToken(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 178: type_name_specifier ::= identifier_token
|
||||
//
|
||||
case 178: { action. consumeToken(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 179: struct_or_union_specifier ::= struct_or_union struct_or_union_specifier_hook { <openscope-ast> struct_declaration_list_opt }
|
||||
//
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.eclipse.cdt.core.dom.upc.ast.IUPCASTSynchronizationStatement;
|
|||
import org.eclipse.cdt.core.dom.upc.ast.IUPCASTUnarySizeofExpression;
|
||||
import org.eclipse.cdt.core.dom.lrparser.lpgextensions.FixedBacktrackingParser;
|
||||
|
||||
public class UPCSizeofExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser
|
||||
public class UPCSizeofExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser< IASTExpression >
|
||||
{
|
||||
private static ParseTable prs = new UPCSizeofExpressionParserprs();
|
||||
private FixedBacktrackingParser btParser;
|
||||
|
@ -128,22 +128,22 @@ public class UPCSizeofExpressionParser 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
|
||||
{
|
||||
|
@ -161,7 +161,7 @@ public class UPCSizeofExpressionParser extends PrsStream implements RuleAction ,
|
|||
|
||||
try
|
||||
{
|
||||
return (Object) btParser.parse(error_repair_count);
|
||||
btParser.parse(error_repair_count);
|
||||
}
|
||||
catch (BadParseException e)
|
||||
{
|
||||
|
@ -169,19 +169,19 @@ public class UPCSizeofExpressionParser extends PrsStream implements RuleAction ,
|
|||
DiagnoseParser diagnoseParser = new DiagnoseParser(this, prs);
|
||||
diagnoseParser.diagnose(e.error_token);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private UPCParserAction action;
|
||||
private ScopedStack<Object> astStack = new ScopedStack<Object>();
|
||||
private IASTCompletionNode compNode;
|
||||
|
||||
public UPCSizeofExpressionParser() { // constructor
|
||||
}
|
||||
|
||||
private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
|
||||
action = new UPCParserAction (this, tu, astStack, new UPCASTNodeFactory() , UPCSecondaryParserFactory.getDefault() );
|
||||
private void initActions(Set<IParser.Options> options) {
|
||||
ScopedStack<Object> astStack = new ScopedStack<Object>();
|
||||
|
||||
action = new UPCParserAction (this, astStack, new UPCASTNodeFactory() , UPCSecondaryParserFactory.getDefault() );
|
||||
action.setParserOptions(options);
|
||||
|
||||
|
||||
|
@ -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 UPCSizeofExpressionParsersym.orderedTerminalSymbols;
|
||||
}
|
||||
|
@ -782,6 +779,12 @@ public UPCSizeofExpressionParser(IParserActionTokenProvider parser) { // constr
|
|||
case 164: { action. consumeToken(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 177: type_name_specifier ::= identifier_token
|
||||
//
|
||||
case 177: { action. consumeToken(); break;
|
||||
}
|
||||
|
||||
//
|
||||
// Rule 178: struct_or_union_specifier ::= struct_or_union struct_or_union_specifier_hook { <openscope-ast> struct_declaration_list_opt }
|
||||
//
|
||||
|
@ -1253,7 +1256,7 @@ public UPCSizeofExpressionParser(IParserActionTokenProvider parser) { // constr
|
|||
//
|
||||
// Rule 312: no_sizeof_type_id_start ::= ERROR_TOKEN
|
||||
//
|
||||
case 312: { action. consumeExpressionProblem(); break;
|
||||
case 312: { action. consumeEmpty(); break;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
Loading…
Add table
Reference in a new issue