int enterTconst(char *id, int v) /* It records an integer constant and its value in the name table. */ { enterT(id); nameTable[tIndex].kind = constId; nameTable[tIndex].u.value = v; return tIndex; }
int enterTcharConst(char *id, int ch) /* It records a character constant and its character in the name table. */ { enterT(id); nameTable[tIndex].kind = constCharId; nameTable[tIndex].u.value = ch; return tIndex; }
/* 名前表に定数名とその値を登録 */ int enterTconst(char *id, int v) { enterT(id); nameTable[tIndex].kind = constId; nameTable[tIndex].u.value = v; return tIndex; }
int enterTpar(char *id) /* It records parameters in the name table. */ { enterT(id); nameTable[tIndex].kind = parId; nameTable[tIndex].u.raddr.level = level; nameTable[tfIndex].u.f.pars++; /* It updates the number of parameters. */ return tIndex; }
int enterTvar(char *id) /* It records a variable name in the name table. */ { enterT(id); nameTable[tIndex].kind = varId; nameTable[tIndex].u.raddr.level = level; nameTable[tIndex].u.raddr.addr = localAddr++; return tIndex; }
/* 名前表に変数名を登録 */ int enterTvar(char *id) { enterT(id); nameTable[tIndex].kind = varId; nameTable[tIndex].u.raddr.level = level; nameTable[tIndex].u.raddr.addr = localAddr++; return tIndex; }
/* 名前表にパラメタ名を登録 */ int enterTpar(char *id) { enterT(id); nameTable[tIndex].kind = parId; nameTable[tIndex].u.raddr.level = level; nameTable[tfIndex].u.f.pars++; /* 関数のパラメタ数のカウント */ return tIndex; }
int enterTfunc(char *id, int v) /* It records the name and the starting address of a function in the name table. */ { enterT(id); nameTable[tIndex].kind = funcId; nameTable[tIndex].u.f.raddr.level = level; nameTable[tIndex].u.f.raddr.addr = v; /* The starting address of a function */ nameTable[tIndex].u.f.pars = 0; /* The initial number of parameters */ tfIndex = tIndex; return tIndex; }
/* 名前表に関数や手続きを登録 */ static int enterTsequence(char *id, int v, KindT kind) { enterT(id); nameTable[tIndex].kind = kind; nameTable[tIndex].u.f.raddr.level = level; nameTable[tIndex].u.f.raddr.addr = v; /* 関数の先頭番地 */ nameTable[tIndex].u.f.pars = 0; /* パラメタ数の初期値 */ tfIndex = tIndex; return tIndex; }
int enterTarrayConst(char *id, int arr[], int arrSize) { int i; enterT(id); nameTable[tIndex].kind = constArrayId; nameTable[tIndex].u.array[0] = arrSize; for (i = 1; i < arrSize + 1; ++i) { nameTable[tIndex].u.array[i] = arr[i - 1]; } return tIndex; }