嘿伙计们,我的程序有问题,我正在尝试使用多重映射读取将多个右手规则放入左手规则的语法。问题是,假设规则是: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);
}
}