2 つの別個のクラス (文字列変数を含むヘッダー ノードと整数値を含むリンク ノード) のリンク リストに格納されている変数を出力しようとしています。シンボルが見つからないというエラーが表示されます。
何が問題なのかわかりません。さらに情報が必要な場合はお知らせください。
完全なコードは次のとおりです。
package symboltable;
public class SymbolTable {
IdentifierHeaderNode[] table = new IdentifierHeaderNode[50];
IdentifierHeaderNode ptr;
public SymbolTable(){
for(int x = 0; x <= 49; x++)
}
public void addIdentifier(String info, int lineNumber){
LineNode ptr;
LineNode newNode;
boolean found = false;
int y = 0;
int x = 0;
//Look for Identifier In Array If Found, Add New Node to End
while(table[y] != null && !found){
if (table[y].info.equals(info)){
newNode = new LineNode (lineNumber, null);
found = true;
}
else
y++;
}
//If Identifier Not Found, Create New Identifier and Add Node to End
IdentifierHeaderNode ident1;
if(found == false){
newNode = new LineNode (lineNumber, null);
ident1 = new IdentifierHeaderNode();
//Add New Identifier to Table
while(!found && x <= 50){
if (table[x] == null){
table[x] = ident1;
found = true;
}
else
x = x + 1;
}
}
}
public void print(){
System.out.println("Symbol Table");
System.out.println("------------------------------------------------");
System.out.println("Identifier Name \t Line Appears On");
int x = 0;
boolean end = false;
while(table[x] != null &&!end){
System.out.print(table[x].info);
System.out.println( table[x].lineNumber);
}
}
}
エラーの場所は次のとおりです。
if (table[y].info.equals(info))
System.out.print(table[x].info);
System.out.println( table[x].lineNumber);
それぞれが「シンボルが見つかりません」と言っています。これらの変数は、それぞれのクラスで宣言されています。
IdentifierHeaderNode クラス: パッケージ シンボルテーブル;
public class IdentifierHeaderNode {
public static String info;
public LineNode first;
public IdentifierHeaderNode(){
}
public IdentifierHeaderNode (String info, LineNode node){
this.info = info;
first = node;
}
public String getInfo(){
return info;
}
}