1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 22:22:11 +02:00

working on porting the UPC plugin

This commit is contained in:
Mike Kucera 2008-04-08 22:01:21 +00:00
parent 1ca857981f
commit 2ae1a301ef
17 changed files with 3014 additions and 3135 deletions

View file

@ -6,7 +6,8 @@ Bundle-Version: 4.0.1.qualifier
Bundle-ClassPath: .
Require-Bundle: org.eclipse.cdt.core,
net.sourceforge.lpg.lpgjavaruntime;bundle-version="1.1.0";visibility:=reexport,
org.eclipse.core.runtime
org.eclipse.core.runtime,
org.apache.ant;bundle-version="1.7.0"
Export-Package: org.eclipse.cdt.core.dom.lrparser,
org.eclipse.cdt.core.dom.lrparser.action,
org.eclipse.cdt.core.dom.lrparser.action.c99,

View file

@ -13,6 +13,7 @@
-- TODO when the architecture has solidified try to move common
-- stuff between C99 and C++ into one file.
$Include
common.g
$End
@ -117,13 +118,6 @@ $End
--$Start
-- translation_unit
--$End
$Rules
-------------------------------------------------------------------------------------------
@ -986,19 +980,3 @@ function_body
/. $Build consumeStatementCompoundStatement(true); $EndBuild ./
$End

View file

@ -67,7 +67,6 @@ $Headers
private void initActions(IASTTranslationUnit tu) {
action = new $build_action_class($node_factory_create_expression, this, tu);
action.setTokenMap($sym_type.orderedTerminalSymbols);
}

View file

