大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> NET专区 -> 穿针引线:一个不完全的对代码加亮的代码,大家可以对其进行扩展!(原创)

穿针引线:一个不完全的对代码加亮的代码,大家可以对其进行扩展!(原创)

时间: 2021-07-31 作者:daque

using system;using system.text;using system.text.regularexpressions;namespace com.osleague.component{/// <summary>/// 语法领会器,将一切code按照语法举行变色/// <list type="vb">扶助vb.net</list>/// <list type="cs">扶助cs</list>/// <author>掉掉</author>/// <date>2002年5月14日</date>/// <memo>/// 熟习正则表白式/// </memo>/// </summary>public class codeanalysis{////设置html发端和中断的语句,用来语法变色//const string tag_fntred= @"<font color=""red"">";const string tag_fntblue = @"<font color=""blue"">" ;const string tag_fntgrn= @"<font color=""green"">" ;const string tag_fntmrn= @"<font color=""maroon"">" ;const string tag_fntblack= @"<font color=""black"">" ;const string tag_efont = @"</font>" ;const string tag_spnyellow = @"<span style=""background-color: yellow;"">";const string tag_espan = @"</span>";const string tag_b = @"<b>";const string tag_eb= @"</b>";//public codeanalysis(){//// todo: 在此处增添结构因变量论理//}/// <summary>/// 处置cs代码,彩色化../// </summary>/// <param name="code">传入的code</param>/// <returns>处置事后的代码</returns>public string parsecs(string code){////设置cs中要害字,将其存为数组//string[] cs_keyword = new string[]{"as", "auto","base","break","case","catch","const","continue","default","do","else","event","explicit","extern","false","finally","fixed","for","foreach","goto","if,","implicit","in","internal","lock","namespace","null","operator","out","override","params","private","protected","public","readonly","ref","return","sealed","stackalloc","static","switch","this","throw","true","try","unsafe","using","virtual","void","while","new"};////设定变换代码脸色//string replacecskeyword = tag_fntblue + "${char}" + tag_efont;//发端变换for (int i=0;i<cs_keyword.length;i++){string tempdirectives = @"(?<char>(\s" + cs_keyword[i] + "|" + cs_keyword[i] + @"\s))";code = regex.replace(code,tempdirectives,replacecskeyword);}////设置cs中数据典型,将其存为数组//string[] cs_datatype = new string[]{"bool","byte","char","class","decimal","delegate","double","enum","float","int","interface","long","object","sbyte","short","string","struct","uint","ulong","ushort"};////设置cs中预处置引导,将其存为数组//string[] cs_preprocessor = new string[]{//:todo};return code;}}}过两天大概就会扶助asp,html,ubb,js之类少许列货色

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.