private void button7_Clickobject sender EventArgs e string text = textBox1Text; 初始化分析栈和输入栈 analyseStack = new Stackchar; inputStack = new Stackchar
可能是分析表中没有对应的产生式,需要检查分析表中是否包含所有的终结符和非终结符的组合。可以在代码中添加以下检查:
if (!table.ContainsKey(topAnalyse.ToString()) || !table[topAnalyse.ToString()].ContainsKey(topInput.ToString())) { resultParse.Add("出错"); break; } else { string production = table[topAnalyse.ToString()][topInput.ToString()]; //... }
原文地址: http://www.cveoy.top/t/topic/g8OY 著作权归作者所有。请勿转载和采集!