using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace byyljxfzxt
{
    public partial class Form4 : Form
    {
        // ... (其他代码)

       private void button8_Click(object sender, EventArgs e)
        {
            // 在界面第二行之后展示步骤、分析串、剩余输入串、推导所用产生式或匹配
            //点一下按钮对应出来一行结果
            if (step >= result_parse.Count) return; // 如果已经分析结束,不再展示

            ListViewItem item = new ListViewItem((step + 1).ToString()); // 步骤
            item.SubItems.Add(new string(result_analys[step].Reverse().ToArray())); // 分析串
            item.SubItems.Add(new string(result_input[step].Reverse().ToArray())); // 剩余输入串
            item.SubItems.Add(result_parse[step]); // 推导所用产生式或匹配
            listView4.Items.Add(item);

            step++; // 步骤加一
        }

        private void button9_Click(object sender, EventArgs e)
        {
            // 自动分析直到分析结束
            button8.Enabled = false;
            button9.Enabled = false;

            while (step < result_parse.Count)
            {
                ListViewItem item = new ListViewItem((step + 1).ToString()); // 步骤
                item.SubItems.Add(new string(result_analys[step].Reverse().ToArray())); // 分析串
                item.SubItems.Add(new string(result_input[step].Reverse().ToArray())); // 剩余输入串
                item.SubItems.Add(result_parse[step]); // 推导所用产生式或匹配
                listView4.Items.Add(item);

                step++; // 步骤加一
            }
        }

        // ... (其他代码)
    }
}
C# LL(1)语法分析器逐步分析功能实现

原文地址: https://www.cveoy.top/t/topic/fXPq 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录