Skip to main content
summaryrefslogtreecommitdiffstats
path: root/upc
diff options
context:
space:
mode:
authorMike Kucera2009-01-15 11:47:58 -0500
committerMike Kucera2009-01-15 11:47:58 -0500
commit7f0debb02ee3ae69906cf16cd82217d67a01757a (patch)
treec71ebe7c7479865574f59fc82a26fbc1392cc763 /upc
parentd52e5c0f1cec1270e4ac69af36727b506b6f209c (diff)
downloadorg.eclipse.cdt-7f0debb02ee3ae69906cf16cd82217d67a01757a.tar.gz
org.eclipse.cdt-7f0debb02ee3ae69906cf16cd82217d67a01757a.tar.xz
org.eclipse.cdt-7f0debb02ee3ae69906cf16cd82217d67a01757a.zip
added ability to "mix-in" grammar extensions and actions, support for extended gnu asm syntax
Diffstat (limited to 'upc')
-rw-r--r--upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/parser/upc/UPCParserAction.java5
-rw-r--r--upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/UPCExpressionParser.java25
-rw-r--r--upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/UPCNoCastExpressionParser.java25
-rw-r--r--upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/UPCParser.java25
-rw-r--r--upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/UPCSizeofExpressionParser.java25
5 files changed, 59 insertions, 46 deletions
diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/parser/upc/UPCParserAction.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/parser/upc/UPCParserAction.java
index 1c7ed62675..142b48121a 100644
--- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/parser/upc/UPCParserAction.java
+++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/parser/upc/UPCParserAction.java
@@ -23,6 +23,7 @@ import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier;
import org.eclipse.cdt.core.dom.lrparser.IParser;
import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
+import org.eclipse.cdt.core.dom.lrparser.action.ScopedStack;
import org.eclipse.cdt.core.dom.lrparser.action.c99.C99BuildASTParserAction;
import org.eclipse.cdt.core.dom.upc.ast.IUPCASTDeclSpecifier;
import org.eclipse.cdt.core.dom.upc.ast.IUPCASTForallStatement;
@@ -48,8 +49,8 @@ public class UPCParserAction extends C99BuildASTParserAction {
* @param parser
* @param tu
*/
- public UPCParserAction(UPCASTNodeFactory nodeFactory, IParserActionTokenProvider parser, IASTTranslationUnit tu) {
- super(nodeFactory, parser, tu);
+ public UPCParserAction(UPCASTNodeFactory nodeFactory, IParserActionTokenProvider parser, IASTTranslationUnit tu, ScopedStack<Object> astStack) {
+ super(nodeFactory, parser, tu, astStack);
this.nodeFactory = nodeFactory;
nodeFactory.setUseC99SizeofExpressions();
}
diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/UPCExpressionParser.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/UPCExpressionParser.java
index f49d243203..24d399d1dd 100644
--- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/UPCExpressionParser.java
+++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/UPCExpressionParser.java
@@ -20,6 +20,7 @@ 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.lpgextensions.FixedBacktrackingParser;
+import org.eclipse.cdt.core.dom.lrparser.action.ScopedStack;
import org.eclipse.cdt.core.dom.lrparser.action.ITokenMap;
import org.eclipse.cdt.core.dom.lrparser.action.TokenMap;
@@ -172,13 +173,16 @@ public class UPCExpressionParser extends PrsStream implements RuleAction , IPars
private UPCParserAction action;
+private ScopedStack<Object> astStack = new ScopedStack<Object>();
public UPCExpressionParser() { // constructor
}
private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
- action = new UPCParserAction ( UPCASTNodeFactory.DEFAULT_INSTANCE , this, tu);
+ action = new UPCParserAction ( UPCASTNodeFactory.DEFAULT_INSTANCE , this, tu, astStack);
action.setParserOptions(options);
+
+
}
@@ -206,13 +210,12 @@ public IASTCompletionNode parse(IASTTranslationUnit tu, Set<IParser.Options> opt
}
// uncomment this method to use with backtracking parser
-public List getRuleTokens() {
- return Collections.unmodifiableList(getTokens().subList(getLeftSpan(), getRightSpan() + 1));
+public List<IToken> getRuleTokens() {
+ return getTokens().subList(getLeftSpan(), getRightSpan() + 1);
}
-
public IASTNode getSecondaryParseResult() {
- return action.getSecondaryParseResult();
+ return (IASTNode) astStack.pop();
}
public String[] getOrderedTerminalSymbols() {
@@ -774,25 +777,25 @@ public UPCExpressionParser(String[] mapFrom) { // constructor
//
// Rule 159: storage_class_specifier ::= storage_class_specifier_token
//
- case 159: { action. consumeDeclSpecToken(); break;
+ case 159: { action. consumeToken(); break;
}
//
// Rule 165: simple_type_specifier ::= simple_type_specifier_token
//
- case 165: { action. consumeDeclSpecToken(); break;
+ case 165: { action. consumeToken(); break;
}
//
// Rule 178: typedef_name_in_declspec ::= Completion
//
- case 178: { action. consumeDeclSpecToken(); break;
+ case 178: { action. consumeToken(); break;
}
//
// Rule 179: typedef_name_in_declspec ::= identifier
//
- case 179: { action. consumeDeclSpecToken(); break;
+ case 179: { action. consumeToken(); break;
}
//
@@ -882,13 +885,13 @@ public UPCExpressionParser(String[] mapFrom) { // constructor
//
// Rule 215: type_qualifier ::= type_qualifier_token
//
- case 215: { action. consumeDeclSpecToken(); break;
+ case 215: { action. consumeToken(); break;
}
//
// Rule 219: function_specifier ::= inline
//
- case 219: { action. consumeDeclSpecToken(); break;
+ case 219: { action. consumeToken(); break;
}
//
diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/UPCNoCastExpressionParser.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/UPCNoCastExpressionParser.java
index f62dca50f7..934912c416 100644
--- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/UPCNoCastExpressionParser.java
+++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/UPCNoCastExpressionParser.java
@@ -20,6 +20,7 @@ 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.lpgextensions.FixedBacktrackingParser;
+import org.eclipse.cdt.core.dom.lrparser.action.ScopedStack;
import org.eclipse.cdt.core.dom.lrparser.action.ITokenMap;
import org.eclipse.cdt.core.dom.lrparser.action.TokenMap;
@@ -172,13 +173,16 @@ public class UPCNoCastExpressionParser extends PrsStream implements RuleAction ,
private UPCParserAction action;
+private ScopedStack<Object> astStack = new ScopedStack<Object>();
public UPCNoCastExpressionParser() { // constructor
}
private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
- action = new UPCParserAction ( UPCASTNodeFactory.DEFAULT_INSTANCE , this, tu);
+ action = new UPCParserAction ( UPCASTNodeFactory.DEFAULT_INSTANCE , this, tu, astStack);
action.setParserOptions(options);
+
+
}
@@ -206,13 +210,12 @@ public IASTCompletionNode parse(IASTTranslationUnit tu, Set<IParser.Options> opt
}
// uncomment this method to use with backtracking parser
-public List getRuleTokens() {
- return Collections.unmodifiableList(getTokens().subList(getLeftSpan(), getRightSpan() + 1));
+public List<IToken> getRuleTokens() {
+ return getTokens().subList(getLeftSpan(), getRightSpan() + 1);
}
-
public IASTNode getSecondaryParseResult() {
- return action.getSecondaryParseResult();
+ return (IASTNode) astStack.pop();
}
public String[] getOrderedTerminalSymbols() {
@@ -768,25 +771,25 @@ public UPCNoCastExpressionParser(String[] mapFrom) { // constructor
//
// Rule 158: storage_class_specifier ::= storage_class_specifier_token
//
- case 158: { action. consumeDeclSpecToken(); break;
+ case 158: { action. consumeToken(); break;
}
//
// Rule 164: simple_type_specifier ::= simple_type_specifier_token
//
- case 164: { action. consumeDeclSpecToken(); break;
+ case 164: { action. consumeToken(); break;
}
//
// Rule 177: typedef_name_in_declspec ::= Completion
//
- case 177: { action. consumeDeclSpecToken(); break;
+ case 177: { action. consumeToken(); break;
}
//
// Rule 178: typedef_name_in_declspec ::= identifier
//
- case 178: { action. consumeDeclSpecToken(); break;
+ case 178: { action. consumeToken(); break;
}
//
@@ -876,13 +879,13 @@ public UPCNoCastExpressionParser(String[] mapFrom) { // constructor
//
// Rule 214: type_qualifier ::= type_qualifier_token
//
- case 214: { action. consumeDeclSpecToken(); break;
+ case 214: { action. consumeToken(); break;
}
//
// Rule 218: function_specifier ::= inline
//
- case 218: { action. consumeDeclSpecToken(); break;
+ case 218: { action. consumeToken(); break;
}
//
diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/UPCParser.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/UPCParser.java
index 625c6931b5..c04af564cc 100644
--- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/UPCParser.java
+++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/UPCParser.java
@@ -20,6 +20,7 @@ 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.lpgextensions.FixedBacktrackingParser;
+import org.eclipse.cdt.core.dom.lrparser.action.ScopedStack;
import org.eclipse.cdt.core.dom.lrparser.action.ITokenMap;
import org.eclipse.cdt.core.dom.lrparser.action.TokenMap;
@@ -172,13 +173,16 @@ public class UPCParser extends PrsStream implements RuleAction , IParserActionTo
private UPCParserAction action;
+private ScopedStack<Object> astStack = new ScopedStack<Object>();
public UPCParser() { // constructor
}
private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
- action = new UPCParserAction ( UPCASTNodeFactory.DEFAULT_INSTANCE , this, tu);
+ action = new UPCParserAction ( UPCASTNodeFactory.DEFAULT_INSTANCE , this, tu, astStack);
action.setParserOptions(options);
+
+
}
@@ -206,13 +210,12 @@ public IASTCompletionNode parse(IASTTranslationUnit tu, Set<IParser.Options> opt
}
// uncomment this method to use with backtracking parser
-public List getRuleTokens() {
- return Collections.unmodifiableList(getTokens().subList(getLeftSpan(), getRightSpan() + 1));
+public List<IToken> getRuleTokens() {
+ return getTokens().subList(getLeftSpan(), getRightSpan() + 1);
}
-
public IASTNode getSecondaryParseResult() {
- return action.getSecondaryParseResult();
+ return (IASTNode) astStack.pop();
}
public String[] getOrderedTerminalSymbols() {
@@ -774,25 +777,25 @@ public UPCParser(String[] mapFrom) { // constructor
//
// Rule 159: storage_class_specifier ::= storage_class_specifier_token
//
- case 159: { action. consumeDeclSpecToken(); break;
+ case 159: { action. consumeToken(); break;
}
//
// Rule 165: simple_type_specifier ::= simple_type_specifier_token
//
- case 165: { action. consumeDeclSpecToken(); break;
+ case 165: { action. consumeToken(); break;
}
//
// Rule 178: typedef_name_in_declspec ::= Completion
//
- case 178: { action. consumeDeclSpecToken(); break;
+ case 178: { action. consumeToken(); break;
}
//
// Rule 179: typedef_name_in_declspec ::= identifier
//
- case 179: { action. consumeDeclSpecToken(); break;
+ case 179: { action. consumeToken(); break;
}
//
@@ -882,13 +885,13 @@ public UPCParser(String[] mapFrom) { // constructor
//
// Rule 215: type_qualifier ::= type_qualifier_token
//
- case 215: { action. consumeDeclSpecToken(); break;
+ case 215: { action. consumeToken(); break;
}
//
// Rule 219: function_specifier ::= inline
//
- case 219: { action. consumeDeclSpecToken(); break;
+ case 219: { action. consumeToken(); break;
}
//
diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/UPCSizeofExpressionParser.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/UPCSizeofExpressionParser.java
index b8f1bd78ba..a5d9262e76 100644
--- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/UPCSizeofExpressionParser.java
+++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/UPCSizeofExpressionParser.java
@@ -20,6 +20,7 @@ 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.lpgextensions.FixedBacktrackingParser;
+import org.eclipse.cdt.core.dom.lrparser.action.ScopedStack;
import org.eclipse.cdt.core.dom.lrparser.action.ITokenMap;
import org.eclipse.cdt.core.dom.lrparser.action.TokenMap;
@@ -172,13 +173,16 @@ public class UPCSizeofExpressionParser extends PrsStream implements RuleAction ,
private UPCParserAction action;
+private ScopedStack<Object> astStack = new ScopedStack<Object>();
public UPCSizeofExpressionParser() { // constructor
}
private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
- action = new UPCParserAction ( UPCASTNodeFactory.DEFAULT_INSTANCE , this, tu);
+ action = new UPCParserAction ( UPCASTNodeFactory.DEFAULT_INSTANCE , this, tu, astStack);
action.setParserOptions(options);
+
+
}
@@ -206,13 +210,12 @@ public IASTCompletionNode parse(IASTTranslationUnit tu, Set<IParser.Options> opt
}
// uncomment this method to use with backtracking parser
-public List getRuleTokens() {
- return Collections.unmodifiableList(getTokens().subList(getLeftSpan(), getRightSpan() + 1));
+public List<IToken> getRuleTokens() {
+ return getTokens().subList(getLeftSpan(), getRightSpan() + 1);
}
-
public IASTNode getSecondaryParseResult() {
- return action.getSecondaryParseResult();
+ return (IASTNode) astStack.pop();
}
public String[] getOrderedTerminalSymbols() {
@@ -768,25 +771,25 @@ public UPCSizeofExpressionParser(String[] mapFrom) { // constructor
//
// Rule 158: storage_class_specifier ::= storage_class_specifier_token
//
- case 158: { action. consumeDeclSpecToken(); break;
+ case 158: { action. consumeToken(); break;
}
//
// Rule 164: simple_type_specifier ::= simple_type_specifier_token
//
- case 164: { action. consumeDeclSpecToken(); break;
+ case 164: { action. consumeToken(); break;
}
//
// Rule 177: typedef_name_in_declspec ::= Completion
//
- case 177: { action. consumeDeclSpecToken(); break;
+ case 177: { action. consumeToken(); break;
}
//
// Rule 178: typedef_name_in_declspec ::= identifier
//
- case 178: { action. consumeDeclSpecToken(); break;
+ case 178: { action. consumeToken(); break;
}
//
@@ -876,13 +879,13 @@ public UPCSizeofExpressionParser(String[] mapFrom) { // constructor
//
// Rule 214: type_qualifier ::= type_qualifier_token
//
- case 214: { action. consumeDeclSpecToken(); break;
+ case 214: { action. consumeToken(); break;
}
//
// Rule 218: function_specifier ::= inline
//
- case 218: { action. consumeDeclSpecToken(); break;
+ case 218: { action. consumeToken(); break;
}
//

Back to the top