Esempio n. 1
0
 private void TabPreprocess_Enter(object sender, EventArgs e)
 {
     listBoxFirst.Items.Clear();
     listBoxFollow.Items.Clear();
     if (_grammarRules == null)
     {
         MessageBox.Show("Grammar File is empty");
         return;
     }
     _preprocessor = new Preprocessor(_grammarRules);
     RestartStopWatch();
     _preprocessor.CalculateAllFirsts();
     _preprocessor.CalculateAllFollows();
     _stopwatch.Stop();
     lblTime.Text = $"First and follow calculation took {_stopwatch.ElapsedMilliseconds} ms.";
     foreach (ISymbol symbol in _grammarRules.SymbolList)
     {
         if (symbol is Variable variable)
         {
             listBoxFirst.Items.Add(variable.ShowFirsts());
             listBoxFollow.Items.Add(variable.ShowFollows());
         }
     }
 }