diff options
author | Jeffrey Overbey | 2005-11-04 20:38:55 +0000 |
---|---|---|
committer | Jeffrey Overbey | 2005-11-04 20:38:55 +0000 |
commit | 67530d5fe0c358a3f006f8915aa35aad8a82fd0a (patch) | |
tree | 972b861e8501617180d43ddb8cd5b390ae43c493 | |
parent | 04b5b738b91fe6622a5e3d7f83600ad2638c264a (diff) | |
download | org.eclipse.photran-67530d5fe0c358a3f006f8915aa35aad8a82fd0a.tar.gz org.eclipse.photran-67530d5fe0c358a3f006f8915aa35aad8a82fd0a.tar.xz org.eclipse.photran-67530d5fe0c358a3f006f8915aa35aad8a82fd0a.zip |
Implicit declarations added to symbol table
3 files changed, 25 insertions, 4 deletions
diff --git a/org.eclipse.photran.core/parser/org/eclipse/photran/internal/core/f95parser/symboltable/ReferenceCollector.java b/org.eclipse.photran.core/parser/org/eclipse/photran/internal/core/f95parser/symboltable/ReferenceCollector.java index e2ae61ad..946d5011 100644 --- a/org.eclipse.photran.core/parser/org/eclipse/photran/internal/core/f95parser/symboltable/ReferenceCollector.java +++ b/org.eclipse.photran.core/parser/org/eclipse/photran/internal/core/f95parser/symboltable/ReferenceCollector.java @@ -9,6 +9,7 @@ import org.eclipse.photran.internal.core.f95parser.ParseTreeVisitor; import org.eclipse.photran.internal.core.f95parser.SemanticError; import org.eclipse.photran.internal.core.f95parser.Terminal; import org.eclipse.photran.internal.core.f95parser.Token; +import org.eclipse.photran.internal.core.f95parser.symboltable.entries.VariableEntry; /** * This should be called after creating an initial symbol table hierarchy via a @@ -107,9 +108,14 @@ final class ReferenceCollector extends ParseTreeVisitor SymbolTableEntry entry = getCurrentParent().getEntryInHierarchyFor(token.getText()); if (entry != null) entry.addReference(token); - else if (getCurrentParent().getImplicitSpec() == null) - throw new SemanticError(token, token.getText() - + " is used but not defined in an \"implicit none\" context"); + else if (getCurrentParent().isImplicitNone()) + throw new SemanticError(token, token.getText() + " is used but not defined in an \"implicit none\" context"); + else // implicitly-declared variable + { + VariableEntry newEntry = new VariableEntry(getCurrentParent(), token, token.getParent()); + newEntry.setImplicitDeclared(true); + getCurrentParent().addEntry(newEntry); + } } //--VISITOR METHODS------------------------------------------------- diff --git a/org.eclipse.photran.core/parser/org/eclipse/photran/internal/core/f95parser/symboltable/SymbolTable.java b/org.eclipse.photran.core/parser/org/eclipse/photran/internal/core/f95parser/symboltable/SymbolTable.java index a8c0eb4d..c6970f34 100644 --- a/org.eclipse.photran.core/parser/org/eclipse/photran/internal/core/f95parser/symboltable/SymbolTable.java +++ b/org.eclipse.photran.core/parser/org/eclipse/photran/internal/core/f95parser/symboltable/SymbolTable.java @@ -65,6 +65,11 @@ public class SymbolTable { return implicitSpec; } + + public boolean isImplicitNone() + { + return implicitSpec == null; + } /** * Sets the IMPLICIT specification for this symbol table: either a valid diff --git a/org.eclipse.photran.core/parser/org/eclipse/photran/internal/core/f95parser/symboltable/entries/VariableEntry.java b/org.eclipse.photran.core/parser/org/eclipse/photran/internal/core/f95parser/symboltable/entries/VariableEntry.java index 5f4f2907..d2a56d3e 100644 --- a/org.eclipse.photran.core/parser/org/eclipse/photran/internal/core/f95parser/symboltable/entries/VariableEntry.java +++ b/org.eclipse.photran.core/parser/org/eclipse/photran/internal/core/f95parser/symboltable/entries/VariableEntry.java @@ -25,7 +25,7 @@ public class VariableEntry extends SymbolTableEntry && correspondingParseTreeNode.getRootNonterminal() != Nonterminal.XNAME && correspondingParseTreeNode.getRootNonterminal() != Nonterminal.XSUBROUTINEPAR && correspondingParseTreeNode.getRootNonterminal() != Nonterminal.XOBJECTNAME) - throw new SymbolTableError("The ParseTreeNode passed to the VariableEntry constructor should be one of the following: xComponentName, xFunctionPar, xName (if in the RESULT clause of a function), xSubroutinePar, xObjectName"); + throw new SymbolTableError("The ParseTreeNode passed to the VariableEntry constructor should be one of the following: xComponentName, xFunctionPar, xName (if IMPLICIT or in the RESULT clause of a function), xSubroutinePar, xObjectName"); } public String getTypeDescription() @@ -83,4 +83,14 @@ public class VariableEntry extends SymbolTableEntry { this.isFunctionOrSubroutineParameter = isFunctionOrSubroutineParameter; } + + private boolean isImplicit = false; + public boolean isImplicitlyDeclared() + { + return isImplicit; + } + public void setImplicitDeclared(boolean isImplicit) + { + this.isImplicit = isImplicit; + } } |