⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 编译原理 词法分析器 识别标识符
💻 CS
📖 第 1 页 / 共 4 页
字号:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
namespace WindowsApplication1
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{   
		[DllImport("user32")]
		public static extern bool GetCaretPos(ref System.Drawing.Point lpPoint);
		private System.Windows.Forms.RichTextBox richTextBox1;
		private System.Windows.Forms.OpenFileDialog openFileDialog1;
		private System.Windows.Forms.SaveFileDialog saveFileDialog1;
		private System.Windows.Forms.MainMenu mainMenu1;
		private System.Windows.Forms.MenuItem menuItem2;
		private System.Windows.Forms.MenuItem menuItem3;
		private System.Windows.Forms.MenuItem menuItem4;
		private System.Windows.Forms.MenuItem menuItem5;
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.MenuItem menuItem6;
		private System.Windows.Forms.MenuItem menuItem7;
		private System.Windows.Forms.MenuItem menuItem8;
		private System.Windows.Forms.MenuItem menuItem9;
		private System.Windows.Forms.MenuItem menuItem10;
		private System.Windows.Forms.MenuItem menuItem11;
		private System.Windows.Forms.MenuItem menuItem12;
		private System.Windows.Forms.MenuItem menuItem13;
		private System.Windows.Forms.MenuItem menuItem14;
		private System.Windows.Forms.MenuItem menuItem15;
		private System.Windows.Forms.ToolBar toolBar1;
		private System.Windows.Forms.ToolBarButton toolBarButton_open;
		private System.Windows.Forms.ToolBarButton toolBarButton_save;
		private System.Windows.Forms.ToolBarButton toolBarButton_print;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.ToolBarButton toolBarButton_new;
		private System.Windows.Forms.MenuItem menuItem16;
		private System.Windows.Forms.SaveFileDialog saveFileDialog2;
		private System.Windows.Forms.DataGridTableStyle 错误提示;
		private System.Windows.Forms.DataGridTableStyle 错误单词;
		private System.Windows.Forms.DataGridTableStyle 行;
		private System.Windows.Forms.DataGridTableStyle 列;
		private System.Windows.Forms.DataGrid dataGrid_token;
		private System.Windows.Forms.DataGrid dataGrid_error;
		private System.ComponentModel.IContainer components;
		
		#region 定义单词结构体
		public struct words  
		{   
			public string word ; //单词
			public int row;      //行号
			public int col;      //列号
			public string type;     //种别码
			
		}  ////标识符结构数组
		#endregion
		
		
		public Form1()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();
			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}
			
		private int X = 0;
		private int Y = 0;
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}
		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.richTextBox1 = new System.Windows.Forms.RichTextBox();
			this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
			this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
			this.mainMenu1 = new System.Windows.Forms.MainMenu();
			this.menuItem2 = new System.Windows.Forms.MenuItem();
			this.menuItem3 = new System.Windows.Forms.MenuItem();
			this.menuItem4 = new System.Windows.Forms.MenuItem();
			this.menuItem5 = new System.Windows.Forms.MenuItem();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.menuItem16 = new System.Windows.Forms.MenuItem();
			this.menuItem6 = new System.Windows.Forms.MenuItem();
			this.menuItem7 = new System.Windows.Forms.MenuItem();
			this.menuItem8 = new System.Windows.Forms.MenuItem();
			this.menuItem9 = new System.Windows.Forms.MenuItem();
			this.menuItem10 = new System.Windows.Forms.MenuItem();
			this.menuItem11 = new System.Windows.Forms.MenuItem();
			this.menuItem12 = new System.Windows.Forms.MenuItem();
			this.menuItem13 = new System.Windows.Forms.MenuItem();
			this.menuItem14 = new System.Windows.Forms.MenuItem();
			this.menuItem15 = new System.Windows.Forms.MenuItem();
			this.toolBar1 = new System.Windows.Forms.ToolBar();
			this.toolBarButton_new = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton_open = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton_save = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton_print = new System.Windows.Forms.ToolBarButton();
			this.label1 = new System.Windows.Forms.Label();
			this.saveFileDialog2 = new System.Windows.Forms.SaveFileDialog();
			this.dataGrid_token = new System.Windows.Forms.DataGrid();
			this.dataGrid_error = new System.Windows.Forms.DataGrid();
			this.错误提示 = new System.Windows.Forms.DataGridTableStyle();
			this.错误单词 = new System.Windows.Forms.DataGridTableStyle();
			this.行 = new System.Windows.Forms.DataGridTableStyle();
			this.列 = new System.Windows.Forms.DataGridTableStyle();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid_token)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid_error)).BeginInit();
			this.SuspendLayout();
			// 
			// richTextBox1
			// 
			this.richTextBox1.Location = new System.Drawing.Point(16, 48);
			this.richTextBox1.Name = "richTextBox1";
			this.richTextBox1.Size = new System.Drawing.Size(384, 352);
			this.richTextBox1.TabIndex = 2;
			this.richTextBox1.Text = "";
			this.richTextBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.richTextBox1_KeyDown);
			this.richTextBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.richTextBox1_MouseDown);
			this.richTextBox1.TextChanged += new System.EventHandler(this.richTextBox1_TextChanged);
			// 
			// openFileDialog1
			// 
			this.openFileDialog1.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog1_FileOk);
			// 
			// mainMenu1
			// 
			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem2,
																					  this.menuItem6,
																					  this.menuItem10,
																					  this.menuItem11,
																					  this.menuItem12,
																					  this.menuItem13,
																					  this.menuItem14,
																					  this.menuItem15});
			// 
			// menuItem2
			// 
			this.menuItem2.Index = 0;
			this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem3,
																					  this.menuItem4,
																					  this.menuItem5,
																					  this.menuItem1,
																					  this.menuItem16});
			this.menuItem2.Shortcut = System.Windows.Forms.Shortcut.CtrlF;
			this.menuItem2.ShowShortcut = false;
			this.menuItem2.Text = "文件(File)";
			this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
			// 
			// menuItem3
			// 
			this.menuItem3.Index = 0;
			this.menuItem3.Shortcut = System.Windows.Forms.Shortcut.CtrlN;
			this.menuItem3.Text = "新建(New)";
			this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
			// 
			// menuItem4
			// 
			this.menuItem4.Index = 1;
			this.menuItem4.Shortcut = System.Windows.Forms.Shortcut.CtrlO;
			this.menuItem4.Text = "打开(Open)";
			this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
			// 
			// menuItem5
			// 
			this.menuItem5.Index = 2;
			this.menuItem5.Shortcut = System.Windows.Forms.Shortcut.CtrlS;
			this.menuItem5.Text = "保存(Save)";
			this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 3;
			this.menuItem1.Shortcut = System.Windows.Forms.Shortcut.CtrlE;
			this.menuItem1.Text = "退出(Exit)";
			this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
			// 
			// menuItem16
			// 
			this.menuItem16.Index = 4;
			this.menuItem16.Text = "另存为(Save as)";
			this.menuItem16.Click += new System.EventHandler(this.menuItem16_Click);
			// 
			// menuItem6
			// 
			this.menuItem6.Index = 1;
			this.menuItem6.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem7,
																					  this.menuItem8,
																					  this.menuItem9});
			this.menuItem6.Text = "编辑(Edit)";
			this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
			// 
			// menuItem7
			// 
			this.menuItem7.Index = 0;
			this.menuItem7.Shortcut = System.Windows.Forms.Shortcut.CtrlC;
			this.menuItem7.Text = "复制(Copy)";
			// 
			// menuItem8
			// 
			this.menuItem8.Index = 1;
			this.menuItem8.Shortcut = System.Windows.Forms.Shortcut.CtrlU;
			this.menuItem8.Text = "剪切(cUt)";
			// 
			// menuItem9
			// 
			this.menuItem9.Index = 2;
			this.menuItem9.Shortcut = System.Windows.Forms.Shortcut.CtrlP;
			this.menuItem9.Text = "粘贴(Paste)";
			// 
			// menuItem10
			// 
			this.menuItem10.Index = 2;
			this.menuItem10.Text = "词法分析(Words)";
			this.menuItem10.Click += new System.EventHandler(this.menuItem10_Click);
			// 
			// menuItem11
			// 
			this.menuItem11.Index = 3;
			this.menuItem11.Text = "生成目标语言(Dest)";
			this.menuItem11.Click += new System.EventHandler(this.menuItem11_Click);
			// 
			// menuItem12
			// 
			this.menuItem12.Index = 4;
			this.menuItem12.Text = "工具(Tools)";
			this.menuItem12.Click += new System.EventHandler(this.menuItem12_Click);
			// 
			// menuItem13
			// 
			this.menuItem13.Index = 5;
			this.menuItem13.Text = "演示(Perform)";
			// 
			// menuItem14
			// 
			this.menuItem14.Index = 6;
			this.menuItem14.Text = "查看(Read)";
			// 
			// menuItem15
			// 
			this.menuItem15.Index = 7;
			this.menuItem15.Text = "帮助(Help)";
			// 
			// toolBar1
			// 
			this.toolBar1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.toolBar1.AutoSize = false;
			this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																						this.toolBarButton_new,
																						this.toolBarButton_open,
																						this.toolBarButton_save,
																						this.toolBarButton_print});
			this.toolBar1.ButtonSize = new System.Drawing.Size(31, 35);
			this.toolBar1.CausesValidation = false;
			this.toolBar1.Cursor = System.Windows.Forms.Cursors.Hand;
			this.toolBar1.Dock = System.Windows.Forms.DockStyle.None;
			this.toolBar1.DropDownArrows = true;
			this.toolBar1.Location = new System.Drawing.Point(0, 0);
			this.toolBar1.Name = "toolBar1";
			this.toolBar1.ShowToolTips = true;
			this.toolBar1.Size = new System.Drawing.Size(785, 40);
			this.toolBar1.TabIndex = 6;
			this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
			// 
			// toolBarButton_new
			// 
			this.toolBarButton_new.Text = "新建";
			// 
			// toolBarButton_open
			// 
			this.toolBarButton_open.Text = "打开";
			// 
			// toolBarButton_save
			// 
			this.toolBarButton_save.Text = "保存";
			// 
			// toolBarButton_print
			// 
			this.toolBarButton_print.Enabled = false;
			this.toolBarButton_print.Text = "打印";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(408, 552);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(224, 23);
			this.label1.TabIndex = 7;
			// 
			// dataGrid_token
			// 
			this.dataGrid_token.BackgroundColor = System.Drawing.SystemColors.ActiveCaptionText;
			this.dataGrid_token.CaptionBackColor = System.Drawing.SystemColors.GrayText;
			this.dataGrid_token.DataMember = "";
			this.dataGrid_token.ForeColor = System.Drawing.SystemColors.InactiveCaption;
			this.dataGrid_token.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGrid_token.Location = new System.Drawing.Point(408, 48);
			this.dataGrid_token.Name = "dataGrid_token";
			this.dataGrid_token.Size = new System.Drawing.Size(360, 352);
			this.dataGrid_token.TabIndex = 12;
			this.dataGrid_token.Navigate += new System.Windows.Forms.NavigateEventHandler(this.dataGrid_token_Navigate);
			// 
			// dataGrid_error
			// 
			this.dataGrid_error.BackgroundColor = System.Drawing.SystemColors.ActiveCaptionText;
			this.dataGrid_error.CaptionBackColor = System.Drawing.SystemColors.GrayText;
			this.dataGrid_error.DataMember = "";
			this.dataGrid_error.ForeColor = System.Drawing.Color.Red;
			this.dataGrid_error.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGrid_error.Location = new System.Drawing.Point(16, 408);
			this.dataGrid_error.Name = "dataGrid_error";
			this.dataGrid_error.SelectionBackColor = System.Drawing.Color.White;
			this.dataGrid_error.Size = new System.Drawing.Size(752, 136);
			this.dataGrid_error.TabIndex = 13;
			this.dataGrid_error.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] {
																									   this.错误提示,
																									   this.错误单词,
																									   this.行,
																									   this.列});
			this.dataGrid_error.Navigate += new System.Windows.Forms.NavigateEventHandler(this.dataGrid_error_Navigate);
			// 
			// 错误提示
			// 
			this.错误提示.ColumnHeadersVisible = false;
			this.错误提示.DataGrid = this.dataGrid_error;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -