国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

OK.這個是完整的VB.NET的語法解析程序。比較長,不過支持全部的關鍵字,直接就可以用了。

2024-07-10 13:08:15
字體:
來源:轉載
供稿:網友
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 background-color: yellow;"">";
        const string tag_espan     = @"</span>";
        const string tag_b         = @"<b>";
        const string tag_eb        = @"</b>";
        const string tag_comment   = @"<font colr=#008200>";
        const string tag_ecomment   = @"</font>";

        //



        public codeanalysis()
        {
            //
            // todo: 在此處添加構造函數邏輯
            //
        }

    
        
        /// <summary>
        /// 處理vb.net代碼,彩色化..
        /// </summary>
        /// <param name="code">傳入的code</param>
        /// <returns>處理過后的代碼</returns>
        public string parsevb(string code)
        {
            //
            //定義vb.net中關鍵字,將其存為數組
            //

            string[] vb_keyword = new string[]
            {
                "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"
            };

            

            //
            //設定轉換代碼顏色
            //

            string replacevbcomment = tag_comment + "$1" + tag_ecomment;
            string replacevbkeyword = tag_fntblue + "${char}" + tag_efont;
            //開始轉換
            for (int i=0;i<vb_keyword.length;i++)
            {
                string tempdirectives = @"(?<char>(/s" + vb_keyword[i] + "|" + vb_keyword[i] + @"/s))";
                code = regex.replace(code,tempdirectives,replacevbkeyword,regexoptions.ignorecase);
                code = regex.replace(code,@"'(?<x>[^/r/n]*)",replacevbcomment);
                code = regex.replace(code,@"rem (?<x>[^/r/n]*)",replacevbcomment);
            }
            return code;    
        }
    }<
國內最大的酷站演示中心!
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 上林县| 炉霍县| 敦煌市| 太康县| 柯坪县| 阿尔山市| 青龙| 多伦县| 平山县| 孝义市| 吴堡县| 广丰县| 南和县| 凤凰县| 天津市| 溆浦县| 札达县| 穆棱市| 乡城县| 沧州市| 获嘉县| 泸西县| 西藏| 集贤县| 湘潭市| 横山县| 上思县| 泸定县| 公安县| 浦江县| 凤台县| 海宁市| 灌云县| 太原市| 丰都县| 阿鲁科尔沁旗| 新蔡县| 册亨县| 临海市| 驻马店市| 凌海市|