资源简介

去年做的编译原理作业,由于时间紧迫,没有完成语法分析与语义分析,但拥有比较完善的界面(界面有两个,在主程序中可以修改使用哪个界面)。 词法规则如下: 关键字:int char if else real for do while 数字、变量名(不使用下划线,头字母不为数字)、符号 词法分析生成*.TAKEN、*.SymbolTable两个文件。 保留部分语法分析接口,可以继续完成。 词法分析部分在Lex文件夹下,生成中间数据存储的类在Data下。 由于老师给的语法分析规则太复杂(老师给的还是错的,我后来自己改的),而且在程序中还没有体现,故不上传,需要的可以来信索取,有完成的语法分析表(不知道是否正确……orz)。 注:在界面最下边……2009后面有一个箭头可以弹出菜单,选择"恢复默认设置"即可使用全部功能。将DisplayForm.cs中38-40行的 toolStrip1.Visible = false; toolStrip2.Visible = false; listBox1.Visible = false; 中false改为ture则默认显示全部组件。 本程序系自己完成,版权没有,盗版自由,个人完成程序均免资源分下载。 shizhiyu701@live.cn

资源截图

代码片段和文件信息

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;
using LexApplication.lex;

namespace LexApplication
{
    public partial class DisplayForm : Form
    {
        static ArrayList errorMessage = new ArrayList();
        static int lineNum = 0;
        static ArrayList errorLine = new ArrayList();
        static ArrayList errerWors = new ArrayList();
        TabPage last = new TabPage();
        int sign1 = 1;

        public DisplayForm()
        {
            InitializeComponent();
            TextUserControl newUserControl = new TextUserControl();
            TabPage newPage = new TabPage(“新建代码“);
            newPage.Controls.Add(newUserControl);
            newPage.Location = new System.Drawing.Point(4 22);
            newPage.Name = “newPage“;
            newPage.Padding = new System.Windows.Forms.Padding(3);
            newPage.Size = new System.Drawing.Size(732 271);
            newPage.TabIndex = 0;
            newPage.Text = “新建代码“;
            newPage.UseVisualstyleBackColor = true;
            tabControl1.TabPages.Add(newPage);
            newUserControl.richTextBox1.Text = ““;
            toolStrip1.Visible = false;
            toolStrip2.Visible = false;
            listBox1.Visible = false;
        }

        private void toolStripLabel1_Click(object sender EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                TextUserControl newUserControl = new TextUserControl();
                TabPage newPage = new TabPage(openFileDialog1.FileName);
                newPage.Controls.Add(newUserControl);
                newPage.Location = new System.Drawing.Point(4 22);
                newPage.Name = “newPage“;
                newPage.Padding = new System.Windows.Forms.Padding(3);
                newPage.Size = new System.Drawing.Size(732 271);
                newPage.TabIndex = 0;
                newPage.Text = openFileDialog1.FileName;
                newPage.UseVisualstyleBackColor = true;
                
                tabControl1.SelectedTab = newPage;
                tabControl1.TabPages.Add(newPage);
                TextReader reader = new TextReader();
                newUserControl.richTextBox1.Text = reader.readFile(openFileDialog1.FileName);
            }
            
        }

        private void toolStripLabel2_Click(object sender EventArgs e)
        {

            if (tabControl1.TabPages.Count != 0)
            {

                Writer myWriter = new Writer();
                myWriter.writeLog(tabControl1.SelectedTab.Text ((TextUserControl)tabControl1.SelectedTab.Controls[0]).richTextBox1.Text);
            }
        }

        private void 打开ToolStripMenuItem_Click(object sender EventArgs e)
        {

            TextUser

评论

共有 条评论