• 大小: 112KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-06-30
  • 语言: C#
  • 标签: 编译原理  C#  

资源简介

用C#编写的语法分析器,可以自上而下进行语法分析,进行LL(1)分析

资源截图

代码片段和文件信息

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

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

        private void button3_Click(object sender EventArgs e)
        {
            pictureBox1.Visible = true;
        }

        private void button4_Click(object sender EventArgs e)
        {
            DialogResult ret;
            ret = MessageBox.Show(“确定要退出吗?“
                                  “退出“
                                  MessageBoxButtons.OKCancel
                                  MessageBoxIcon.Question
                                  MessageBoxDefaultButton.Button2);

            if (ret == DialogResult.OK)
            {
                this.Close();
            }
        }

        private void label13_Click(object sender EventArgs e)
        {

        }
        #region 相关初始量(都是全局的)
        public string[] term = { “(“ “i“ “+“ “-“ “*“ “/“ “)“ “#“ };
        public string[] unterm = { “E“ “T“ “G“ “S“ “F“ };
        Stack MyStack = new Stack();
        Stack InputStack = new Stack(); 
        public bool con = true;
        string MyNowString;
        public int line row;
        public string[] mystring = { { “TG“ “TG“ ““ ““ ““ ““ ““ ““ } { “FS“ “FS“ ““ ““ ““ ““ ““ ““ } { ““ ““ “+TG“ “-TG“ ““ ““ “ε“ “ε“ } { ““ ““ “ε“ “ε“ “*FS“ “/FS“ ““ “ε“ } { “(E)“ “i“ ““ ““ ““ ““ ““ ““ } };
        #endregion
        private void button1_Click(object sender EventArgs e)
        {
            if (richTextBox1.Text == ““)
            {
                MessageBox.Show(“请输入要分析的字符串“);
            }
            else
            {
                //this.Output_listBox3.Items.Add(“E->TG“);
                MyStack.Push(“#“);
                MyStack.Push(“E“);
                MyStack_listBox1.Items.Add(“#E“);
                Input_listBox2.Items.Add(richTextBox1.Text + “#“);
                InputStack.Push(“#“);
                for (int i = richTextBox1.Text.Length - 1; i >= 0; i--)
                {
                    InputStack.Push(richTextBox1.Text[i]);
                }
                button1.Enabled = false;
            }
        }

        private void button5_Click(object sender EventArgs e)
        {
            int loc;
            string MyStackTop MyStackInputTop;

            MyStackTop = MyStack.Peek().ToString();
            MyStackInputTop = InputStack.Peek().ToString();
            MyStackTopOne(MyStackTop);
            if (MyStackTopOne(MyStackTop))
            {
                MyStackTopTwo(MyStackTop MyStackInputTop);

            }
            else if (MyStackTopThree(MyStackTop) &&
                MyInputStackTopOne(My

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

     文件      35328  2013-05-19 19:51  LanguageAnalyse\LanguageAnalyse\bin\Debug\LanguageAnalyse.exe

     文件      34304  2013-05-19 19:51  LanguageAnalyse\LanguageAnalyse\bin\Debug\LanguageAnalyse.pdb

     文件      14328  2013-06-20 22:03  LanguageAnalyse\LanguageAnalyse\bin\Debug\LanguageAnalyse.vshost.exe

     文件        490  2009-06-11 05:14  LanguageAnalyse\LanguageAnalyse\bin\Debug\LanguageAnalyse.vshost.exe.manifest

     文件       7653  2013-05-19 19:51  LanguageAnalyse\LanguageAnalyse\Form1.cs

     文件      17768  2013-05-19 19:48  LanguageAnalyse\LanguageAnalyse\Form1.Designer.cs

     文件       5814  2013-05-19 19:48  LanguageAnalyse\LanguageAnalyse\Form1.resx

     文件       4082  2013-05-19 19:48  LanguageAnalyse\LanguageAnalyse\LanguageAnalyse.csproj

     文件       3224  2013-06-20 22:03  LanguageAnalyse\LanguageAnalyse\obj\Debug\LanguageAnalyse.csproj.FileListAbsolute.txt

     文件       1008  2013-05-19 19:48  LanguageAnalyse\LanguageAnalyse\obj\Debug\LanguageAnalyse.csproj.GenerateResource.Cache

     文件      35328  2013-05-19 19:51  LanguageAnalyse\LanguageAnalyse\obj\Debug\LanguageAnalyse.exe

     文件        180  2013-05-19 19:48  LanguageAnalyse\LanguageAnalyse\obj\Debug\LanguageAnalyse.Form1.resources

     文件      34304  2013-05-19 19:51  LanguageAnalyse\LanguageAnalyse\obj\Debug\LanguageAnalyse.pdb

     文件      17674  2013-05-19 19:48  LanguageAnalyse\LanguageAnalyse\obj\Debug\LanguageAnalyse.Properties.Resources.resources

     文件       5120  2013-05-19 19:48  LanguageAnalyse\LanguageAnalyse\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll

     文件        496  2013-04-19 09:02  LanguageAnalyse\LanguageAnalyse\Program.cs

     文件       1386  2013-04-19 09:02  LanguageAnalyse\LanguageAnalyse\Properties\AssemblyInfo.cs

     文件       3689  2013-05-19 19:48  LanguageAnalyse\LanguageAnalyse\Properties\Resources.Designer.cs

     文件       6765  2013-05-19 19:48  LanguageAnalyse\LanguageAnalyse\Properties\Resources.resx

     文件       1100  2013-04-19 09:02  LanguageAnalyse\LanguageAnalyse\Properties\Settings.Designer.cs

     文件        249  2013-04-19 09:02  LanguageAnalyse\LanguageAnalyse\Properties\Settings.settings

     文件       4970  2013-05-19 19:45  LanguageAnalyse\LanguageAnalyse\Resources\QQ截图20130519194448.png

     文件       4944  2013-05-19 19:48  LanguageAnalyse\LanguageAnalyse\Resources\QQ截图20130519194725.png

     文件       7059  2013-04-19 09:24  LanguageAnalyse\LanguageAnalyse\Resources\预测分析表.png

     文件        935  2013-04-19 09:02  LanguageAnalyse\LanguageAnalyse.sln

    ..A..H.     17408  2013-06-20 22:03  LanguageAnalyse\LanguageAnalyse.suo

     文件       4944  2013-05-19 19:47  LanguageAnalyse\QQ截图20130519194725.png

     文件      27648  2013-05-19 19:44  LanguageAnalyse\分析表.doc

     目录          0  2013-05-17 10:05  LanguageAnalyse\LanguageAnalyse\obj\Debug\Refactor

     目录          0  2013-05-19 19:48  LanguageAnalyse\LanguageAnalyse\obj\Debug\TempPE

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

评论

共有 条评论