Ejemplo n.º 1
0
        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;
                }
            }
        }
Ejemplo n.º 2
0
    bool emg;       // Does the grid need to emerge?

    public void InitializeDisplay()
    {
        ldatabase   = GameObject.FindGameObjectWithTag("Level Database").GetComponent <LevelDatabase>();
        GUC         = GameObject.Find("Canvas").transform.FindChild("Game UI").GetComponent <GameUIControl>();
        ruleDisplay = GameObject.Find("Canvas").transform.FindChild("Game UI/Rules Panel/Rules Container Panel").GetComponent <RuleDisplay>();

        sounds  = GetComponents <AudioSource>();
        explode = sounds[0];
        ding    = sounds[1];

        levelnumber  = 0;
        currentlevel = ldatabase.levels[levelnumber];
        answerKey    = currentlevel.levAnswerKey;
        wallList     = currentlevel.levWalls;
        gamegrid     = currentlevel.levGameGrid;

        levCol = currentlevel.levCol;
        levRow = currentlevel.levRow;

        MAX = GlobalControl.control.NumOfLevels;

        drawLevel = true;
    }