Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/upc
diff options
context:
space:
mode:
authorMike Kucera2009-02-03 16:57:50 +0000
committerMike Kucera2009-02-03 16:57:50 +0000
commit75756374e344fd22c97f31308a3ec977c474b3ac (patch)
treecc96f2a4361e5b695519481b42c5b932720ff507 /upc
parentbd7f096c7c4469c98cea8692325267b63e269d43 (diff)
downloadorg.eclipse.cdt-75756374e344fd22c97f31308a3ec977c474b3ac.tar.gz
org.eclipse.cdt-75756374e344fd22c97f31308a3ec977c474b3ac.tar.xz
org.eclipse.cdt-75756374e344fd22c97f31308a3ec977c474b3ac.zip
improved several interfaces in LR parser
Diffstat (limited to 'upc')
-rw-r--r--upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/parser/upc/UPCParserAction.java10
-rw-r--r--upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/parser/upc/UPCSecondaryParserFactory.java7
-rw-r--r--upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/UPCLanguage.java10
-rw-r--r--upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/UPCExpressionParser.java53
-rw-r--r--upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/UPCNoCastExpressionParser.java53
-rw-r--r--upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/UPCParser.java51
-rw-r--r--upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/UPCSizeofExpressionParser.java53
7 files changed, 122 insertions, 115 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 40eeea6838c..aa5875b8375 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
@@ -11,13 +11,15 @@
package org.eclipse.cdt.core.dom.parser.upc;
-import static org.eclipse.cdt.internal.core.dom.parser.upc.UPCParsersym.*;
+import static org.eclipse.cdt.internal.core.dom.parser.upc.UPCParsersym.TK_Completion;
+import static org.eclipse.cdt.internal.core.dom.parser.upc.UPCParsersym.TK_relaxed;
+import static org.eclipse.cdt.internal.core.dom.parser.upc.UPCParsersym.TK_shared;
+import static org.eclipse.cdt.internal.core.dom.parser.upc.UPCParsersym.TK_strict;
import lpg.lpgjavaruntime.IToken;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier;
@@ -46,8 +48,8 @@ public class UPCParserAction extends C99BuildASTParserAction {
* @param parser
* @param tu
*/
- public UPCParserAction(IParserActionTokenProvider parser, IASTTranslationUnit tu, ScopedStack<Object> astStack, IUPCNodeFactory nodeFactory, ISecondaryParserFactory parserFactory) {
- super(parser, tu, astStack, nodeFactory, parserFactory);
+ public UPCParserAction(IParserActionTokenProvider parser, ScopedStack<Object> astStack, IUPCNodeFactory nodeFactory, ISecondaryParserFactory parserFactory) {
+ super(parser, astStack, nodeFactory, parserFactory);
this.nodeFactory = nodeFactory;
nodeFactory.setUseC99SizeofExpressions();
}
diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/parser/upc/UPCSecondaryParserFactory.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/parser/upc/UPCSecondaryParserFactory.java
index 50b85994963..216d356c470 100644
--- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/parser/upc/UPCSecondaryParserFactory.java
+++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/parser/upc/UPCSecondaryParserFactory.java
@@ -11,6 +11,7 @@
package org.eclipse.cdt.core.dom.parser.upc;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.lrparser.IParser;
import org.eclipse.cdt.core.dom.lrparser.IParserActionTokenProvider;
import org.eclipse.cdt.core.dom.lrparser.action.ISecondaryParserFactory;
@@ -26,15 +27,15 @@ public class UPCSecondaryParserFactory implements ISecondaryParserFactory{
return DEFAULT_INSTANCE;
}
- public IParser getExpressionParser(IParserActionTokenProvider parser) {
+ public IParser<IASTExpression> getExpressionParser(IParserActionTokenProvider parser) {
return new UPCExpressionParser(parser);
}
- public IParser getNoCastExpressionParser(IParserActionTokenProvider parser) {
+ public IParser<IASTExpression> getNoCastExpressionParser(IParserActionTokenProvider parser) {
return new UPCNoCastExpressionParser(parser);
}
- public IParser getSizeofExpressionParser(IParserActionTokenProvider parser) {
+ public IParser<IASTExpression> getSizeofExpressionParser(IParserActionTokenProvider parser) {
return new UPCSizeofExpressionParser(parser);
}
diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/UPCLanguage.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/UPCLanguage.java
index ea0cbda096e..605a50df3c7 100644
--- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/UPCLanguage.java
+++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/upc/UPCLanguage.java
@@ -49,7 +49,7 @@ public class UPCLanguage extends BaseExtensibleLanguage {
}
@Override
- public IParser getParser() {
+ public IParser<IASTTranslationUnit> getParser() {
return new UPCParser();
}
@@ -85,14 +85,6 @@ public class UPCLanguage extends BaseExtensibleLanguage {
return ParserLanguage.C;
}
- /**
- * Gets the translation unit object and sets the index and the location resolver.
- */
- @Override
- protected IASTTranslationUnit createASTTranslationUnit() {
- return CNodeFactory.getDefault().newTranslationUnit();
- }
-
@Override
protected IScannerExtensionConfiguration getScannerExtensionConfiguration() {
return ScannerExtensionConfiguration.createC();
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 c08adb8db51..eefb86977ec 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
@@ -37,7 +37,7 @@ import org.eclipse.cdt.core.dom.upc.ast.IUPCASTSynchronizationStatement;
import org.eclipse.cdt.core.dom.upc.ast.IUPCASTUnarySizeofExpression;
import org.eclipse.cdt.core.dom.lrparser.lpgextensions.FixedBacktrackingParser;
-public class UPCExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser
+public class UPCExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser< IASTExpression >
{
private static ParseTable prs = new UPCExpressionParserprs();
private FixedBacktrackingParser btParser;
@@ -128,22 +128,22 @@ public class UPCExpressionParser extends PrsStream implements RuleAction , IPars
super.reportError((firsttok > lasttok ? ParseErrorCodes.INSERTION_CODE : ParseErrorCodes.SUBSTITUTION_CODE), location, msg);
}
- public Object parser()
+ public void parser()
{
- return parser(null, 0);
+ parser(null, 0);
}
- public Object parser(Monitor monitor)
+ public void parser(Monitor monitor)
{
- return parser(monitor, 0);
+ parser(monitor, 0);
}
- public Object parser(int error_repair_count)
+ public void parser(int error_repair_count)
{
- return parser(null, error_repair_count);
+ parser(null, error_repair_count);
}
- public Object parser(Monitor monitor, int error_repair_count)
+ public void parser(Monitor monitor, int error_repair_count)
{
try
{
@@ -161,7 +161,7 @@ public class UPCExpressionParser extends PrsStream implements RuleAction , IPars
try
{
- return (Object) btParser.parse(error_repair_count);
+ btParser.parse(error_repair_count);
}
catch (BadParseException e)
{
@@ -169,19 +169,19 @@ public class UPCExpressionParser extends PrsStream implements RuleAction , IPars
DiagnoseParser diagnoseParser = new DiagnoseParser(this, prs);
diagnoseParser.diagnose(e.error_token);
}
-
- return null;
}
private UPCParserAction action;
-private ScopedStack<Object> astStack = new ScopedStack<Object>();
+private IASTCompletionNode compNode;
public UPCExpressionParser() { // constructor
}
-private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
- action = new UPCParserAction (this, tu, astStack, new UPCASTNodeFactory() , UPCSecondaryParserFactory.getDefault() );
+private void initActions(Set<IParser.Options> options) {
+ ScopedStack<Object> astStack = new ScopedStack<Object>();
+
+ action = new UPCParserAction (this, astStack, new UPCASTNodeFactory() , UPCSecondaryParserFactory.getDefault() );
action.setParserOptions(options);
@@ -194,20 +194,21 @@ public void addToken(IToken token) {
}
-public IASTCompletionNode parse(IASTTranslationUnit tu, Set<IParser.Options> options) {
+public IASTExpression parse(Set<IParser.Options> options) {
// this has to be done, or... kaboom!
setStreamLength(getSize());
- initActions(tu, options);
+ initActions(options);
final int errorRepairCount = -1; // -1 means full error handling
parser(null, errorRepairCount); // do the actual parse
super.resetTokenStream(); // allow tokens to be garbage collected
- // the completion node may be null
- IASTCompletionNode compNode = action.getASTCompletionNode();
+ compNode = action.getASTCompletionNode(); // the completion node may be null
+ return ( IASTExpression ) action.getParseResult();
+}
- //action = null;
- //parserAction = null;
+
+public IASTCompletionNode getCompletionNode() {
return compNode;
}
@@ -216,10 +217,6 @@ public List<IToken> getRuleTokens() {
return getTokens().subList(getLeftSpan(), getRightSpan() + 1);
}
-public IASTNode getSecondaryParseResult() {
- return (IASTNode) astStack.pop();
-}
-
public String[] getOrderedTerminalSymbols() {
return UPCExpressionParsersym.orderedTerminalSymbols;
}
@@ -789,6 +786,12 @@ public UPCExpressionParser(IParserActionTokenProvider parser) { // constructor
}
//
+ // Rule 178: type_name_specifier ::= identifier_token
+ //
+ case 178: { action. consumeToken(); break;
+ }
+
+ //
// Rule 179: struct_or_union_specifier ::= struct_or_union struct_or_union_specifier_hook { <openscope-ast> struct_declaration_list_opt }
//
case 179: { action. consumeTypeSpecifierComposite(false); break;
@@ -1259,7 +1262,7 @@ public UPCExpressionParser(IParserActionTokenProvider parser) { // constructor
//
// Rule 313: expression_parser_start ::= ERROR_TOKEN
//
- case 313: { action. consumeExpressionProblem(); break;
+ case 313: { action. consumeEmpty(); break;
}
//
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 8f2bb80f869..9e62301e284 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
@@ -37,7 +37,7 @@ import org.eclipse.cdt.core.dom.upc.ast.IUPCASTSynchronizationStatement;
import org.eclipse.cdt.core.dom.upc.ast.IUPCASTUnarySizeofExpression;
import org.eclipse.cdt.core.dom.lrparser.lpgextensions.FixedBacktrackingParser;
-public class UPCNoCastExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser
+public class UPCNoCastExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser< IASTExpression >
{
private static ParseTable prs = new UPCNoCastExpressionParserprs();
private FixedBacktrackingParser btParser;
@@ -128,22 +128,22 @@ public class UPCNoCastExpressionParser extends PrsStream implements RuleAction ,
super.reportError((firsttok > lasttok ? ParseErrorCodes.INSERTION_CODE : ParseErrorCodes.SUBSTITUTION_CODE), location, msg);
}
- public Object parser()
+ public void parser()
{
- return parser(null, 0);
+ parser(null, 0);
}
- public Object parser(Monitor monitor)
+ public void parser(Monitor monitor)
{
- return parser(monitor, 0);
+ parser(monitor, 0);
}
- public Object parser(int error_repair_count)
+ public void parser(int error_repair_count)
{
- return parser(null, error_repair_count);
+ parser(null, error_repair_count);
}
- public Object parser(Monitor monitor, int error_repair_count)
+ public void parser(Monitor monitor, int error_repair_count)
{
try
{
@@ -161,7 +161,7 @@ public class UPCNoCastExpressionParser extends PrsStream implements RuleAction ,
try
{
- return (Object) btParser.parse(error_repair_count);
+ btParser.parse(error_repair_count);
}
catch (BadParseException e)
{
@@ -169,19 +169,19 @@ public class UPCNoCastExpressionParser extends PrsStream implements RuleAction ,
DiagnoseParser diagnoseParser = new DiagnoseParser(this, prs);
diagnoseParser.diagnose(e.error_token);
}
-
- return null;
}
private UPCParserAction action;
-private ScopedStack<Object> astStack = new ScopedStack<Object>();
+private IASTCompletionNode compNode;
public UPCNoCastExpressionParser() { // constructor
}
-private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
- action = new UPCParserAction (this, tu, astStack, new UPCASTNodeFactory() , UPCSecondaryParserFactory.getDefault() );
+private void initActions(Set<IParser.Options> options) {
+ ScopedStack<Object> astStack = new ScopedStack<Object>();
+
+ action = new UPCParserAction (this, astStack, new UPCASTNodeFactory() , UPCSecondaryParserFactory.getDefault() );
action.setParserOptions(options);
@@ -194,20 +194,21 @@ public void addToken(IToken token) {
}
-public IASTCompletionNode parse(IASTTranslationUnit tu, Set<IParser.Options> options) {
+public IASTExpression parse(Set<IParser.Options> options) {
// this has to be done, or... kaboom!
setStreamLength(getSize());
- initActions(tu, options);
+ initActions(options);
final int errorRepairCount = -1; // -1 means full error handling
parser(null, errorRepairCount); // do the actual parse
super.resetTokenStream(); // allow tokens to be garbage collected
- // the completion node may be null
- IASTCompletionNode compNode = action.getASTCompletionNode();
+ compNode = action.getASTCompletionNode(); // the completion node may be null
+ return ( IASTExpression ) action.getParseResult();
+}
- //action = null;
- //parserAction = null;
+
+public IASTCompletionNode getCompletionNode() {
return compNode;
}
@@ -216,10 +217,6 @@ public List<IToken> getRuleTokens() {
return getTokens().subList(getLeftSpan(), getRightSpan() + 1);
}
-public IASTNode getSecondaryParseResult() {
- return (IASTNode) astStack.pop();
-}
-
public String[] getOrderedTerminalSymbols() {
return UPCNoCastExpressionParsersym.orderedTerminalSymbols;
}
@@ -783,6 +780,12 @@ public UPCNoCastExpressionParser(IParserActionTokenProvider parser) { // constr
}
//
+ // Rule 177: type_name_specifier ::= identifier_token
+ //
+ case 177: { action. consumeToken(); break;
+ }
+
+ //
// Rule 178: struct_or_union_specifier ::= struct_or_union struct_or_union_specifier_hook { <openscope-ast> struct_declaration_list_opt }
//
case 178: { action. consumeTypeSpecifierComposite(false); break;
@@ -1253,7 +1256,7 @@ public UPCNoCastExpressionParser(IParserActionTokenProvider parser) { // constr
//
// Rule 312: no_cast_start ::= ERROR_TOKEN
//
- case 312: { action. consumeExpressionProblem(); break;
+ case 312: { action. consumeEmpty(); break;
}
//
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 647b0482379..693ff8f0483 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
@@ -37,7 +37,7 @@ import org.eclipse.cdt.core.dom.upc.ast.IUPCASTSynchronizationStatement;
import org.eclipse.cdt.core.dom.upc.ast.IUPCASTUnarySizeofExpression;
import org.eclipse.cdt.core.dom.lrparser.lpgextensions.FixedBacktrackingParser;
-public class UPCParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser
+public class UPCParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser< IASTTranslationUnit >
{
private static ParseTable prs = new UPCParserprs();
private FixedBacktrackingParser btParser;
@@ -128,22 +128,22 @@ public class UPCParser extends PrsStream implements RuleAction , IParserActionTo
super.reportError((firsttok > lasttok ? ParseErrorCodes.INSERTION_CODE : ParseErrorCodes.SUBSTITUTION_CODE), location, msg);
}
- public Object parser()
+ public void parser()
{
- return parser(null, 0);
+ parser(null, 0);
}
- public Object parser(Monitor monitor)
+ public void parser(Monitor monitor)
{
- return parser(monitor, 0);
+ parser(monitor, 0);
}
- public Object parser(int error_repair_count)
+ public void parser(int error_repair_count)
{
- return parser(null, error_repair_count);
+ parser(null, error_repair_count);
}
- public Object parser(Monitor monitor, int error_repair_count)
+ public void parser(Monitor monitor, int error_repair_count)
{
try
{
@@ -161,7 +161,7 @@ public class UPCParser extends PrsStream implements RuleAction , IParserActionTo
try
{
- return (Object) btParser.parse(error_repair_count);
+ btParser.parse(error_repair_count);
}
catch (BadParseException e)
{
@@ -169,19 +169,19 @@ public class UPCParser extends PrsStream implements RuleAction , IParserActionTo
DiagnoseParser diagnoseParser = new DiagnoseParser(this, prs);
diagnoseParser.diagnose(e.error_token);
}
-
- return null;
}
private UPCParserAction action;
-private ScopedStack<Object> astStack = new ScopedStack<Object>();
+private IASTCompletionNode compNode;
public UPCParser() { // constructor
}
-private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
- action = new UPCParserAction (this, tu, astStack, new UPCASTNodeFactory() , UPCSecondaryParserFactory.getDefault() );
+private void initActions(Set<IParser.Options> options) {
+ ScopedStack<Object> astStack = new ScopedStack<Object>();
+
+ action = new UPCParserAction (this, astStack, new UPCASTNodeFactory() , UPCSecondaryParserFactory.getDefault() );
action.setParserOptions(options);
@@ -194,20 +194,21 @@ public void addToken(IToken token) {
}
-public IASTCompletionNode parse(IASTTranslationUnit tu, Set<IParser.Options> options) {
+public IASTTranslationUnit parse(Set<IParser.Options> options) {
// this has to be done, or... kaboom!
setStreamLength(getSize());
- initActions(tu, options);
+ initActions(options);
final int errorRepairCount = -1; // -1 means full error handling
parser(null, errorRepairCount); // do the actual parse
super.resetTokenStream(); // allow tokens to be garbage collected
- // the completion node may be null
- IASTCompletionNode compNode = action.getASTCompletionNode();
+ compNode = action.getASTCompletionNode(); // the completion node may be null
+ return ( IASTTranslationUnit ) action.getParseResult();
+}
- //action = null;
- //parserAction = null;
+
+public IASTCompletionNode getCompletionNode() {
return compNode;
}
@@ -216,10 +217,6 @@ public List<IToken> getRuleTokens() {
return getTokens().subList(getLeftSpan(), getRightSpan() + 1);
}
-public IASTNode getSecondaryParseResult() {
- return (IASTNode) astStack.pop();
-}
-
public String[] getOrderedTerminalSymbols() {
return UPCParsersym.orderedTerminalSymbols;
}
@@ -789,6 +786,12 @@ public UPCParser(IParserActionTokenProvider parser) { // constructor
}
//
+ // Rule 178: type_name_specifier ::= identifier_token
+ //
+ case 178: { action. consumeToken(); break;
+ }
+
+ //
// Rule 179: struct_or_union_specifier ::= struct_or_union struct_or_union_specifier_hook { <openscope-ast> struct_declaration_list_opt }
//
case 179: { action. consumeTypeSpecifierComposite(false); 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 6ff22d291a6..570dc6feb68 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
@@ -37,7 +37,7 @@ import org.eclipse.cdt.core.dom.upc.ast.IUPCASTSynchronizationStatement;
import org.eclipse.cdt.core.dom.upc.ast.IUPCASTUnarySizeofExpression;
import org.eclipse.cdt.core.dom.lrparser.lpgextensions.FixedBacktrackingParser;
-public class UPCSizeofExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser
+public class UPCSizeofExpressionParser extends PrsStream implements RuleAction , IParserActionTokenProvider, IParser< IASTExpression >
{
private static ParseTable prs = new UPCSizeofExpressionParserprs();
private FixedBacktrackingParser btParser;
@@ -128,22 +128,22 @@ public class UPCSizeofExpressionParser extends PrsStream implements RuleAction ,
super.reportError((firsttok > lasttok ? ParseErrorCodes.INSERTION_CODE : ParseErrorCodes.SUBSTITUTION_CODE), location, msg);
}
- public Object parser()
+ public void parser()
{
- return parser(null, 0);
+ parser(null, 0);
}
- public Object parser(Monitor monitor)
+ public void parser(Monitor monitor)
{
- return parser(monitor, 0);
+ parser(monitor, 0);
}
- public Object parser(int error_repair_count)
+ public void parser(int error_repair_count)
{
- return parser(null, error_repair_count);
+ parser(null, error_repair_count);
}
- public Object parser(Monitor monitor, int error_repair_count)
+ public void parser(Monitor monitor, int error_repair_count)
{
try
{
@@ -161,7 +161,7 @@ public class UPCSizeofExpressionParser extends PrsStream implements RuleAction ,
try
{
- return (Object) btParser.parse(error_repair_count);
+ btParser.parse(error_repair_count);
}
catch (BadParseException e)
{
@@ -169,19 +169,19 @@ public class UPCSizeofExpressionParser extends PrsStream implements RuleAction ,
DiagnoseParser diagnoseParser = new DiagnoseParser(this, prs);
diagnoseParser.diagnose(e.error_token);
}
-
- return null;
}
private UPCParserAction action;
-private ScopedStack<Object> astStack = new ScopedStack<Object>();
+private IASTCompletionNode compNode;
public UPCSizeofExpressionParser() { // constructor
}
-private void initActions(IASTTranslationUnit tu, Set<IParser.Options> options) {
- action = new UPCParserAction (this, tu, astStack, new UPCASTNodeFactory() , UPCSecondaryParserFactory.getDefault() );
+private void initActions(Set<IParser.Options> options) {
+ ScopedStack<Object> astStack = new ScopedStack<Object>();
+
+ action = new UPCParserAction (this, astStack, new UPCASTNodeFactory() , UPCSecondaryParserFactory.getDefault() );
action.setParserOptions(options);
@@ -194,20 +194,21 @@ public void addToken(IToken token) {
}
-public IASTCompletionNode parse(IASTTranslationUnit tu, Set<IParser.Options> options) {
+public IASTExpression parse(Set<IParser.Options> options) {
// this has to be done, or... kaboom!
setStreamLength(getSize());
- initActions(tu, options);
+ initActions(options);
final int errorRepairCount = -1; // -1 means full error handling
parser(null, errorRepairCount); // do the actual parse
super.resetTokenStream(); // allow tokens to be garbage collected
- // the completion node may be null
- IASTCompletionNode compNode = action.getASTCompletionNode();
+ compNode = action.getASTCompletionNode(); // the completion node may be null
+ return ( IASTExpression ) action.getParseResult();
+}
- //action = null;
- //parserAction = null;
+
+public IASTCompletionNode getCompletionNode() {
return compNode;
}
@@ -216,10 +217,6 @@ public List<IToken> getRuleTokens() {
return getTokens().subList(getLeftSpan(), getRightSpan() + 1);
}
-public IASTNode getSecondaryParseResult() {
- return (IASTNode) astStack.pop();
-}
-
public String[] getOrderedTerminalSymbols() {
return UPCSizeofExpressionParsersym.orderedTerminalSymbols;
}
@@ -783,6 +780,12 @@ public UPCSizeofExpressionParser(IParserActionTokenProvider parser) { // constr
}
//
+ // Rule 177: type_name_specifier ::= identifier_token
+ //
+ case 177: { action. consumeToken(); break;
+ }
+
+ //
// Rule 178: struct_or_union_specifier ::= struct_or_union struct_or_union_specifier_hook { <openscope-ast> struct_declaration_list_opt }
//
case 178: { action. consumeTypeSpecifierComposite(false); break;
@@ -1253,7 +1256,7 @@ public UPCSizeofExpressionParser(IParserActionTokenProvider parser) { // constr
//
// Rule 312: no_sizeof_type_id_start ::= ERROR_TOKEN
//
- case 312: { action. consumeExpressionProblem(); break;
+ case 312: { action. consumeEmpty(); break;
}
//

Back to the top