|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
如果英语好,口才好,加上女孩子的优势说不定有机会进去做做别的工具)usingSystem;
usingSystem.Text;
usingSystem.Text.RegularExpressions;
namespaceCom.OSLeague.Component
{
///<summary>
///语法剖析器,将一切Code依据语法举行变色
///<listtype="VB">撑持VB.NET</list>
///<listtype="CS">撑持CS</list>
///<author>失落失落</author>
///<date>2002年5月14日</date>
///<Memo>
///实习正则表达式
///</Memo>
///</summary>
publicclassCodeAnalysis
{
//
//界说HTML入手下手和停止的语句,用于语法变色
//
conststringTAG_FNTRED=@"<fontcolor=""red"">";
conststringTAG_FNTBLUE=@"<fontcolor=""blue"">";
conststringTAG_FNTGRN=@"<fontcolor=""green"">";
conststringTAG_FNTMRN=@"<fontcolor=""maroon"">";
conststringTAG_FNTBLACK=@"<fontcolor=""black"">";
conststringTAG_EFONT=@"</font>";
conststringTAG_SPNYELLOW=@"<spanstyle=""background-color:yellow;"">";
conststringTAG_ESPAN=@"</span>";
conststringTAG_B=@"<b>";
conststringTAG_EB=@"</b>";
conststringTAG_COMMENT=@"<fontcolr=#008200>";
conststringTAG_ECOMMENT=@"</font>";
//
publicCodeAnalysis()
{
//
//TODO:在此处增加机关函数逻辑
//
}
///<summary>
///处置VB.NET代码,黑色化..
///</summary>
///<paramname="Code">传进的Code</param>
///<returns>处置事后的代码</returns>
publicstringParseVB(stringCode)
{
//
//界说VB.NET中关头字,将其存为数组
//
string[]VB_Keyword=newstring[]
{
"AddHandler","AddressOf","AndAlso","Alias","And","Ansi","As","Assembly","Auto","Boolean",
"ByRef","Byte","ByVal","Call","Case","Catch","CBool","CByte","CChar",
"CDate","CDec","CDbl","Char","CInt","Class","CLng","CObj","Const",
"CShort","CSng","CStr","CType","Date","Decimal","Declare","Default",
"Delegate","Dim","DirectCast","Do","Double","Each","Else","ElseIf","End",
"Enum","Erase","Error","Event","Exit","False",
"Finally","For","Friend","Function","Get","GetType","GoTo","Handles","If",
"Implements","Imports","In","Inherits","Integer","Interface",
"Is","Let","Lib","Like","Long","Loop","Me","Mod","Module",
"MustInherit","MustOverride","MyBase","MyClass","Namespace","New","Next","Not","Nothing",
"NotInheritable","NotOverridable","Object","On","Option","Optional","Or","OrElse",
"Overloads","Overridable","Overrides","ParamArray","Preserve","Private","Property","Protected","Public",
"RaiseEvent","ReadOnly","ReDim","RemoveHandler","Resume","Return",
"Select","Set","Shadows","Shared","Short","Single","Static","Step","Stop",
"String","Structure","Sub","SyncLock","Then","Throw",
"To","True","Try","TypeOf","Unicode","Until","Variant","When","While",
"With","WithEvents","WriteOnly","Xor"
};
//
//设定转换代码色彩
//
stringReplaceVBComment=TAG_COMMENT+"$1"+TAG_ECOMMENT;
stringReplaceVBKeyword=TAG_FNTBLUE+"${char}"+TAG_EFONT;
//入手下手转换
for(inti=0;i<VB_Keyword.Length;i++)
{
stringTempDirectives=@"(?<char>(s"+VB_Keyword[i]+"|"+VB_Keyword[i]+@"s))";
Code=Regex.Replace(Code,TempDirectives,ReplaceVBKeyword,RegexOptions.IgnoreCase);
Code=Regex.Replace(Code,@"(?<x>[^
]*)",ReplaceVBComment);
Code=Regex.Replace(Code,@"REM(?<x>[^
]*)",ReplaceVBComment);
}
returnCode;
}
}<
就安全性而言,Java已经远远低于VB.NET,更无法与安全性著称的C#相比。 |
|