国产探花免费观看_亚洲丰满少妇自慰呻吟_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;    
        }
    }<
國內最大的酷站演示中心!
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 得荣县| 临湘市| 安阳市| 夹江县| 上虞市| 青龙| 分宜县| 南开区| 灯塔市| 当阳市| 友谊县| 涡阳县| 洪泽县| 临桂县| 营山县| 无为县| 牙克石市| 银川市| 波密县| 怀化市| 江源县| 安乡县| 习水县| 洛南县| 清新县| 阳春市| 玉屏| 高平市| 闽侯县| 依安县| 通辽市| 临西县| 贡山| 黄梅县| 枝江市| 秦皇岛市| 南宁市| 泾源县| 拜城县| 无极县| 乌拉特前旗|