1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-12 02:35:37 +02:00

multi-parser approach applied to C99

This commit is contained in:
Mike Kucera 2008-02-05 15:44:08 +00:00
parent a8f928a682
commit 80485fce8a
27 changed files with 12439 additions and 4709 deletions

View file

@ -41,11 +41,30 @@
<target name="c99"> <target name="c99">
<description>Generate the C99 parser</description> <description>Generate the C99 parser</description>
<!-- Generate main parser -->
<antcall target="generate"> <antcall target="generate">
<param name="grammar_dir" value="c99"/> <param name="grammar_dir" value="c99"/>
<param name="grammar_name" value="C99Parser"/> <param name="grammar_name" value="C99Parser"/>
<param name="output_dir" value="org/eclipse/cdt/internal/core/dom/lrparser/c99"/> <param name="output_dir" value="org/eclipse/cdt/internal/core/dom/lrparser/c99"/>
</antcall> </antcall>
<!-- Generate parser for disambiguating declarations vs expression statements -->
<antcall target="generate">
<param name="grammar_dir" value="c99"/>
<param name="grammar_name" value="C99ExpressionStatementParser"/>
<param name="output_dir" value="org/eclipse/cdt/internal/core/dom/lrparser/c99"/>
</antcall>
<!-- Generate parser for disambiguating cast expressions vs binary expressions-->
<antcall target="generate">
<param name="grammar_dir" value="c99"/>
<param name="grammar_name" value="C99NoCastExpressionParser"/>
<param name="output_dir" value="org/eclipse/cdt/internal/core/dom/lrparser/c99"/>
</antcall>
<!-- Generate parser for disambiguating sizeof expressions -->
<antcall target="generate">
<param name="grammar_dir" value="c99"/>
<param name="grammar_name" value="C99SizeofExpressionParser"/>
<param name="output_dir" value="org/eclipse/cdt/internal/core/dom/lrparser/c99"/>
</antcall>
</target> </target>

View file

@ -0,0 +1,47 @@
-----------------------------------------------------------------------------------
-- Copyright (c) 2006, 2008 IBM Corporation and others.
-- All rights reserved. This program and the accompanying materials
-- are made available under the terms of the Eclipse Public License v1.0
-- which accompanies this distribution, and is available at
-- http://www.eclipse.org/legal/epl-v10.html
--
-- Contributors:
-- IBM Corporation - initial API and implementation
-----------------------------------------------------------------------------------
%options la=2
%options package=org.eclipse.cdt.internal.core.dom.lrparser.c99
%options template=btParserTemplateD.g
-- All we need to do is import the main parser and redefine the start symbol.
$Define
$sym_class /. C99ExpressionStatementParsersym ./
$End
$Import
C99Grammar.g
$End
$Start
expression_parser_start
$End
$Headers
/.
public IASTExpression getParseResult() {
return (IASTExpression) action.getSecondaryParseResult();
}
./
$End
$Rules
expression_parser_start
::= expression ';'
| ERROR_TOKEN
/. $Build consumeExpressionProblem(); $EndBuild ./
$End

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,57 @@
-----------------------------------------------------------------------------------
-- Copyright (c) 2006, 2008 IBM Corporation and others.
-- All rights reserved. This program and the accompanying materials
-- are made available under the terms of the Eclipse Public License v1.0
-- which accompanies this distribution, and is available at
-- http://www.eclipse.org/legal/epl-v10.html
--
-- Contributors:
-- IBM Corporation - initial API and implementation
-----------------------------------------------------------------------------------
%options la=2
%options package=org.eclipse.cdt.internal.core.dom.lrparser.c99
%options template=btParserTemplateD.g
$Define
$sym_class /. C99NoCastExpressionParsersym ./
$End
$Import
C99Grammar.g
$DropRules
cast_expression
::= '(' type_name ')' cast_expression
-- The following rule remains in the grammar:
-- cast_expression ::= unary_expression
$End
$Start
no_cast_start
$End
$Headers
/.
public IASTExpression getParseResult() {
return (IASTExpression) action.getSecondaryParseResult();
}
./
$End
$Rules
no_cast_start
::= expression
| ERROR_TOKEN
/. $Build consumeExpressionProblem(); $EndBuild ./
$End

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,54 @@
-----------------------------------------------------------------------------------
-- Copyright (c) 2006, 2008 IBM Corporation and others.
-- All rights reserved. This program and the accompanying materials
-- are made available under the terms of the Eclipse Public License v1.0
-- which accompanies this distribution, and is available at
-- http://www.eclipse.org/legal/epl-v10.html
--
-- Contributors:
-- IBM Corporation - initial API and implementation
-----------------------------------------------------------------------------------
%options la=2
%options package=org.eclipse.cdt.internal.core.dom.lrparser.c99
%options template=btParserTemplateD.g
$Define
$sym_class /. C99SizeofExpressionParsersym ./
$End
$Import
C99Grammar.g
$DropRules
unary_expression
::= 'sizeof' '(' type_name ')'
$End
$Start
no_sizeof_type_name_start
$End
$Headers
/.
public IASTExpression getParseResult() {
return (IASTExpression) action.getSecondaryParseResult();
}
./
$End
$Rules
no_sizeof_type_name_start
::= expression
| ERROR_TOKEN
/. $Build consumeExpressionProblem(); $EndBuild ./
$End

File diff suppressed because it is too large Load diff

View file

