int main( void )
{
/*    freopen("in.txt", "r", stdin);*/
    freopen("out.txt", "w", stdout);

    HashTable * H = ( HashTable * )malloc( MAX * sizeof ( HashTable ) );
    int key, temp;

    InitTable( &H );
    InTable( &H );

    while ( scanf("%d", &key) != EOF )
    {
        if ( 0 == key )
            break;

        temp = Search( &H, key );
        if ( temp == ERROR )
            printf("查找失败!元素%d不存在于该表中.\n", key);
        else
            printf("查找成功!元素%d位于表中的第%2d位置.\n", key, temp + 1);
    }

    return 0;
}
/* add a new symbol to table */
void AddEntry(char symbol, char type)
{
    if (InTable(symbol)) {
        Duplicate(symbol);
    }
    ST[symbol-'A'] = type;
}
void Store(char* Name) {
  if(!InTable(Name)) {
    Undefined(Name);
  }
  sprintf(tmp, "mov [%s], rax", Name);
  EmitLn(tmp);
}
void LoadVar(char* Name) {
  if(!InTable(Name)) {
    Undefined(Name);
  }
  sprintf(tmp, "mov rax, [%s]", Name);
  EmitLn(tmp);
}
/* check an entry to make sure it's a variable */
void CheckVar(char name)
{
    char tmp_buf[MAX_BUF];
    if (!InTable(name)) {
        Undefined(name);
    }
    if (TypeOf(name) != 'v') {
        sprintf(tmp_buf, "%c is not a variable", name);
        Abort(tmp_buf);
    }
}
Beispiel #6
0
void RoutesPage::Remove(const char *name)
{
	GPXRow *row;

	/* make sure point is not already in the route */
	row=InTable(name);
	if(!row)
		return;

	/* hmmm, should this be true? */
	m_routewptable.DeleteRow(row,false);
	Changed();
}
void AddEntry(char *ident)
{
	char msg[MAXMSG];
	if ( InTable(ident) ) {
		snprintf(msg, MAXMSG,
		    "Dupe variable declaration : \'%s\'", ident);
		Abort(msg);
	}

	if ( NumSymbols == MAXENTRY ) {
		Abort("Symbol table full");
	}

	strncpy( SymTable[NumSymbols], ident, MAXNAME);
	NumSymbols++;
}
void Alloc(char* Name) {
  if(InTable(Name)) {
    sprintf(tmp, "Duplicate Variable Name %s", Name);
    Abort(tmp);
  }
  AddEntry(Name, 'v');
  printf( "%s:	DQ ", Name);
  if(Look == '=') {
    Match('=');
    if(Look == '-') {
      printf("-");
      Match('-');
    }
    printf("%d\n", GetNum());
  }
  else {
    printf("0\n");
  }

}