1 / 15
文档名称:

词法分析器用C#实现.doc

格式:doc   大小:138KB   页数:15页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

词法分析器用C#实现.doc

上传人:sssmppp 2021/3/5 文件大小:138 KB

下载得到文件列表

词法分析器用C#实现.doc

相关文档

文档介绍

文档介绍:编译原理词法分析器
文件 字体 词法分析 符号表 错误详细信息
设计界面如上图所示:
代码如下:
namespace WindowsApp1ication1
(
public partial class Forml : Form
{
public Forml ()
(
InitializeComponent();
}
string Str = 〃〃,text2 二〃〃;
private void JT?fToolStripMenuItem_Click(object sender, EventArgs e) (
string Fname =〃〃;
openFileDialogl. Filter 二〃文本文件(*. txt) | *. txt”;
openFileDialogl. Title = 〃打开文件〃;
openFileDialogl. RestoreDirectory = true;
if (openFileDialogl. ShowDialogO — DialogResult. OK)
Fname 二 openFileDialogl. FileName;
richTextBoxl. LoadFile(Fname, RichTextBoxStreamType. PlainText);
Str 二 richTextBoxl. Text;
private void 保存ToolStripMemiltem Click (object sender, EventArgs e) string Fname = openFileDialogl. FileName;
richTextBoxl. SaveFile(Fname, RichTextBoxStreamType. PlainText); }
private void 另存为ToolStripMenuItem_Click(object sender, EventArgs e) (
string Fname;
saveFileDialogl. Filter 二〃文本文件(*. txt) | *. txt〃 ;
saveFileDialogl. Title = 〃保存文件〃;
saveFileDialogl. RestoreDirectory = true;
saveFileDialogl. ShowDialog();
Fname = saveFileDialogl. FileName;
if (Fname != 〃〃)
richTextBoxl. SaveFile(Fname, RichTextBoxStreamType. PlainText);
}
private void 关闭ToolStripMenuItem_Click(object sender, EventArgs e)
(
Application. Exit ();
}
private void 字体ToolStripMenuItem_Click (object sender, EventArgs e) (
fontDialogl. ShowEffects = true;
fontDialogl. Font = richTextBoxl. SelectionFont;
if (fontDialogl. ShowDialog() ― DialogResult. OK)
richTextBoxl. SelectionFont 二 fontDialogl. Font; }
private void 词法分析ToolStripMenuItem_Click(object sender, EventArgs e) (
Gets. LineNo = 1; //初始化行号
Gets, errors二0; //初始化错误个数
二〃〃;
string textl 二 richTextBoxl. Text + ' \0';
Gets getstring 二 new Gets();
text2 = getstring. GetString(textl);
richTextBox2. Text 二 〃*****************Token串生成表如下'********************〃 + 〃\r\n〃 + text2;
textBox2. Text 二 getstring. ErrorN0();
private void Forml_Load(object sender, EventArgs e)
private void 符号表ToolStripMenuItem_Click (object send