@ -33,76 +33,49 @@ $Define
$ast_class /.Object./ $ast_class /.Object./
$data_class /. Object ./ -- allow anything to be passed between actions $data_class /. Object ./ -- allow anything to be passed between actions
--$additional_interfaces /. , IParserActionTokenProvider, IParser ./ $additional_interfaces /. , IParserActionTokenProvider, IParser ./
$additional_interfaces /. ./
$build_action_class /. ./ $build_action_class /. ./
$resolve_action_class /. ./ $resolve_action_class /. ./
$node_factory_create_expression /. ./ $node_factory_create_expression /. ./
$lexer_class /. ./ $lexer_class /. ./
$action_class /. ./ $action_class /. ./
$Build /. $BeginAction action. ./
$UndoResolver /.$Undo action.resolver.undo(); $EndUndo./ $EndBuild /. $EndAction ./
$Resolve /. $BeginTrial $resolve.
./
$EndResolve /. $EndTrial
$UndoResolver
./ -- undo actions are automatically generated for binding resolution actions
$Builder /. $BeginFinal $builder.
./
$EndBuilder /. /*$builder.getASTStack().print();*/ $EndFinal ./
$Build /. $Action $Builder ./
$EndBuild /. $EndBuilder $EndAction ./
$resolve /. action.resolver./
$builder /. action.builder./
-- comment out when using trial/undo
--$Action /. $BeginAction ./
--$BeginFinal /. ./
--$EndFinal /. ./
--$BeginTrial /. ./
--$EndTrial /. ./
--$Undo /. ./
--$EndUndo /. ./
$End $End
$Globals
/.
import java.util.*;
import org.eclipse.cdt.core.dom.ast.*;
import org.eclipse.cdt.core.dom.lrparser.IParser;
import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
import org.eclipse.cdt.core.dom.lrparser.util.DebugUtil;
./
$End
$Headers $Headers
/. /.
private $action_class action; private $build_action_class action;
//public $action_type() { // constructor public $action_type() { // constructor
//} }
private void initActions(IASTTranslationUnit tu) { private void initActions(IASTTranslationUnit tu) {
// binding resolution actions need access to IASTName nodes, temporary action = new $build_action_class($node_factory_create_expression, this, tu);
action = new $action_class(); action.setTokenMap($sym_class.orderedTerminalSymbols);
action.resolver = new $resolve_action_class(this);
action.builder = new $build_action_class($node_factory_create_expression, this, tu);
action.builder.setTokenMap($sym_class.orderedTerminalSymbols);
//setParserAction(action);
} }
public void addToken(IToken token) { public void addToken(IToken token) {
token.setKind(mapKind(token.getKind())); token.setKind(mapKind(token.getKind())); // TODO does mapKind need to be called?
super.addToken(token); super.addToken(token);
} }
public void setTokens(List<IToken> tokens) {
resetTokenStream();
for(IToken token : tokens) {
addToken(token);
}
}
public IASTCompletionNode parse(IASTTranslationUnit tu) { public IASTCompletionNode parse(IASTTranslationUnit tu) {
// this has to be done, or... kaboom! // this has to be done, or... kaboom!
@ -114,21 +87,45 @@ $Headers
super.resetTokenStream(); // allow tokens to be garbage collected super.resetTokenStream(); // allow tokens to be garbage collected
// the completion node may be null // the completion node may be null
IASTCompletionNode compNode = action.builder.getASTCompletionNode(); IASTCompletionNode compNode = action.getASTCompletionNode();
action = null; //action = null;
parserAction = null; //parserAction = null;
return compNode; return compNode;
} }
// uncomment this method to use with backtracking parser
public int getKind(int i) { public List getRuleTokens() {
int kind = super.getKind(i); return Collections.unmodifiableList(getTokens().subList(getLeftSpan(), getRightSpan() + 1));
// lexer feedback hack! }
//if(kind == $sym_class.TK_identifier && action.resolver.isTypedef(getTokenText(i))) {
// kind = $sym_class.TK_TypedefName; ./
//} $End
return kind;
$Globals
/.
import org.eclipse.cdt.core.dom.lrparser.action.ITokenMap;
import org.eclipse.cdt.core.dom.lrparser.action.TokenMap;
./
$End
$Headers
/.
private ITokenMap tokenMap = null;
public void setTokens(List<IToken> tokens) {
resetTokenStream();
addToken(new Token(null, 0, 0, 0)); // dummy token
for(IToken token : tokens) {
token.setKind(tokenMap.mapKind(token.getKind()));
addToken(token);
}
addToken(new Token(null, 0, 0, $sym_class.TK_EOF_TOKEN));
}
public $action_type(String[] mapFrom) { // constructor
tokenMap = new TokenMap($sym_class.orderedTerminalSymbols, mapFrom);
} }
./ ./

View file

@ -1588,6 +1588,7 @@ conversion_declarator
/. $Build consumeDeclaratorWithPointer(false); $EndBuild ./ /. $Build consumeDeclaratorWithPointer(false); $EndBuild ./
--conversion_declarator_opt --conversion_declarator_opt
-- ::= conversion_declarator -- ::= conversion_declarator
-- | $empty -- | $empty

View file

@ -15,6 +15,7 @@ import java.util.List;
import lpg.lpgjavaruntime.IToken; import lpg.lpgjavaruntime.IToken;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator; import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier; import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression; import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
@ -52,9 +53,9 @@ import org.eclipse.cdt.core.dom.ast.IASTNullStatement;
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration; import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator; import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
import org.eclipse.cdt.core.dom.ast.IASTProblem; 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.IASTProblemHolder;
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement; import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTStatement; import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
@ -65,13 +66,13 @@ import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTPointer; import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider; import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
import org.eclipse.cdt.core.dom.lrparser.util.DebugUtil; import org.eclipse.cdt.core.dom.lrparser.util.DebugUtil;
import org.eclipse.cdt.internal.core.dom.lrparser.c99.C99NoCastExpressionParser;
import org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.c.CASTNode; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousExpression;
/** /**
@ -117,6 +118,11 @@ public abstract class BuildASTParserAction {
private final IASTNodeFactory nodeFactory; private final IASTNodeFactory nodeFactory;
protected static final ASTVisitor EMPTY_VISITOR = new ASTVisitor() {
{ shouldVisitStatements = true; }
};
/** /**
* Completion tokens are represented by different kinds by different parsers. * Completion tokens are represented by different kinds by different parsers.
@ -165,6 +171,13 @@ public abstract class BuildASTParserAction {
} }
/**
* Used to get the result of secondary parsers.
*/
public Object getSecondaryParseResult() {
return astStack.pop();
}
protected static int offset(IToken token) { protected static int offset(IToken token) {
@ -298,6 +311,9 @@ public abstract class BuildASTParserAction {
setOffsetAndLength(tu, 0, offset(d) + length(d)); setOffsetAndLength(tu, 0, offset(d) + length(d));
} }
// resolve ambiguities
tu.accept(EMPTY_VISITOR);
if(TRACE_AST_STACK) System.out.println(astStack); if(TRACE_AST_STACK) System.out.println(astStack);
} }
@ -439,6 +455,8 @@ public abstract class BuildASTParserAction {
/** /**
* @param operator constant for {@link ICPPASTCastExpression} * @param operator constant for {@link ICPPASTCastExpression}
*
* TODO Remove C99 specific code
*/ */
public void consumeExpressionCast(int operator) { public void consumeExpressionCast(int operator) {
if(TRACE_ACTIONS) DebugUtil.printMethodTrace(); if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
@ -447,7 +465,18 @@ public abstract class BuildASTParserAction {
IASTTypeId typeId = (IASTTypeId) astStack.pop(); IASTTypeId typeId = (IASTTypeId) astStack.pop();
IASTCastExpression expr = nodeFactory.newCastExpression(operator, typeId, operand); IASTCastExpression expr = nodeFactory.newCastExpression(operator, typeId, operand);
setOffsetAndLength(expr); setOffsetAndLength(expr);
astStack.push(expr);
// try parsing as non-cast to resolve ambiguities
C99NoCastExpressionParser alternateParser = new C99NoCastExpressionParser(C99Parsersym.orderedTerminalSymbols);
alternateParser.setTokens(parser.getRuleTokens());
alternateParser.parse(tu);
IASTExpression alternateExpr = alternateParser.getParseResult();
if(alternateExpr == null || alternateExpr instanceof IASTProblemExpression)
astStack.push(expr);
else
astStack.push(nodeFactory.newAmbiguousExpression(expr, alternateExpr));
if(TRACE_AST_STACK) System.out.println(astStack); if(TRACE_AST_STACK) System.out.println(astStack);
} }
@ -598,6 +627,7 @@ public abstract class BuildASTParserAction {
} }
/** /**
* compound_statement ::= <openscope> '{' block_item_list '}' * compound_statement ::= <openscope> '{' block_item_list '}'
* *

View file

@ -62,6 +62,8 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression; import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.IASTWhileStatement; import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator; import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousExpression;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousStatement;
/** /**
@ -69,6 +71,7 @@ import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
* *
* @author Mike Kucera * @author Mike Kucera
*/ */
@SuppressWarnings("restriction")
public interface IASTNodeFactory { public interface IASTNodeFactory {
public IASTName newName(char[] name); public IASTName newName(char[] name);
@ -172,4 +175,8 @@ public interface IASTNodeFactory {
public IASTFieldDeclarator newFieldDeclarator(IASTName name, IASTExpression bitFieldSize); public IASTFieldDeclarator newFieldDeclarator(IASTName name, IASTExpression bitFieldSize);
public IASTAmbiguousStatement newAmbiguousStatement(IASTStatement... statements);
public IASTAmbiguousExpression newAmbiguousExpression(IASTExpression... expressions);
} }

View file

@ -384,12 +384,12 @@ public class C99ASTNodeFactory implements IC99ASTNodeFactory {
return new CASTProblem(id, arg, warn, error); return new CASTProblem(id, arg, warn, error);
} }
public IASTAmbiguousExpression newAmbiguousExpression() { public IASTAmbiguousExpression newAmbiguousExpression(IASTExpression... expressions) {
return new CASTAmbiguousExpression(); return new CASTAmbiguousExpression(expressions);
} }
public IASTAmbiguousStatement newAmbiguousStatement() { public IASTAmbiguousStatement newAmbiguousStatement(IASTStatement... statements) {
return new CASTAmbiguousStatement(); return new CASTAmbiguousStatement(statements);
} }
public IASTTranslationUnit newTranslationUnit() { public IASTTranslationUnit newTranslationUnit() {

View file

@ -42,20 +42,19 @@ import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement; import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement; import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
import org.eclipse.cdt.core.dom.ast.IASTFieldReference; import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTIfStatement; import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
import org.eclipse.cdt.core.dom.ast.IASTInitializer; import org.eclipse.cdt.core.dom.ast.IASTInitializer;
import org.eclipse.cdt.core.dom.ast.IASTInitializerList; import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration; import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTPointer; import org.eclipse.cdt.core.dom.ast.IASTPointer;
import org.eclipse.cdt.core.dom.ast.IASTProblemExpression;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
@ -63,6 +62,8 @@ import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement; import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.IASTWhileStatement; import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayDesignator; import org.eclipse.cdt.core.dom.ast.c.ICASTArrayDesignator;
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier; import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier;
@ -82,8 +83,14 @@ import org.eclipse.cdt.core.dom.lrparser.action.ITokenMap;
import org.eclipse.cdt.core.dom.lrparser.action.TokenMap; import org.eclipse.cdt.core.dom.lrparser.action.TokenMap;
import org.eclipse.cdt.core.dom.lrparser.util.CollectionUtils; import org.eclipse.cdt.core.dom.lrparser.util.CollectionUtils;
import org.eclipse.cdt.core.dom.lrparser.util.DebugUtil; import org.eclipse.cdt.core.dom.lrparser.util.DebugUtil;
import org.eclipse.cdt.internal.core.dom.lrparser.c99.C99ExpressionStatementParser;
import org.eclipse.cdt.internal.core.dom.lrparser.c99.C99NoCastExpressionParser;
import org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym; import org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym;
import org.eclipse.cdt.internal.core.dom.lrparser.c99.C99SizeofExpressionParser;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousExpression;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousStatement;
import org.eclipse.cdt.internal.core.dom.parser.c.CASTAmbiguousExpression;
/** /**
* Semantic actions called by the C99 parser to build an AST. * Semantic actions called by the C99 parser to build an AST.
@ -171,6 +178,31 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
if(TRACE_AST_STACK) System.out.println(astStack); if(TRACE_AST_STACK) System.out.println(astStack);
} }
/**
* Lots of rules, no need to list them.
* @param operator From IASTUnaryExpression
*/
public void consumeExpressionSizeofTypeId() {
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
IASTTypeId typeId = (IASTTypeId) astStack.pop();
IASTTypeIdExpression expr = nodeFactory.newTypeIdExpression(IASTTypeIdExpression.op_sizeof, typeId);
setOffsetAndLength(expr);
// try parsing as an expression to resolve ambiguities
C99SizeofExpressionParser alternateParser = new C99SizeofExpressionParser(C99Parsersym.orderedTerminalSymbols);
alternateParser.setTokens(parser.getRuleTokens());
alternateParser.parse(tu);
IASTExpression alternateExpr = alternateParser.getParseResult();
if(alternateExpr == null || alternateExpr instanceof IASTProblemExpression)
astStack.push(expr);
else
astStack.push(nodeFactory.newAmbiguousExpression(expr, alternateExpr));
if(TRACE_AST_STACK) System.out.println(astStack);
}
/** /**
* Sets a token specifier. * Sets a token specifier.
@ -648,13 +680,30 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
if(TRACE_ACTIONS) DebugUtil.printMethodTrace(); if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
IASTDeclaration decl = (IASTDeclaration) astStack.pop(); IASTDeclaration decl = (IASTDeclaration) astStack.pop();
IASTDeclarationStatement declarationStatement = nodeFactory.newDeclarationStatement(decl);
setOffsetAndLength(declarationStatement);
if(disambiguateHackIdentifierExpression(decl)) // attempt to also parse the tokens as an expression
return; IASTExpressionStatement expressionStatement = null;
if(decl instanceof IASTSimpleDeclaration) {
// TODO this probably has bad performance
C99ExpressionStatementParser expressionParser = new C99ExpressionStatementParser(C99Parsersym.orderedTerminalSymbols);
expressionParser.setTokens(parser.getRuleTokens());
// need to pass tu because any completion nodes need to be linked directly to the root
expressionParser.parse(tu);
IASTExpression expr = expressionParser.getParseResult();
if(expr != null && !(expr instanceof IASTProblemExpression)) { // the parse may fail
expressionStatement = nodeFactory.newExpressionStatement(expr);
setOffsetAndLength(expressionStatement);
}
}
if(expressionStatement == null)
astStack.push(declarationStatement);
else
astStack.push(nodeFactory.newAmbiguousStatement(declarationStatement, expressionStatement));
IASTDeclarationStatement stat = nodeFactory.newDeclarationStatement(decl);
setOffsetAndLength(stat);
astStack.push(stat);
if(TRACE_AST_STACK) System.out.println(astStack); if(TRACE_AST_STACK) System.out.println(astStack);
} }
@ -662,46 +711,46 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
//
/** // /**
* Kludgy way to disambiguate a certain case. // * Kludgy way to disambiguate a certain case.
* An identifier alone on a line will be parsed as a declaration // * An identifier alone on a line will be parsed as a declaration
* but it probably should be an expression. // * but it probably should be an expression.
* eg) i; // * eg) i;
* // *
* This only happens in the presence of a completion token. // * This only happens in the presence of a completion token.
* // *
* @return true if the hack was applied // * @return true if the hack was applied
*/ // */
private boolean disambiguateHackIdentifierExpression(IASTDeclaration decl) { // private boolean disambiguateHackIdentifierExpression(IASTDeclaration decl) {
if(TRACE_ACTIONS) DebugUtil.printMethodTrace(); // if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
//
// this is only meant to work with content assist // // this is only meant to work with content assist
List<IToken> tokens = parser.getRuleTokens(); // List<IToken> tokens = parser.getRuleTokens();
if(tokens.size() != 2 || tokens.get(0).getKind() == TK_typedef) // if(tokens.size() != 2 || tokens.get(0).getKind() == TK_typedef)
return false; // return false;
//
if(decl instanceof IASTSimpleDeclaration) { // if(decl instanceof IASTSimpleDeclaration) {
IASTSimpleDeclaration declaration = (IASTSimpleDeclaration) decl; // IASTSimpleDeclaration declaration = (IASTSimpleDeclaration) decl;
if(declaration.getDeclarators() == IASTDeclarator.EMPTY_DECLARATOR_ARRAY) { // if(declaration.getDeclarators() == IASTDeclarator.EMPTY_DECLARATOR_ARRAY) {
IASTDeclSpecifier declSpec = declaration.getDeclSpecifier(); // IASTDeclSpecifier declSpec = declaration.getDeclSpecifier();
if(declSpec instanceof ICASTTypedefNameSpecifier) { // if(declSpec instanceof ICASTTypedefNameSpecifier) {
ICASTTypedefNameSpecifier typedefNameSpec = (ICASTTypedefNameSpecifier) declSpec; // ICASTTypedefNameSpecifier typedefNameSpec = (ICASTTypedefNameSpecifier) declSpec;
IASTName name = typedefNameSpec.getName(); // IASTName name = typedefNameSpec.getName();
//
if(offset(name) == offset(typedefNameSpec) && length(name) == length(typedefNameSpec)) { // if(offset(name) == offset(typedefNameSpec) && length(name) == length(typedefNameSpec)) {
IASTIdExpression idExpr = nodeFactory.newIdExpression(name); // IASTIdExpression idExpr = nodeFactory.newIdExpression(name);
IASTExpressionStatement stat = nodeFactory.newExpressionStatement(idExpr); // IASTExpressionStatement stat = nodeFactory.newExpressionStatement(idExpr);
//
setOffsetAndLength(stat); // setOffsetAndLength(stat);
astStack.push(stat); // astStack.push(stat);
return true; // return true;
} // }
} // }
} // }
} // }
return false; // return false;
} // }

View file

@ -96,7 +96,13 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisiblityLabel; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisiblityLabel;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.dom.lrparser.action.ASTCompletionNode; import org.eclipse.cdt.core.dom.lrparser.action.ASTCompletionNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousDeclaration;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousExpression;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousStatement;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTASMDeclaration; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTASMDeclaration;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTAmbiguousDeclaration;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTAmbiguousExpression;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTAmbiguousStatement;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTArrayDeclarator; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTArrayDeclarator;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTArrayModifier; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTArrayModifier;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTArraySubscriptExpression; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTArraySubscriptExpression;
@ -533,4 +539,16 @@ public class CPPASTNodeFactory implements ICPPASTNodeFactory {
return new CPPASTTemplatedTypeTemplateParameter(name, idExpression); return new CPPASTTemplatedTypeTemplateParameter(name, idExpression);
} }
public IASTAmbiguousDeclaration newAmbiguousDeclaration(IASTDeclaration... declarations) {
return new CPPASTAmbiguousDeclaration(declarations);
}
public IASTAmbiguousExpression newAmbiguousExpression(IASTExpression... expressions) {
return new CPPASTAmbiguousExpression(expressions);
}
public IASTAmbiguousStatement newAmbiguousStatement(IASTStatement... statements) {
return new CPPASTAmbiguousStatement(statements);
}
} }

