private void OpenFile_Click(object sender, EventArgs e) { OpenFileDialog fileName = new OpenFileDialog(); fileName.InitialDirectory = Application.StartupPath; fileName.Filter = "txt files (*.txt)|*.txt"; fileName.FilterIndex = 1; fileName.RestoreDirectory = true; if (fileName.ShowDialog() == DialogResult.OK) { //MessageBox.Show("OK"); string path = fileName.FileName.ToString(); backEnd = new LALR1(path); Dictionary <string, List <string> > rule = backEnd.GetRuleSet(); RuleDisplay.Clear(); if (rule == null) { MessageBox.Show("LALR1运行失败,输入的规则式有问题"); } else { foreach (string key in rule.Keys) { foreach (string showRule in rule[key]) { RuleDisplay.AppendText(key + "->" + showRule + "\r\n"); } } backEnd.SolveFirstSet(); backEnd.SolveFollowSet(); backEnd.BuildLR1ForView(); backEnd.ConvertLR1ToLALR1(); isSyntaxValid = backEnd.BuildTable(); MessageBox.Show("输入的规则式合法"); GetLR0.Enabled = true; } } }
public void InputAlorithm(LALR1 al) { alogrithm = al; }