資源簡介
去年做的編譯原理作業,由于時間緊迫,沒有完成語法分析與語義分析,但擁有比較完善的界面(界面有兩個,在主程序中可以修改使用哪個界面)。
詞法規則如下:
關鍵字: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
- 上一篇:C#圖片顏色比例分布
- 下一篇:解決IE10以上版本doPostBack未定義
評論
共有 條評論