View file

@ -52,12 +52,14 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisiblityLabel; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisiblityLabel;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.dom.lrparser.action.IASTNodeFactory; import org.eclipse.cdt.core.dom.lrparser.action.IASTNodeFactory;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousDeclaration;
/** /**
* TODO remove CPP from method names. * TODO remove CPP from method names.
* *
* @author Mike Kucera * @author Mike Kucera
*/ */
@SuppressWarnings("restriction")
public interface ICPPASTNodeFactory extends IASTNodeFactory { public interface ICPPASTNodeFactory extends IASTNodeFactory {
public ICPPASTOperatorName newCPPOperatorName(char[] name); public ICPPASTOperatorName newCPPOperatorName(char[] name);
@ -131,4 +133,6 @@ public interface ICPPASTNodeFactory extends IASTNodeFactory {
public ICPPASTSimpleTypeTemplateParameter newSimpleTypeTemplateParameter(int type, IASTName name, IASTTypeId typeId); public ICPPASTSimpleTypeTemplateParameter newSimpleTypeTemplateParameter(int type, IASTName name, IASTTypeId typeId);
public ICPPASTTemplatedTypeTemplateParameter newTemplatedTypeTemplateParameter(IASTName name, IASTExpression idExpression); public ICPPASTTemplatedTypeTemplateParameter newTemplatedTypeTemplateParameter(IASTName name, IASTExpression idExpression);
public IASTAmbiguousDeclaration newAmbiguousDeclaration(IASTDeclaration... declarations);
} }

View file

@ -0,0 +1,210 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*********************************************************************************/
// This file was generated by LPG
package org.eclipse.cdt.internal.core.dom.lrparser.c99;
public interface C99ExpressionStatementParsersym {
public final static int
TK_auto = 24,
TK_break = 81,
TK_case = 82,
TK_char = 36,
TK_const = 8,
TK_continue = 83,
TK_default = 84,
TK_do = 85,
TK_double = 37,
TK_else = 86,
TK_enum = 58,
TK_extern = 25,
TK_float = 38,
TK_for = 87,
TK_goto = 88,
TK_if = 89,
TK_inline = 26,
TK_int = 39,
TK_long = 40,
TK_register = 27,
TK_restrict = 9,
TK_return = 90,
TK_short = 41,
TK_signed = 42,
TK_sizeof = 15,
TK_static = 23,
TK_struct = 59,
TK_switch = 91,
TK_typedef = 28,
TK_union = 60,
TK_unsigned = 43,
TK_void = 44,
TK_volatile = 10,
TK_while = 92,
TK__Bool = 45,
TK__Complex = 46,
TK__Imaginary = 47,
TK_integer = 16,
TK_floating = 17,
TK_charconst = 18,
TK_stringlit = 19,
TK_identifier = 1,
TK_Completion = 4,
TK_EndOfCompletion = 5,
TK_Invalid = 93,
TK_LeftBracket = 11,
TK_LeftParen = 2,
TK_LeftBrace = 22,
TK_Dot = 48,
TK_Arrow = 66,
TK_PlusPlus = 13,
TK_MinusMinus = 14,
TK_And = 12,
TK_Star = 3,
TK_Plus = 6,
TK_Minus = 7,
TK_Tilde = 20,
TK_Bang = 21,
TK_Slash = 49,
TK_Percent = 50,
TK_RightShift = 31,
TK_LeftShift = 32,
TK_LT = 51,
TK_GT = 52,
TK_LE = 53,
TK_GE = 54,
TK_EQ = 61,
TK_NE = 62,
TK_Caret = 63,
TK_Or = 64,
TK_AndAnd = 65,
TK_OrOr = 67,
TK_Question = 68,
TK_Colon = 55,
TK_DotDotDot = 33,
TK_Assign = 56,
TK_StarAssign = 69,
TK_SlashAssign = 70,
TK_PercentAssign = 71,
TK_PlusAssign = 72,
TK_MinusAssign = 73,
TK_RightShiftAssign = 74,
TK_LeftShiftAssign = 75,
TK_AndAssign = 76,
TK_CaretAssign = 77,
TK_OrAssign = 78,
TK_Comma = 30,
TK_RightBracket = 34,
TK_RightParen = 29,
TK_RightBrace = 35,
TK_SemiColon = 57,
TK_ERROR_TOKEN = 79,
TK_EOF_TOKEN = 80;
public final static String orderedTerminalSymbols[] = {
"",
"identifier",
"LeftParen",
"Star",
"Completion",
"EndOfCompletion",
"Plus",
"Minus",
"const",
"restrict",
"volatile",
"LeftBracket",
"And",
"PlusPlus",
"MinusMinus",
"sizeof",
"integer",
"floating",
"charconst",
"stringlit",
"Tilde",
"Bang",
"LeftBrace",
"static",
"auto",
"extern",
"inline",
"register",
"typedef",
"RightParen",
"Comma",
"RightShift",
"LeftShift",
"DotDotDot",
"RightBracket",
"RightBrace",
"char",
"double",
"float",
"int",
"long",
"short",
"signed",
"unsigned",
"void",
"_Bool",
"_Complex",
"_Imaginary",
"Dot",
"Slash",
"Percent",
"LT",
"GT",
"LE",
"GE",
"Colon",
"Assign",
"SemiColon",
"enum",
"struct",
"union",
"EQ",
"NE",
"Caret",
"Or",
"AndAnd",
"Arrow",
"OrOr",
"Question",
"StarAssign",
"SlashAssign",
"PercentAssign",
"PlusAssign",
"MinusAssign",
"RightShiftAssign",
"LeftShiftAssign",
"AndAssign",
"CaretAssign",
"OrAssign",
"ERROR_TOKEN",
"EOF_TOKEN",
"break",
"case",
"continue",
"default",
"do",
"else",
"for",
"goto",
"if",
"return",
"switch",
"while",
"Invalid"
};
public final static boolean isValidForParser = true;
}

View file

@ -0,0 +1,210 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*********************************************************************************/
// This file was generated by LPG
package org.eclipse.cdt.internal.core.dom.lrparser.c99;
public interface C99NoCastExpressionParsersym {
public final static int
TK_auto = 24,
TK_break = 81,
TK_case = 82,
TK_char = 36,
TK_const = 6,
TK_continue = 83,
TK_default = 84,
TK_do = 85,
TK_double = 37,
TK_else = 86,
TK_enum = 57,
TK_extern = 25,
TK_float = 38,
TK_for = 87,
TK_goto = 88,
TK_if = 89,
TK_inline = 26,
TK_int = 39,
TK_long = 40,
TK_register = 27,
TK_restrict = 7,
TK_return = 90,
TK_short = 41,
TK_signed = 42,
TK_sizeof = 15,
TK_static = 16,
TK_struct = 58,
TK_switch = 91,
TK_typedef = 28,
TK_union = 59,
TK_unsigned = 43,
TK_void = 44,
TK_volatile = 8,
TK_while = 92,
TK__Bool = 45,
TK__Complex = 46,
TK__Imaginary = 47,
TK_integer = 17,
TK_floating = 18,
TK_charconst = 19,
TK_stringlit = 20,
TK_identifier = 1,
TK_Completion = 4,
TK_EndOfCompletion = 5,
TK_Invalid = 93,
TK_LeftBracket = 9,
TK_LeftParen = 2,
TK_LeftBrace = 21,
TK_Dot = 48,
TK_Arrow = 66,
TK_PlusPlus = 13,
TK_MinusMinus = 14,
TK_And = 12,
TK_Star = 3,
TK_Plus = 10,
TK_Minus = 11,
TK_Tilde = 22,
TK_Bang = 23,
TK_Slash = 49,
TK_Percent = 50,
TK_RightShift = 31,
TK_LeftShift = 32,
TK_LT = 51,
TK_GT = 52,
TK_LE = 53,
TK_GE = 54,
TK_EQ = 60,
TK_NE = 61,
TK_Caret = 62,
TK_Or = 63,
TK_AndAnd = 64,
TK_OrOr = 67,
TK_Question = 68,
TK_Colon = 55,
TK_DotDotDot = 33,
TK_Assign = 56,
TK_StarAssign = 69,
TK_SlashAssign = 70,
TK_PercentAssign = 71,
TK_PlusAssign = 72,
TK_MinusAssign = 73,
TK_RightShiftAssign = 74,
TK_LeftShiftAssign = 75,
TK_AndAssign = 76,
TK_CaretAssign = 77,
TK_OrAssign = 78,
TK_Comma = 30,
TK_RightBracket = 34,
TK_RightParen = 29,
TK_RightBrace = 35,
TK_SemiColon = 65,
TK_ERROR_TOKEN = 79,
TK_EOF_TOKEN = 80;
public final static String orderedTerminalSymbols[] = {
"",
"identifier",
"LeftParen",
"Star",
"Completion",
"EndOfCompletion",
"const",
"restrict",
"volatile",
"LeftBracket",
"Plus",
"Minus",
"And",
"PlusPlus",
"MinusMinus",
"sizeof",
"static",
"integer",
"floating",
"charconst",
"stringlit",
"LeftBrace",
"Tilde",
"Bang",
"auto",
"extern",
"inline",
"register",
"typedef",
"RightParen",
"Comma",
"RightShift",
"LeftShift",
"DotDotDot",
"RightBracket",
"RightBrace",
"char",
"double",
"float",
"int",
"long",
"short",
"signed",
"unsigned",
"void",
"_Bool",
"_Complex",
"_Imaginary",
"Dot",
"Slash",
"Percent",
"LT",
"GT",
"LE",
"GE",
"Colon",
"Assign",
"enum",
"struct",
"union",
"EQ",
"NE",
"Caret",
"Or",
"AndAnd",
"SemiColon",
"Arrow",
"OrOr",
"Question",
"StarAssign",
"SlashAssign",
"PercentAssign",
"PlusAssign",
"MinusAssign",
"RightShiftAssign",
"LeftShiftAssign",
"AndAssign",
"CaretAssign",
"OrAssign",
"ERROR_TOKEN",
"EOF_TOKEN",
"break",
"case",
"continue",
"default",
"do",
"else",
"for",
"goto",
"if",
"return",
"switch",
"while",
"Invalid"
};
public final static boolean isValidForParser = true;
}

View file

@ -15,57 +15,56 @@ package org.eclipse.cdt.internal.core.dom.lrparser.c99;
public interface C99Parsersym { public interface C99Parsersym {
public final static int public final static int
TK_auto = 26, TK_auto = 24,
TK_break = 33, TK_break = 32,
TK_case = 34, TK_case = 33,
TK_char = 43, TK_char = 42,
TK_const = 21, TK_const = 20,
TK_continue = 35, TK_continue = 34,
TK_default = 36, TK_default = 35,
TK_do = 37, TK_do = 36,
TK_double = 44, TK_double = 43,
TK_else = 80, TK_else = 79,
TK_enum = 56, TK_enum = 54,
TK_extern = 27, TK_extern = 25,
TK_float = 45, TK_float = 44,
TK_for = 28, TK_for = 37,
TK_goto = 38, TK_goto = 38,
TK_if = 39, TK_if = 39,
TK_inline = 29, TK_inline = 26,
TK_int = 46, TK_int = 45,
TK_long = 47, TK_long = 46,
TK_register = 30, TK_register = 27,
TK_restrict = 22, TK_restrict = 21,
TK_return = 40, TK_return = 40,
TK_short = 48, TK_short = 47,
TK_signed = 49, TK_signed = 48,
TK_sizeof = 12, TK_sizeof = 12,
TK_static = 24, TK_static = 23,
TK_struct = 57, TK_struct = 55,
TK_switch = 41, TK_switch = 41,
TK_typedef = 31, TK_typedef = 28,
TK_union = 58, TK_union = 56,
TK_unsigned = 50, TK_unsigned = 49,
TK_void = 51, TK_void = 50,
TK_volatile = 23, TK_volatile = 22,
TK_while = 32, TK_while = 31,
TK__Bool = 52, TK__Bool = 51,
TK__Complex = 53, TK__Complex = 52,
TK__Imaginary = 54, TK__Imaginary = 53,
TK_integer = 13, TK_integer = 13,
TK_floating = 14, TK_floating = 14,
TK_charconst = 15, TK_charconst = 15,
TK_stringlit = 16, TK_stringlit = 16,
TK_identifier = 2, TK_identifier = 2,
TK_TypedefName = 19,
TK_Completion = 5, TK_Completion = 5,
TK_EndOfCompletion = 3, TK_EndOfCompletion = 3,
TK_Invalid = 94, TK_Invalid = 93,
TK_LeftBracket = 42, TK_LeftBracket = 29,
TK_LeftParen = 1, TK_LeftParen = 1,
TK_LeftBrace = 6, TK_LeftBrace = 6,
TK_Dot = 67, TK_Dot = 66,
TK_Arrow = 81, TK_Arrow = 80,
TK_PlusPlus = 10, TK_PlusPlus = 10,
TK_MinusMinus = 11, TK_MinusMinus = 11,
TK_And = 9, TK_And = 9,
@ -74,41 +73,41 @@ public interface C99Parsersym {
TK_Minus = 8, TK_Minus = 8,
TK_Tilde = 17, TK_Tilde = 17,
TK_Bang = 18, TK_Bang = 18,
TK_Slash = 68, TK_Slash = 67,
TK_Percent = 69, TK_Percent = 68,
TK_RightShift = 63, TK_RightShift = 62,
TK_LeftShift = 64, TK_LeftShift = 63,
TK_LT = 70, TK_LT = 69,
TK_GT = 71, TK_GT = 70,
TK_LE = 72, TK_LE = 71,
TK_GE = 73, TK_GE = 72,
TK_EQ = 75, TK_EQ = 74,
TK_NE = 76, TK_NE = 75,
TK_Caret = 77, TK_Caret = 76,
TK_Or = 78, TK_Or = 77,
TK_AndAnd = 79, TK_AndAnd = 78,
TK_OrOr = 82, TK_OrOr = 81,
TK_Question = 83, TK_Question = 82,
TK_Colon = 59, TK_Colon = 59,
TK_DotDotDot = 65, TK_DotDotDot = 64,
TK_Assign = 62, TK_Assign = 61,
TK_StarAssign = 84, TK_StarAssign = 83,
TK_SlashAssign = 85, TK_SlashAssign = 84,
TK_PercentAssign = 86, TK_PercentAssign = 85,
TK_PlusAssign = 87, TK_PlusAssign = 86,
TK_MinusAssign = 88, TK_MinusAssign = 87,
TK_RightShiftAssign = 89, TK_RightShiftAssign = 88,
TK_LeftShiftAssign = 90, TK_LeftShiftAssign = 89,
TK_AndAssign = 91, TK_AndAssign = 90,
TK_CaretAssign = 92, TK_CaretAssign = 91,
TK_OrAssign = 93, TK_OrAssign = 92,
TK_Comma = 55, TK_Comma = 57,
TK_RightBracket = 66, TK_RightBracket = 65,
TK_RightParen = 61, TK_RightParen = 58,
TK_RightBrace = 60, TK_RightBrace = 60,
TK_SemiColon = 20, TK_SemiColon = 19,
TK_ERROR_TOKEN = 25, TK_ERROR_TOKEN = 30,
TK_EOF_TOKEN = 74; TK_EOF_TOKEN = 73;
public final static String orderedTerminalSymbols[] = { public final static String orderedTerminalSymbols[] = {
"", "",
@ -130,30 +129,29 @@ public interface C99Parsersym {
"stringlit", "stringlit",
"Tilde", "Tilde",
"Bang", "Bang",
"TypedefName",
"SemiColon", "SemiColon",
"const", "const",
"restrict", "restrict",
"volatile", "volatile",
"static", "static",
"ERROR_TOKEN",
"auto", "auto",
"extern", "extern",
"for",
"inline", "inline",
"register", "register",
"typedef", "typedef",
"LeftBracket",
"ERROR_TOKEN",
"while", "while",
"break", "break",
"case", "case",
"continue", "continue",
"default", "default",
"do", "do",
"for",
"goto", "goto",
"if", "if",
"return", "return",
"switch", "switch",
"LeftBracket",
"char", "char",
"double", "double",
"float", "float",
@ -166,13 +164,13 @@ public interface C99Parsersym {
"_Bool", "_Bool",
"_Complex", "_Complex",
"_Imaginary", "_Imaginary",
"Comma",
"enum", "enum",
"struct", "struct",
"union", "union",
"Comma",
"RightParen",
"Colon", "Colon",
"RightBrace", "RightBrace",
"RightParen",
"Assign", "Assign",
"RightShift", "RightShift",
"LeftShift", "LeftShift",

View file

@ -0,0 +1,210 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*********************************************************************************/
// This file was generated by LPG
package org.eclipse.cdt.internal.core.dom.lrparser.c99;
public interface C99SizeofExpressionParsersym {
public final static int
TK_auto = 24,
TK_break = 81,
TK_case = 82,
TK_char = 36,
TK_const = 6,
TK_continue = 83,
TK_default = 84,
TK_do = 85,
TK_double = 37,
TK_else = 86,
TK_enum = 57,
TK_extern = 25,
TK_float = 38,
TK_for = 87,
TK_goto = 88,
TK_if = 89,
TK_inline = 26,
TK_int = 39,
TK_long = 40,
TK_register = 27,
TK_restrict = 7,
TK_return = 90,
TK_short = 41,
TK_signed = 42,
TK_sizeof = 15,
TK_static = 22,
TK_struct = 58,
TK_switch = 91,
TK_typedef = 28,
TK_union = 59,
TK_unsigned = 43,
TK_void = 44,
TK_volatile = 8,
TK_while = 92,
TK__Bool = 45,
TK__Complex = 46,
TK__Imaginary = 47,
TK_integer = 16,
TK_floating = 17,
TK_charconst = 18,
TK_stringlit = 19,
TK_identifier = 1,
TK_Completion = 4,
TK_EndOfCompletion = 5,
TK_Invalid = 93,
TK_LeftBracket = 9,
TK_LeftParen = 2,
TK_LeftBrace = 23,
TK_Dot = 48,
TK_Arrow = 66,
TK_PlusPlus = 13,
TK_MinusMinus = 14,
TK_And = 12,
TK_Star = 3,
TK_Plus = 10,
TK_Minus = 11,
TK_Tilde = 20,
TK_Bang = 21,
TK_Slash = 49,
TK_Percent = 50,
TK_RightShift = 31,
TK_LeftShift = 32,
TK_LT = 51,
TK_GT = 52,
TK_LE = 53,
TK_GE = 54,
TK_EQ = 60,
TK_NE = 61,
TK_Caret = 62,
TK_Or = 63,
TK_AndAnd = 64,
TK_OrOr = 67,
TK_Question = 68,
TK_Colon = 55,
TK_DotDotDot = 33,
TK_Assign = 56,
TK_StarAssign = 69,
TK_SlashAssign = 70,
TK_PercentAssign = 71,
TK_PlusAssign = 72,
TK_MinusAssign = 73,
TK_RightShiftAssign = 74,
TK_LeftShiftAssign = 75,
TK_AndAssign = 76,
TK_CaretAssign = 77,
TK_OrAssign = 78,
TK_Comma = 30,
TK_RightBracket = 34,
TK_RightParen = 29,
TK_RightBrace = 35,
TK_SemiColon = 65,
TK_ERROR_TOKEN = 79,
TK_EOF_TOKEN = 80;
public final static String orderedTerminalSymbols[] = {
"",
"identifier",
"LeftParen",
"Star",
"Completion",
"EndOfCompletion",
"const",
"restrict",
"volatile",
"LeftBracket",
"Plus",
"Minus",
"And",
"PlusPlus",
"MinusMinus",
"sizeof",
"integer",
"floating",
"charconst",
"stringlit",
"Tilde",
"Bang",
"static",
"LeftBrace",
"auto",
"extern",
"inline",
"register",
"typedef",
"RightParen",
"Comma",
"RightShift",
"LeftShift",
"DotDotDot",
"RightBracket",
"RightBrace",
"char",
"double",
"float",
"int",
"long",
"short",
"signed",
"unsigned",
"void",
"_Bool",
"_Complex",
"_Imaginary",
"Dot",
"Slash",
"Percent",
"LT",
"GT",
"LE",
"GE",
"Colon",
"Assign",
"enum",
"struct",
"union",
"EQ",
"NE",
"Caret",
"Or",
"AndAnd",
"SemiColon",
"Arrow",
"OrOr",
"Question",
"StarAssign",
"SlashAssign",
"PercentAssign",
"PlusAssign",
"MinusAssign",
"RightShiftAssign",
"LeftShiftAssign",
"AndAssign",
"CaretAssign",
"OrAssign",
"ERROR_TOKEN",
"EOF_TOKEN",
"break",
"case",
"continue",
"default",
"do",
"else",
"for",
"goto",
"if",
"return",
"switch",
"while",
"Invalid"
};
public final static boolean isValidForParser = true;
}