• 大小: 1.21MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-11-04
  • 语言: C#
  • 标签: 编译  课程设计  

资源简介

实现的功能: (1)选定一文法,选定一种分析方法(自上而下、自下而上) (2)允许用户输入语句并对该语句进行相应的语法分析 (3)要求显示语法树的建立过程以及跟踪分析表和分析栈的状态 (4)要提供单步运行,让用户跟踪分析器工作的每一个步骤 。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace zhengjie_LL_1_
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void listBox3_SelectedIndexChanged(object sender EventArgs e)
        {

        }

        private void listBox2_SelectedIndexChanged(object sender EventArgs e)
        {

        }
        #region 相关初始量(都是全局的)
        public string[] mystring = { “TE‘“ “FALSE“ “FALSE“ “TE‘“ “FALSE“ “FALSE“ “FALSE“ “TE‘“ “FALSE“ “FALSE“ “ε“ “ε“ “FT‘“ “FALSE“ “FALSE“ “FT‘“ “FALSE“ “FALSE“ “FALSE“ “ε“ “*FT‘“ “FALSE“ “ε“ “ε“ “id“ “FALSE“ “FALSE“ “(E)“ “FALSE“ “FALSE“ };
        public string[] Terminal = { “id“ “+“ “*“ “(“ “)“ “&“ };
        public string[] unTerminal = { “E“ “E‘“ “T“ “T‘“ “F“ };
        private Stack MyStack = new Stack();
        private Stack MyInputstack = new Stack();
        public string[] Term = { “id“ “+“ “*“ “(“ “)“ “&“ };
        public string[] unTerm = { “E“ “E‘“ “T“ “T‘“ “F“ };
        private int line row;
        #endregion 
        private void 开始_Click(object sender EventArgs e)
        {
            if (Input_richTextBox1.Text == ““)
            {
                MessageBox.Show(“请输入要分析的字符串!“);
            }
            else
            {
                MyStack.Push(“&“);
                MyStack.Push(“E“);
            
                MyStack_listBox1.Items.Add(“&E“);

                MyInput_listBox2.Items.Add(Input_richTextBox1.Text + “&“);
                MyInputstack.Push(“&“);
                for (int i = Input_richTextBox1.Text.Length - 1; i >= 0; i--)
                {
                    MyInputstack.Push(Input_richTextBox1.Text[i]);
                }
            }
            //myoutput_richTextBox4.Items.Add(““);
        }

        private void 下一步_Click(object sender EventArgs e)
        {
            string MyStackTop MyStackInputTop;
            //object Top = new object();
            MyStackTop = MyStack.Peek().ToString();
            MyStackInputTop = MyInputstack.Peek().ToString();
            MyStackTopOne(MyStackTopMyStackInputTop );
            if (MyStackTopOne(MyStackTop))
            { 

            
            }

         
        }
#region 状态栈是终结符的情况
       public bool   MyStackTopOne(string stack  )
        {
            bool   symbol = false ;
          for (int i = 0; i < Term.Length; i++)
          {
              if (stack == Term[i])
              {
                  symbol = true ;
                  break;
              }
            }
            return symbol;
            //if (symbol == 1)
            //{ 
            //if (stack == input)
            //{
            //    if (stack == “&“)
       

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        932  2009-06-25 12:26  zhengjie_LL(1)\zhengjie_LL(1).sln

    ..A..H.     17408  2009-09-17 19:40  zhengjie_LL(1)\zhengjie_LL(1).suo

     文件      20273  2009-06-28 22:39  zhengjie_LL(1)\zhengjie_LL(1)\Form1.Designer.cs

     文件     381942  2009-06-25 16:08  zhengjie_LL(1)\zhengjie_LL(1)\Resources\LL(1).bmp

     文件     360422  2009-06-25 16:10  zhengjie_LL(1)\zhengjie_LL(1)\Resources\LL(1)1.bmp

     文件      92830  2009-06-25 16:38  zhengjie_LL(1)\zhengjie_LL(1)\Resources\5.jpg

     文件     590038  2009-06-25 16:52  zhengjie_LL(1)\zhengjie_LL(1)\Resources\LL(1)2.bmp

     文件       8958  2009-06-28 22:41  zhengjie_LL(1)\zhengjie_LL(1)\Form1.cs

     文件        473  2009-06-25 09:52  zhengjie_LL(1)\zhengjie_LL(1)\Program.cs

     文件       5126  2009-06-25 16:53  zhengjie_LL(1)\zhengjie_LL(1)\zhengjie_LL(1).csproj

     文件    1473536  2009-06-28 22:41  zhengjie_LL(1)\zhengjie_LL(1)\bin\Debug\zhengjie_LL(1).exe

     文件      42496  2009-06-28 22:41  zhengjie_LL(1)\zhengjie_LL(1)\bin\Debug\zhengjie_LL(1).pdb

     文件      14328  2009-09-17 19:40  zhengjie_LL(1)\zhengjie_LL(1)\bin\Debug\zhengjie_LL(1).vshost.exe

     文件        490  2007-07-21 01:33  zhengjie_LL(1)\zhengjie_LL(1)\bin\Debug\zhengjie_LL(1).vshost.exe.manifest

     文件        317  2009-06-25 11:27  zhengjie_LL(1)\zhengjie_LL(1)\obj\zhengjie_LL(1).csproj.FileList.txt

     文件    1473536  2009-06-28 22:41  zhengjie_LL(1)\zhengjie_LL(1)\obj\Debug\zhengjie_LL(1).exe

     文件      28640  2009-06-28 22:39  zhengjie_LL(1)\zhengjie_LL(1)\obj\Debug\zhengjie_LL_1_.Form1.resources

     文件    1427291  2009-06-25 16:53  zhengjie_LL(1)\zhengjie_LL(1)\obj\Debug\zhengjie_LL_1_.Properties.Resources.resources

     文件       5120  2009-06-25 16:52  zhengjie_LL(1)\zhengjie_LL(1)\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll

     文件       1922  2009-09-17 19:40  zhengjie_LL(1)\zhengjie_LL(1)\obj\Debug\zhengjie_LL(1).csproj.FileListAbsolute.txt

     文件      42496  2009-06-28 22:41  zhengjie_LL(1)\zhengjie_LL(1)\obj\Debug\zhengjie_LL(1).pdb

     文件       1001  2009-06-28 22:39  zhengjie_LL(1)\zhengjie_LL(1)\obj\Debug\zhengjie_LL(1).csproj.GenerateResource.Cache

     文件       1182  2009-06-25 09:52  zhengjie_LL(1)\zhengjie_LL(1)\Properties\AssemblyInfo.cs

     文件       3845  2009-06-25 16:52  zhengjie_LL(1)\zhengjie_LL(1)\Properties\Resources.Designer.cs

     文件       1112  2009-06-25 12:26  zhengjie_LL(1)\zhengjie_LL(1)\Properties\Settings.Designer.cs

     文件        249  2009-06-25 09:52  zhengjie_LL(1)\zhengjie_LL(1)\Properties\Settings.settings

     文件       6913  2009-06-25 16:52  zhengjie_LL(1)\zhengjie_LL(1)\Properties\Resources.resx

     文件      48333  2009-06-28 22:39  zhengjie_LL(1)\zhengjie_LL(1)\Form1.resx

     文件        931  2009-06-25 11:28  zhengjie_LL(1)\zhengjie_LL(1)\Backup\zhengjie_LL(1).sln

    ..A..H.     14848  2009-06-25 11:29  zhengjie_LL(1)\zhengjie_LL(1)\Backup\zhengjie_LL(1).suo

............此处省略93个文件信息

评论

共有 条评论