2
嘿傢伙我有一個問題與我的程序,我想閱讀一個語法,把多個右手規則放在使用多映射的左手規則中。問題是,讓我們說規則是: a - > al be ze 它映射[a,al]並忽略其餘部分。 只留下密鑰,我想把不同的屬性,以該鍵。 想知道你們是否可以發現我似乎找不到的錯誤。 我是否正確使用多重映射? 謝謝。使用多映射
map<string, string> rule; // global var
void righthandside(){ // get rhs of grammar rule
char c;
skipSpace();
c = getchar();
if(isalpha(c)){
checkforE = false; // rule not epsilon
while(isalnum(c)){
righths += c;
c = getchar();
}
righths += '\0';
rule.insert(pair<string, string>(LHS[lhs], righths));
righths.clear();
righthandside();
}
else if(c == '#'){
if(checkforE == true)
rule.insert(pair<string, string>(LHS[lhs], epsilon)); // rule states NT goes to epsilon
skipSpace();
c = getchar();
if(c == '#'){ //end of file
cout << "end of file \n";
}
else{ // end of rule
ungetc(c, stdin);
lhs++;
readGR();
}
}
else{
errorcode(0);
}
}