@ -114,9 +114,6 @@ public abstract class BuildASTParserAction {
private final IASTNodeFactory nodeFactory;
/**
* Completion tokens are represented by different kinds by different parsers.
*/

View file

@ -11,28 +11,7 @@
package org.eclipse.cdt.core.dom.lrparser.action.c99;
import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_Completion;
import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK__Bool;
import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK__Complex;
import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_auto;
import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_char;
import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_const;
import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_double;
import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_extern;
import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_float;
import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_identifier;
import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_inline;
import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_int;
import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_long;
import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_register;
import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_restrict;
import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_short;
import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_signed;
import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_static;
import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_typedef;
import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_unsigned;
import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_void;
import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.TK_volatile;
import static org.eclipse.cdt.internal.core.dom.lrparser.c99.C99Parsersym.*;
import java.util.Collections;
import java.util.List;
@ -87,7 +66,6 @@ import org.eclipse.cdt.internal.core.dom.lrparser.c99.C99ExpressionStatementPars
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.C99SizeofExpressionParser;
import org.eclipse.cdt.internal.core.dom.lrparser.cpp.CPPParsersym;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
/**
@ -98,7 +76,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
@SuppressWarnings("restriction")
public class C99BuildASTParserAction extends BuildASTParserAction {
private ITokenMap tokenMap = null;
private final ITokenMap tokenMap;
/** Used to create the AST node objects */
protected final IC99ASTNodeFactory nodeFactory;
@ -111,25 +89,22 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
public C99BuildASTParserAction(IC99ASTNodeFactory nodeFactory, IParserActionTokenProvider parser, IASTTranslationUnit tu) {
super(nodeFactory, parser, tu);
this.nodeFactory = nodeFactory;
this.tokenMap = new TokenMap(C99Parsersym.orderedTerminalSymbols, parser.getOrderedTerminalSymbols());
}
@Override protected boolean isCompletionToken(IToken token) {
@Override
protected boolean isCompletionToken(IToken token) {
return asC99Kind(token) == TK_Completion;
}
public void setTokenMap(String[] orderedTerminalSymbols) {
this.tokenMap = new TokenMap(C99Parsersym.orderedTerminalSymbols, orderedTerminalSymbols);
}
int asC99Kind(IToken token) {
private int asC99Kind(IToken token) {
return asC99Kind(token.getKind());
}
private int asC99Kind(int tokenKind) {
return tokenMap == null ? tokenKind : tokenMap.mapKind(tokenKind);
return tokenMap.mapKind(tokenKind);
}
@ -161,11 +136,10 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
* postfix_expression ::= postfix_expression '.' ident
* postfix_expression ::= postfix_expression '->' ident
*/
public void consumeExpressionFieldReference(/*IBinding field, */ boolean isPointerDereference) {
public void consumeExpressionFieldReference(boolean isPointerDereference) {
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
IASTName name = createName(parser.getRightIToken());
//name.setBinding(field);
IASTExpression owner = (IASTExpression) astStack.pop();
IASTFieldReference expr = nodeFactory.newFieldReference(name, owner, isPointerDereference);
setOffsetAndLength(expr);
@ -222,7 +196,7 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
* In plain C99 specifiers are always just single tokens, but in language
* extensions specifiers may be more complex. Thats why this method takes
* Object as the type of the specifier, so that it may be overridden in subclasses
* and used with arbitray objects as the specifier.
* and used with arbitrary objects as the specifier.
*/
protected void setSpecifier(ICASTDeclSpecifier node, Object specifier) {
if(!(specifier instanceof IToken))
@ -463,11 +437,10 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
/**
* designator ::= '.' 'identifier'
*/
public void consumeDesignatorField(/*IBinding binding*/) {
public void consumeDesignatorField() {
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
IASTName name = createName( parser.getRightIToken() );
//name.setBinding(binding);
IASTName name = createName(parser.getRightIToken());
ICASTFieldDesignator designator = nodeFactory.newCFieldDesignator(name);
setOffsetAndLength(designator);
astStack.push(designator);
@ -558,10 +531,10 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
List<Object> declarators = (hasDeclaratorList) ? astStack.closeScope() : Collections.emptyList();
IASTDeclSpecifier declSpecifier = (IASTDeclSpecifier) astStack.pop();
// do not generate nodes for extra EOC tokens
if(matchTokens(parser.getRuleTokens(), CPPParsersym.TK_EndOfCompletion))
return;
List<IToken> ruleTokens = parser.getRuleTokens();
if(ruleTokens.size() == 1 && asC99Kind(ruleTokens.get(0)) == TK_EndOfCompletion)
return; // do not generate nodes for extra EOC tokens
IASTSimpleDeclaration declaration = nodeFactory.newSimpleDeclaration(declSpecifier);
for(Object declarator : declarators)
@ -647,11 +620,10 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
*
* enum_specifier ::= 'enum' enum_identifier
*/
public void consumeTypeSpecifierElaborated(int kind /*, IBinding binding*/) {
public void consumeTypeSpecifierElaborated(int kind) {
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
IASTName name = createName(parser.getRuleTokens().get(1));
//name.setBinding(binding);
IASTElaboratedTypeSpecifier typeSpec = nodeFactory.newElaboratedTypeSpecifier(kind, name);
setOffsetAndLength(typeSpec);
astStack.push(typeSpec);

View file

@ -170,7 +170,6 @@ public C99ExpressionStatementParser() { // constructor
private void initActions(IASTTranslationUnit tu) {
action = new C99BuildASTParserAction ( C99ASTNodeFactory.DEFAULT_INSTANCE , this, tu);
action.setTokenMap(C99ExpressionStatementParsersym.orderedTerminalSymbols);
}

View file

@ -170,7 +170,6 @@ public C99NoCastExpressionParser() { // constructor
private void initActions(IASTTranslationUnit tu) {
action = new C99BuildASTParserAction ( C99ASTNodeFactory.DEFAULT_INSTANCE , this, tu);
action.setTokenMap(C99NoCastExpressionParsersym.orderedTerminalSymbols);
}

View file

@ -170,7 +170,6 @@ public C99Parser() { // constructor
private void initActions(IASTTranslationUnit tu) {
action = new C99BuildASTParserAction ( C99ASTNodeFactory.DEFAULT_INSTANCE , this, tu);
action.setTokenMap(C99Parsersym.orderedTerminalSymbols);
}

View file

@ -170,7 +170,6 @@ public C99SizeofExpressionParser() { // constructor
private void initActions(IASTTranslationUnit tu) {
action = new C99BuildASTParserAction ( C99ASTNodeFactory.DEFAULT_INSTANCE , this, tu);
action.setTokenMap(C99SizeofExpressionParsersym.orderedTerminalSymbols);
}

View file

@ -1,4 +1,4 @@
#Tue Apr 08 11:17:06 EDT 2008
#Tue Apr 08 17:05:16 EDT 2008
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
@ -48,7 +48,7 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
org.eclipse.jdt.core.compiler.problem.unusedImport=error
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
org.eclipse.jdt.core.compiler.problem.unusedParameter=warning

View file

@ -0,0 +1,82 @@
<!--
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
-->
<project name="UPC Parser" default="upc" basedir=".">
<description>Generates the UPC parser from LPG grammar files</description>
<fail unless="lpg_exe">
Property $${lpg_exe} not set.
This property must be set to the full path to the LPG generator executable.
</fail>
<fail unless="lpg_template">
Property $${lpg_template} not set.
This property must be set to the full path to the LPG templates folder.
</fail>
<property name="upc_location" value="../src/org/eclipse/cdt/internal/core/dom/parser/upc"/>
<target name="upc">
<description>Generate the UPC parser</description>
<!-- Generate main parser -->
<antcall target="generate_upc">
<param name="grammar_name" value="UPCParser"/>
</antcall>
<!-- Generate parser for disambiguating declarations vs expression statements -->
<!--
<antcall target="generate_upc">
<param name="grammar_name" value="C99ExpressionStatementParser"/>
</antcall>
-->
<!-- Generate parser for disambiguating cast expressions vs binary expressions-->
<!--
<antcall target="generate_upc">
<param name="grammar_name" value="C99NoCastExpressionParser"/>
</antcall>
-->
<!-- Generate parser for disambiguating sizeof expressions -->
<!--
<antcall target="generate_upc">
<param name="grammar_name" value="C99SizeofExpressionParser"/>
</antcall>
-->
</target>
<target name="generate_upc">
<antcall target="generate">
<param name="grammar_dir" value="upc"/>
<param name="output_dir" value="${upc_location}"/>
<param name="grammar_name" value="${grammar_name}"/>
</antcall>
</target>
<target name="generate">
<property name="grammar_file" value="${grammar_dir}/${grammar_name}.g"/>
<echo message="lpg_exe=${lpg_exe}"/>
<echo message="lpg_template=${lpg_template}"/>
<echo message="grammar_file=${grammar_file}.g"/>
<echo message="output_dir=${output_dir}"/>
<exec executable="${lpg_exe}">
<arg value="${grammar_file}"/>
<env key="LPG_TEMPLATE" path="${lpg_template}"/>
</exec>
<move overwrite="true" toDir="${output_dir}">
<fileset dir=".">
<include name="${grammar_name}*.*"/>
</fileset>
</move>
</target>
</project>

View file

@ -12,35 +12,34 @@
%options la=2
%options package=org.eclipse.cdt.internal.core.dom.parser.upc
%options template=btParserTemplateD.g
%options import_terminals=UPCLexer.g
-- Unified Parallel C (UPC) is an extension of C99.
-- Must set LPG_INCLUDE environment variable to the location of C99Parser.g
$Import
C99Parser.g
C99Grammar.g
$End
$Start
translation_unit
$End
$Define
$build_action_class /. UPCParserAction ./
$node_factory_create_expression /. UPCASTNodeFactory.DEFAULT_INSTANCE ./
$End
$Globals
/.
import org.eclipse.cdt.core.dom.upc.ast.IUPCASTKeywordExpression;
import org.eclipse.cdt.core.dom.upc.ast.IUPCASTSizeofExpression;
import org.eclipse.cdt.core.dom.upc.ast.IUPCASTSynchronizationStatement;
import org.eclipse.cdt.internal.core.dom.parser.c99.C99Lexer;
import org.eclipse.cdt.internal.core.dom.parser.c99.C99Parsersym;
import org.eclipse.cdt.core.dom.parser.upc.UPCKeywordMap;
import org.eclipse.cdt.core.dom.parser.upc.UPCASTNodeFactory;
import org.eclipse.cdt.core.dom.parser.upc.UPCParserAction;
import org.eclipse.cdt.core.dom.c99.IPreprocessorTokenCollector;
import org.eclipse.cdt.core.dom.upc.ast.IUPCASTKeywordExpression;
import org.eclipse.cdt.core.dom.upc.ast.IUPCASTSynchronizationStatement;
import org.eclipse.cdt.core.dom.upc.ast.IUPCASTUnaryExpression;
./
$End
$Define
$action_class /. UPCParserAction ./
$keyword_map_class /. UPCKeywordMap ./
$token_map_class /. UPCTokenMap ./
$lexer_class /. UPCLexer ./
$End
$Terminals -- Additional keywords defined by UPC
MYTHREAD
@ -67,40 +66,30 @@ $Rules -- UPC grammar extensions to C99
-- Expressions
-----------------------------------------------------------------------------------
-- also need to be a pre-defined macro
-- THREADS and UPC_MAX_BLOCKSIZE are macros, but I want to be able to recognize
-- them in the AST, how do I do this? (getRawSignature() to get the source code and then string compare to THREADS?)
-- just use the paths and symbols dialog to add them, good for testing they can be added later by a upc toolchain
-- map them to integers in the UPCKeywordMap
-- override consumeExpressionConstant(IASTLiteralExpression.lk_integer_constant), call toString() onthe token
-- and check if its THREADS or UPC_MAX_BLOCKSIZE and create appropriate AST node
-- but then the value would be lost, its no good, they need to be builtin macros
constant
literal
::= 'MYTHREAD'
/.$ba consumeKeywordExpression(IUPCASTKeywordExpression.kw_mythread); $ea./
/. $Build consumeKeywordExpression(IUPCASTKeywordExpression.kw_mythread); $EndBuild ./
| 'THREADS'
/.$ba consumeKeywordExpression(IUPCASTKeywordExpression.kw_threads); $ea./
/. $Build consumeKeywordExpression(IUPCASTKeywordExpression.kw_threads); $EndBuild ./
| 'UPC_MAX_BLOCKSIZE'
/.$ba consumeKeywordExpression(IUPCASTKeywordExpression.kw_upc_max_block_size); $ea./
/. $Build consumeKeywordExpression(IUPCASTKeywordExpression.kw_upc_max_block_size); $EndBuild ./
-- causes ambiguities because of no type information, solution is SGLR
unary_expression
::= 'upc_localsizeof' unary_expression
/.$ba consumeExpressionUpcSizeofOperator(IUPCASTSizeofExpression.op_upc_localsizeof); $ea./
/. $Build consumeExpressionUpcSizeofOperator(IUPCASTUnaryExpression.op_upc_localsizeof); $EndBuild ./
| 'upc_localsizeof' '(' type_name ')'
/.$ba consumeExpressionUpcSizeofTypeName(IUPCASTSizeofExpression.op_upc_localsizeof); $ea./
/. $Build consumeExpressionUpcSizeofTypeName(IUPCASTUnaryExpression.op_upc_localsizeof); $EndBuild ./
| 'upc_blocksizeof' unary_expression
/.$ba consumeExpressionUpcSizeofOperator(IUPCASTSizeofExpression.op_upc_blocksizeof); $ea./
/. $Build consumeExpressionUpcSizeofOperator(IUPCASTUnaryExpression.op_upc_blocksizeof); $EndBuild ./
| 'upc_blocksizeof' '(' type_name ')'
/.$ba consumeExpressionUpcSizeofTypeName(IUPCASTSizeofExpression.op_upc_blocksizeof); $ea./
/. $Build consumeExpressionUpcSizeofTypeName(IUPCASTUnaryExpression.op_upc_blocksizeof); $EndBuild ./
| 'upc_elemsizeof' unary_expression
/.$ba consumeExpressionUpcSizeofOperator(IUPCASTSizeofExpression.op_upc_elemsizeof); $ea./
/. $Build consumeExpressionUpcSizeofOperator(IUPCASTUnaryExpression.op_upc_elemsizeof); $EndBuild ./
| 'upc_elemsizeof' '(' type_name ')'
/.$ba consumeExpressionUpcSizeofTypeName(IUPCASTSizeofExpression.op_upc_elemsizeof); $ea./
/. $Build consumeExpressionUpcSizeofTypeName(IUPCASTUnaryExpression.op_upc_elemsizeof); $EndBuild ./
-----------------------------------------------------------------------------------
@ -120,19 +109,19 @@ type_qualifier
shared_type_qualifier
::= 'shared' layout_qualifier -- don't consume anything, the presense of the
-- layout_qualifier will determine that 'shared' token was encountered
| 'shared' /.$ba consumeToken(); $ea./
| 'shared' /. $Build consumeToken(); $EndBuild ./
reference_type_qualifier
::= 'relaxed' /.$ba consumeToken(); $ea./
| 'strict' /.$ba consumeToken(); $ea./
::= 'relaxed' /. $Build consumeToken(); $EndBuild ./
| 'strict' /. $Build consumeToken(); $EndBuild ./
layout_qualifier
::= '[' constant_expression ']'
/.$ba consumeLayoutQualifier(true, false); $ea./
/. $Build consumeLayoutQualifier(true, false); $EndBuild ./
| '[' '*' ']'
/.$ba consumeLayoutQualifier(false, true); $ea./
/. $Build consumeLayoutQualifier(false, true); $EndBuild ./
| '[' ']'
/.$ba consumeLayoutQualifier(false, false); $ea./
/. $Build consumeLayoutQualifier(false, false); $EndBuild ./
@ -145,98 +134,98 @@ statement
synchronization_statement
::= 'upc_notify' expression ';'
/.$ba consumeStatementSynchronizationStatement(IUPCASTSynchronizationStatement.st_upc_notify, true); $ea./
/. $Build consumeStatementSynchronizationStatement(IUPCASTSynchronizationStatement.st_upc_notify, true); $EndBuild ./
| 'upc_notify' ';'
/.$ba consumeStatementSynchronizationStatement(IUPCASTSynchronizationStatement.st_upc_notify, false); $ea./
/. $Build consumeStatementSynchronizationStatement(IUPCASTSynchronizationStatement.st_upc_notify, false); $EndBuild ./
| 'upc_wait' expression ';'
/.$ba consumeStatementSynchronizationStatement(IUPCASTSynchronizationStatement.st_upc_wait, true); $ea./
/. $Build consumeStatementSynchronizationStatement(IUPCASTSynchronizationStatement.st_upc_wait, true); $EndBuild ./
| 'upc_wait' ';'
/.$ba consumeStatementSynchronizationStatement(IUPCASTSynchronizationStatement.st_upc_wait, false); $ea./
/. $Build consumeStatementSynchronizationStatement(IUPCASTSynchronizationStatement.st_upc_wait, false); $EndBuild ./
| 'upc_barrier' expression ';'
/.$ba consumeStatementSynchronizationStatement(IUPCASTSynchronizationStatement.st_upc_barrier, true); $ea./
/. $Build consumeStatementSynchronizationStatement(IUPCASTSynchronizationStatement.st_upc_barrier, true); $EndBuild ./
| 'upc_barrier' ';'
/.$ba consumeStatementSynchronizationStatement(IUPCASTSynchronizationStatement.st_upc_barrier, false); $ea./
/. $Build consumeStatementSynchronizationStatement(IUPCASTSynchronizationStatement.st_upc_barrier, false); $EndBuild ./
| 'upc_fence' ';'
/.$ba consumeStatementSynchronizationStatement(IUPCASTSynchronizationStatement.st_upc_fence, false); $ea./
/. $Build consumeStatementSynchronizationStatement(IUPCASTSynchronizationStatement.st_upc_fence, false); $EndBuild ./
iteration_statement
::= 'upc_forall' '(' expression ';' expression ';' expression ';' affinity ')' statement
/.$ba consumeStatementUPCForallLoop(true, true, true, true); $ea./
/. $Build consumeStatementUPCForallLoop(true, true, true, true); $EndBuild ./
| 'upc_forall' '(' expression ';' expression ';' expression ';' ')' statement
/.$ba consumeStatementUPCForallLoop(true, true, true, false); $ea./
/. $Build consumeStatementUPCForallLoop(true, true, true, false); $EndBuild ./
| 'upc_forall' '(' expression ';' expression ';' ';' affinity ')' statement
/.$ba consumeStatementUPCForallLoop(true, true, false, true); $ea./
/. $Build consumeStatementUPCForallLoop(true, true, false, true); $EndBuild ./
| 'upc_forall' '(' expression ';' expression ';' ';' ')' statement
/.$ba consumeStatementUPCForallLoop(true, true, false, false); $ea./
/. $Build consumeStatementUPCForallLoop(true, true, false, false); $EndBuild ./
| 'upc_forall' '(' expression ';' ';' expression ';' affinity ')' statement
/.$ba consumeStatementUPCForallLoop(true, false, true, true); $ea./
/. $Build consumeStatementUPCForallLoop(true, false, true, true); $EndBuild ./
| 'upc_forall' '(' expression ';' ';' expression ';' ')' statement
/.$ba consumeStatementUPCForallLoop(true, false, true, false); $ea./
/. $Build consumeStatementUPCForallLoop(true, false, true, false); $EndBuild ./
| 'upc_forall' '(' expression ';' ';' ';' affinity ')' statement
/.$ba consumeStatementUPCForallLoop(true, false, false, true); $ea./
/. $Build consumeStatementUPCForallLoop(true, false, false, true); $EndBuild ./
| 'upc_forall' '(' expression ';' ';' ';' ')' statement
/.$ba consumeStatementUPCForallLoop(true, false, false, false); $ea./
/. $Build consumeStatementUPCForallLoop(true, false, false, false); $EndBuild ./
| 'upc_forall' '(' ';' expression ';' expression ';' affinity ')' statement
/.$ba consumeStatementUPCForallLoop(false, true, true, true); $ea./
/. $Build consumeStatementUPCForallLoop(false, true, true, true); $EndBuild ./
| 'upc_forall' '(' ';' expression ';' expression ';' ')' statement
/.$ba consumeStatementUPCForallLoop(false, true, true, false); $ea./
/. $Build consumeStatementUPCForallLoop(false, true, true, false); $EndBuild ./
| 'upc_forall' '(' ';' expression ';' ';' affinity ')' statement
/.$ba consumeStatementUPCForallLoop(false, true, false, true); $ea./
/. $Build consumeStatementUPCForallLoop(false, true, false, true); $EndBuild ./
| 'upc_forall' '(' ';' expression ';' ';' ')' statement
/.$ba consumeStatementUPCForallLoop(false, true, false, false); $ea./
/. $Build consumeStatementUPCForallLoop(false, true, false, false); $EndBuild ./
| 'upc_forall' '(' ';' ';' expression ';' affinity ')' statement
/.$ba consumeStatementUPCForallLoop(false, false, true, true); $ea./
/. $Build consumeStatementUPCForallLoop(false, false, true, true); $EndBuild ./
| 'upc_forall' '(' ';' ';' expression ';' ')' statement
/.$ba consumeStatementUPCForallLoop(false, false, true, false); $ea./
/. $Build consumeStatementUPCForallLoop(false, false, true, false); $EndBuild ./
| 'upc_forall' '(' ';' ';' ';' affinity ')' statement
/.$ba consumeStatementUPCForallLoop(false, false, false, true); $ea./
/. $Build consumeStatementUPCForallLoop(false, false, false, true); $EndBuild ./
| 'upc_forall' '(' ';' ';' ';' ')' statement
/.$ba consumeStatementUPCForallLoop(false, false, false, false); $ea./
/. $Build consumeStatementUPCForallLoop(false, false, false, false); $EndBuild ./
| 'upc_forall' '(' declaration expression ';' expression ';' affinity ')' statement
/.$ba consumeStatementUPCForallLoop(true, true, true, true); $ea./
/. $Build consumeStatementUPCForallLoop(true, true, true, true); $EndBuild ./
| 'upc_forall' '(' declaration expression ';' expression ';' ')' statement
/.$ba consumeStatementUPCForallLoop(true, true, true, false); $ea./
/. $Build consumeStatementUPCForallLoop(true, true, true, false); $EndBuild ./
| 'upc_forall' '(' declaration expression ';' ';' affinity ')' statement
/.$ba consumeStatementUPCForallLoop(true, true, false, true); $ea./
/. $Build consumeStatementUPCForallLoop(true, true, false, true); $EndBuild ./
| 'upc_forall' '(' declaration expression ';' ';' ')' statement
/.$ba consumeStatementUPCForallLoop(true, true, false, false); $ea./
/. $Build consumeStatementUPCForallLoop(true, true, false, false); $EndBuild ./
| 'upc_forall' '(' declaration ';' expression ';' affinity ')' statement
/.$ba consumeStatementUPCForallLoop(true, false, true, true); $ea./
/. $Build consumeStatementUPCForallLoop(true, false, true, true); $EndBuild ./
| 'upc_forall' '(' declaration ';' expression ';' ')' statement
/.$ba consumeStatementUPCForallLoop(true, false, true, false); $ea./
/. $Build consumeStatementUPCForallLoop(true, false, true, false); $EndBuild ./
| 'upc_forall' '(' declaration ';' ';' affinity ')' statement
/.$ba consumeStatementUPCForallLoop(true, false, false, true); $ea./
/. $Build consumeStatementUPCForallLoop(true, false, false, true); $EndBuild ./
| 'upc_forall' '(' declaration ';' ';' ')' statement
/.$ba consumeStatementUPCForallLoop(true, false, false, false); $ea./
/. $Build consumeStatementUPCForallLoop(true, false, false, false); $EndBuild ./
affinity
::= expression
| 'continue'
/.$ba consumeToken(); $ea./
/. $Build consumeToken(); $EndBuild ./
$End

View file

@ -47,6 +47,9 @@ import org.eclipse.cdt.internal.core.dom.parser.upc.ast.UPCASTUnaryExpression;
*/
public class UPCASTNodeFactory extends C99ASTNodeFactory {
public static final UPCASTNodeFactory DEFAULT_INSTANCE = new UPCASTNodeFactory();
@Override
public IASTTypeIdExpression newTypeIdExpression(int operator, IASTTypeId typeId) {
return new UPCASTTypeIdExpression(operator, typeId);

View file

@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.parser.upc;
import lpg.lpgjavaruntime.IToken;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
@ -40,11 +41,15 @@ public class UPCParserAction extends C99BuildASTParserAction {
public UPCParserAction(UPCASTNodeFactory nodeFactory, IParserActionTokenProvider parser, IASTTranslationUnit tu) {
super(nodeFactory, parser, tu);
super.setTokenMap(UPCParsersym.orderedTerminalSymbols);
this.nodeFactory = nodeFactory;
}
@Override
protected boolean isCompletionToken(IToken token) {
return token.getKind() == UPCParsersym.TK_Completion;
}
/**************************************************************************************
* Semantic actions
**************************************************************************************/

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 IBM Corporation and others.
* 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
@ -15,60 +15,68 @@ package org.eclipse.cdt.internal.core.dom.parser.upc;
public interface UPCParsersym {
public final static int
TK_auto = 35,
TK_break = 64,
TK_case = 65,
TK_char = 41,
TK_const = 25,
TK_continue = 59,
TK_default = 66,
TK_do = 67,
TK_double = 42,
TK_auto = 50,
TK_break = 29,
TK_case = 30,
TK_char = 55,
TK_const = 43,
TK_continue = 27,
TK_default = 31,
TK_do = 32,
TK_double = 56,
TK_else = 93,
TK_enum = 54,
TK_extern = 36,
TK_float = 43,
TK_for = 68,
TK_goto = 69,
TK_if = 70,
TK_inline = 37,
TK_int = 44,
TK_long = 45,
TK_register = 38,
TK_restrict = 26,
TK_return = 71,
TK_short = 46,
TK_signed = 47,
TK_sizeof = 11,
TK_static = 32,
TK_struct = 55,
TK_switch = 72,
TK_typedef = 39,
TK_union = 56,
TK_unsigned = 48,
TK_void = 49,
TK_volatile = 27,
TK_while = 60,
TK__Bool = 50,
TK__Complex = 51,
TK__Imaginary = 52,
TK_LeftBracket = 31,
TK_LeftParen = 1,
TK_LeftBrace = 24,
TK_enum = 68,
TK_extern = 51,
TK_float = 57,
TK_for = 33,
TK_goto = 34,
TK_if = 35,
TK_inline = 52,
TK_int = 58,
TK_long = 59,
TK_register = 53,
TK_restrict = 44,
TK_return = 36,
TK_short = 60,
TK_signed = 61,
TK_sizeof = 12,
TK_static = 49,
TK_struct = 69,
TK_switch = 37,
TK_typedef = 54,
TK_union = 70,
TK_unsigned = 62,
TK_void = 63,
TK_volatile = 45,
TK_while = 28,
TK__Bool = 64,
TK__Complex = 65,
TK__Imaginary = 66,
TK_integer = 13,
TK_floating = 14,
TK_charconst = 15,
TK_stringlit = 16,
TK_identifier = 1,
TK_Completion = 3,
TK_EndOfCompletion = 4,
TK_Invalid = 107,
TK_LeftBracket = 67,
TK_LeftParen = 2,
TK_LeftBrace = 6,
TK_Dot = 80,
TK_Arrow = 94,
TK_PlusPlus = 9,
TK_MinusMinus = 10,
TK_And = 8,
TK_Star = 3,
TK_Plus = 6,
TK_Minus = 7,
TK_Tilde = 12,
TK_Bang = 13,
TK_PlusPlus = 10,
TK_MinusMinus = 11,
TK_And = 9,
TK_Star = 5,
TK_Plus = 7,
TK_Minus = 8,
TK_Tilde = 17,
TK_Bang = 18,
TK_Slash = 81,
TK_Percent = 82,
TK_RightShift = 61,
TK_LeftShift = 62,
TK_RightShift = 76,
TK_LeftShift = 77,
TK_LT = 83,
TK_GT = 84,
TK_LE = 85,
@ -80,9 +88,9 @@ public interface UPCParsersym {
TK_AndAnd = 92,
TK_OrOr = 95,
TK_Question = 96,
TK_Colon = 57,
TK_DotDotDot = 73,
TK_Assign = 74,
TK_Colon = 74,
TK_DotDotDot = 79,
TK_Assign = 75,
TK_StarAssign = 97,
TK_SlashAssign = 98,
TK_PercentAssign = 99,
@ -93,155 +101,137 @@ public interface UPCParsersym {
TK_AndAssign = 104,
TK_CaretAssign = 105,
TK_OrAssign = 106,
TK_Comma = 33,
TK_Hash = 107,
TK_HashHash = 108,
TK_NewLine = 109,
TK_MYTHREAD = 14,
TK_THREADS = 15,
TK_UPC_MAX_BLOCKSIZE = 16,
TK_relaxed = 28,
TK_shared = 29,
TK_strict = 30,
TK_upc_barrier = 75,
TK_upc_localsizeof = 17,
TK_upc_blocksizeof = 18,
TK_upc_elemsizeof = 19,
TK_upc_notify = 76,
TK_upc_fence = 77,
TK_upc_wait = 78,
TK_upc_forall = 79,
TK_EOF_TOKEN = 87,
TK_identifier = 2,
TK_integer = 20,
TK_floating = 21,
TK_charconst = 22,
TK_stringlit = 23,
TK_RightBracket = 63,
TK_RightParen = 53,
TK_RightBrace = 40,
TK_SemiColon = 34,
TK_Invalid = 110,
TK_Completion = 5,
TK_EndOfCompletion = 4,
TK_SingleLineComment = 111,
TK_MultiLineComment = 112,
TK_ERROR_TOKEN = 58;
TK_Comma = 72,
TK_RightBracket = 78,
TK_RightParen = 73,
TK_RightBrace = 71,
TK_SemiColon = 25,
TK_MYTHREAD = 19,
TK_THREADS = 20,
TK_UPC_MAX_BLOCKSIZE = 21,
TK_relaxed = 46,
TK_shared = 47,
TK_strict = 48,
TK_upc_barrier = 38,
TK_upc_localsizeof = 22,
TK_upc_blocksizeof = 23,
TK_upc_elemsizeof = 24,
TK_upc_notify = 39,
TK_upc_fence = 40,
TK_upc_wait = 41,
TK_upc_forall = 42,
TK_ERROR_TOKEN = 26,
TK_EOF_TOKEN = 87;
public final static String orderedTerminalSymbols[] = {
"",//$NON-NLS-1$
"LeftParen",//$NON-NLS-1$
"identifier",//$NON-NLS-1$
"Star",//$NON-NLS-1$
"EndOfCompletion",//$NON-NLS-1$
"Completion",//$NON-NLS-1$
"Plus",//$NON-NLS-1$
"Minus",//$NON-NLS-1$
"And",//$NON-NLS-1$
"PlusPlus",//$NON-NLS-1$
"MinusMinus",//$NON-NLS-1$
"sizeof",//$NON-NLS-1$
"Tilde",//$NON-NLS-1$
"Bang",//$NON-NLS-1$
"MYTHREAD",//$NON-NLS-1$
"THREADS",//$NON-NLS-1$
"UPC_MAX_BLOCKSIZE",//$NON-NLS-1$
"upc_localsizeof",//$NON-NLS-1$
"upc_blocksizeof",//$NON-NLS-1$
"upc_elemsizeof",//$NON-NLS-1$
"integer",//$NON-NLS-1$
"floating",//$NON-NLS-1$
"charconst",//$NON-NLS-1$
"stringlit",//$NON-NLS-1$
"LeftBrace",//$NON-NLS-1$
"const",//$NON-NLS-1$
"restrict",//$NON-NLS-1$
"volatile",//$NON-NLS-1$
"relaxed",//$NON-NLS-1$
"shared",//$NON-NLS-1$
"strict",//$NON-NLS-1$
"LeftBracket",//$NON-NLS-1$
"static",//$NON-NLS-1$
"Comma",//$NON-NLS-1$
"SemiColon",//$NON-NLS-1$
"auto",//$NON-NLS-1$
"extern",//$NON-NLS-1$
"inline",//$NON-NLS-1$
"register",//$NON-NLS-1$
"typedef",//$NON-NLS-1$
"RightBrace",//$NON-NLS-1$
"char",//$NON-NLS-1$
"double",//$NON-NLS-1$
"float",//$NON-NLS-1$
"int",//$NON-NLS-1$
"long",//$NON-NLS-1$
"short",//$NON-NLS-1$
"signed",//$NON-NLS-1$
"unsigned",//$NON-NLS-1$
"void",//$NON-NLS-1$
"_Bool",//$NON-NLS-1$
"_Complex",//$NON-NLS-1$
"_Imaginary",//$NON-NLS-1$
"RightParen",//$NON-NLS-1$
"enum",//$NON-NLS-1$
"struct",//$NON-NLS-1$
"union",//$NON-NLS-1$
"Colon",//$NON-NLS-1$
"ERROR_TOKEN",//$NON-NLS-1$
"continue",//$NON-NLS-1$
"while",//$NON-NLS-1$
"RightShift",//$NON-NLS-1$
"LeftShift",//$NON-NLS-1$
"RightBracket",//$NON-NLS-1$
"break",//$NON-NLS-1$
"case",//$NON-NLS-1$
"default",//$NON-NLS-1$
"do",//$NON-NLS-1$
"for",//$NON-NLS-1$
"goto",//$NON-NLS-1$
"if",//$NON-NLS-1$
"return",//$NON-NLS-1$
"switch",//$NON-NLS-1$
"DotDotDot",//$NON-NLS-1$
"Assign",//$NON-NLS-1$
"upc_barrier",//$NON-NLS-1$
"upc_notify",//$NON-NLS-1$
"upc_fence",//$NON-NLS-1$
"upc_wait",//$NON-NLS-1$
"upc_forall",//$NON-NLS-1$
"Dot",//$NON-NLS-1$
"Slash",//$NON-NLS-1$
"Percent",//$NON-NLS-1$
"LT",//$NON-NLS-1$
"GT",//$NON-NLS-1$
"LE",//$NON-NLS-1$
"GE",//$NON-NLS-1$
"EOF_TOKEN",//$NON-NLS-1$
"EQ",//$NON-NLS-1$
"NE",//$NON-NLS-1$
"Caret",//$NON-NLS-1$
"Or",//$NON-NLS-1$
"AndAnd",//$NON-NLS-1$
"else",//$NON-NLS-1$
"Arrow",//$NON-NLS-1$
"OrOr",//$NON-NLS-1$
"Question",//$NON-NLS-1$
"StarAssign",//$NON-NLS-1$
"SlashAssign",//$NON-NLS-1$
"PercentAssign",//$NON-NLS-1$
"PlusAssign",//$NON-NLS-1$
"MinusAssign",//$NON-NLS-1$
"RightShiftAssign",//$NON-NLS-1$
"LeftShiftAssign",//$NON-NLS-1$
"AndAssign",//$NON-NLS-1$
"CaretAssign",//$NON-NLS-1$
"OrAssign",//$NON-NLS-1$
"Hash",//$NON-NLS-1$
"HashHash",//$NON-NLS-1$
"NewLine",//$NON-NLS-1$
"Invalid",//$NON-NLS-1$
"SingleLineComment",//$NON-NLS-1$
"MultiLineComment"//$NON-NLS-1$
"",
"identifier",
"LeftParen",
"Completion",
"EndOfCompletion",
"Star",
"LeftBrace",
"Plus",
"Minus",
"And",
"PlusPlus",
"MinusMinus",
"sizeof",
"integer",
"floating",
"charconst",
"stringlit",
"Tilde",
"Bang",
"MYTHREAD",
"THREADS",
"UPC_MAX_BLOCKSIZE",
"upc_localsizeof",
"upc_blocksizeof",
"upc_elemsizeof",
"SemiColon",
"ERROR_TOKEN",
"continue",
"while",
"break",
"case",
"default",
"do",
"for",
"goto",
"if",
"return",
"switch",
"upc_barrier",
"upc_notify",
"upc_fence",
"upc_wait",
"upc_forall",
"const",
"restrict",
"volatile",
"relaxed",
"shared",
"strict",
"static",
"auto",
"extern",
"inline",
"register",
"typedef",
"char",
"double",
"float",
"int",
"long",
"short",
"signed",
"unsigned",
"void",
"_Bool",
"_Complex",
"_Imaginary",
"LeftBracket",
"enum",
"struct",
"union",
"RightBrace",
"Comma",
"RightParen",
"Colon",
"Assign",
"RightShift",
"LeftShift",
"RightBracket",
"DotDotDot",
"Dot",
"Slash",
"Percent",
"LT",
"GT",
"LE",
"GE",
"EOF_TOKEN",
"EQ",
"NE",
"Caret",
"Or",
"AndAnd",
"else",
"Arrow",
"OrOr",
"Question",
"StarAssign",
"SlashAssign",
"PercentAssign",
"PlusAssign",
"MinusAssign",
"RightShiftAssign",
"LeftShiftAssign",
"AndAssign",
"CaretAssign",
"OrAssign",
"Invalid"
};
public final static boolean isValidForParser = true;