??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲级αV无码毛片久久精品,狠色狠色狠狠色综合久久,99久久人妻无码精品系列http://www.shnenglu.com/ckyap/<递归的忧?gt;zh-cnWed, 07 May 2025 01:11:54 GMTWed, 07 May 2025 01:11:54 GMT60单地调用Google译APIhttp://www.shnenglu.com/ckyap/archive/2009/06/03/86693.html陈坤陈坤Wed, 03 Jun 2009 13:00:00 GMThttp://www.shnenglu.com/ckyap/archive/2009/06/03/86693.htmlhttp://www.shnenglu.com/ckyap/comments/86693.htmlhttp://www.shnenglu.com/ckyap/archive/2009/06/03/86693.html#Feedback5http://www.shnenglu.com/ckyap/comments/commentRss/86693.htmlhttp://www.shnenglu.com/ckyap/services/trackbacks/86693.htmlJustType新命令translate~ 实时译! 废话不多_?个图先:Q?a >http://justtype.cloudapp.net 我前一博文有更详l地介绍q个JustType目Q?/p>

image

image

 

我们l常会有q种需求,是译一段看不太懂的外语。Google提供了翻译服务,但是如果每次都要打开Google那个译面Q倒也挺麻烦。于是我把翻译功能也做成了JustType的命令,现在在JustType中就可以通过translate命o来翻译Q何语a的文字了。想体验的话Q?a >http://justtype.cloudapp.net

 

整个translate命o的脚本代码很单,先用正则表达式分析了命ol构Q然后向|页写入javascript代码Q在javascript中引用google函数库,调用对应函数卛_Q?/p>

import System
import System.Text
import System.Text.RegularExpressions
import System.Web

from System.Text.RegularExpressions import *

def OnCommand(command):
    sourceLang = "en"
    targetLang = "zh"
    text = command
    chkAdvancedUsage = Regex("(?<text>(.|\n)+?)\\s+from (?<from>[a-zA-Z]+) to (?<to>[a-zA-Z]+)")
    m = chkAdvancedUsage.Match(command)
    if m.Success:
        sourceLang = m.Groups["from"].Value
        targetLang = m.Groups["to"].Value
        text = m.Groups["text"].Value
    render = "<div id=\"divTranslation\" style=\"background-color:#f0f8ff; border:dotted 1px gray; padding:5px; width:500px; \"></div>\n"
    render += "<script type=\"text/javascript\" src=\"http://www.google.com/jsapi\"></script>\n"
    render += "<script type=\"text/javascript\">\n"
    render += "google.load(\"language\", \"1\");\n"
    render += "function initializeTranslation() { google.language.translate(\"" + System.Web.HttpUtility.HtmlEncode(text.Replace("\n", " ").Replace("\r", "")) + "\",\"" + sourceLang + "\", \"" + targetLang + "\", function(result) {\n"
    render += "if (!result.error) { document.getElementById(\"divTranslation\").innerHTML = result.translation; } else { document.getElementById(\"divTranslation\").innerHTML = \"error!\" }\n"
    render += "}); }"
    render += "google.setOnLoadCallback(initializeTranslation);"
    render += "</script>"
    SetTipText(render)
    return True

 

在JustType中,一个命令对应一个执行脚本,我们可以自己写新脚本Q同时可以允许其他h调用自己写的E序。大家互相分享自己智慧的同时Q也在利用编E技术增加自己和他h的工作效率。更多的信息请到http://justtype.cloudapp.net 获取?Q)



陈坤 2009-06-03 21:00 发表评论
]]>
Command the world! 命o整个世界http://www.shnenglu.com/ckyap/archive/2009/06/02/86556.html陈坤陈坤Tue, 02 Jun 2009 08:27:00 GMThttp://www.shnenglu.com/ckyap/archive/2009/06/02/86556.htmlhttp://www.shnenglu.com/ckyap/comments/86556.htmlhttp://www.shnenglu.com/ckyap/archive/2009/06/02/86556.html#Feedback9http://www.shnenglu.com/ckyap/comments/commentRss/86556.htmlhttp://www.shnenglu.com/ckyap/services/trackbacks/86556.html每当我们打开电脑Q我们可能经怼做一些习惯性的动作。例如查一下邮件啦Q看看新dQ观察一下股走向啦。仔l想一下就发现Q这里面有很多动作是我们每天都会重复的。有没有可能更方便一点呢Q?/p>

有。很单,wؓE序员的我们Qؓ每种固定的操作写个小E序好了。但q样一来会带来几个问题Q?/p>

1. 程序写多了Q很隄一理。而且有些带参数的E序Q例如按照一定股编号去查询h的程序)Q用v来ƈ不一定方ѝ?/p>

2. 我们可能l常使用不同的电脑,那么要同步这些小E序会非常头疹{?/p>

3. 你也写,我也写,大家写了大量重复的小E序Q很费资源?/p>

Z应对q些问题Q我提出了一个叫JustType的框Ӟ我们可以?a >http://justtype.cloudapp.net 讉K它?/p>

JustType的界面就是一个文本框Q一切都在这个文本框中进行。在JustType框架中,每个程序都对应一个命令,命o可带参数。写好的程序会保存在服务器Q每一个h都可以选择是否要公开自己的小E序。这样大家可以很方便地共享自q成果?/p>

让我们来逐一看看JustType拥有的功能?/p>

首先Q最基本的,你可以在JustType中输入一个网址Q一按回车就会访问该|址?/p>

image

当然Q仅仅是q样的话Q很傅R因为浏览器的地址栏更好用多了。但是,JustTypeq远不止q点?/p>

我们可以Z个命令设|一个别名,例如Q?/p>

image

l过q样的设|后Q下ơ我只要打cppblog׃自动q入http://www.shnenglu.com 了?/p>

q有很多时候,我们会遇C些小的计算问题。Windows那个计算器实在很不好用,让我们看看JustTypeQ?/p>

image

image

q个calc命o会将后面的表辑ּ求值ƈ昄出来。实际上Q这里这个表辑ּ是Python的表辑ּQJustType中所有的程序都q行在IronPython?q且可以使用.net frameworkcd中的大多数功能?/p>

当然Q除了简单的表达式以外,我们q可以执行更复杂的脚本:

image

输入q个命o之后Q界面就会变成下面的样子Q?/p>

image

MultiLineTextMode是一个预定义函数Q功能是主界面上的文本框变成多行模式,q样我们可以输入更复杂的脚本了。下面我们试试用一?net framework中的功能Q?/p>

image

输出l果如下Q?/p>

image

SetTextBoxText也是一个预定义函数Q可以改变主界面中文本框内的文本。更多的预定义函数描q可以在http://justtype.cloudapp.net/Help.aspx 中看到?/p>

除了临时执行脚本以外Q我们也可以脚本写成小E序保存h。输入newcommand命oQ就会进入创建命令的面。我们将q个程序命名ؓtranslateQ然后输入以下代码:

import System
import System.Web

def OnCommand(command):
    GoToURL("http://dict.youdao.com/search?q=" + System.Web.HttpUtility.UrlEncode(command))
    return True

E序依然是用IronPython写,其实Python语法很简单?a >http://www.python.org 感兴的用户可以ȝ看。这个OnCommand函数是用来接收消息的。当JustType收到命o后,会找到这个命令对应的脚本Qƈ参Cl脚本的OnCommand函数来执行。我们看刎ͼq里E序调用了GoToURL函数Q{向了有道词典的页面。在创徏了这个程序后Q我们就可以在JustType的文本框中输入下面的命oQ?/p>

image

一按回车,׃转向译l果Q?/p>

image

cM圎ͼ我们可以写出很多很多方便实用的小E序。在我们创徏E序Ӟ我们可以选择是否要公开。如果公开的话Q别的用户就可以通过“你的用户名.E序名”来调用你的E序。例如我的用户名是ckQ那么其他用户就可以输入ck.translate来调用我的程序,当然他喜Ƣ的话也可以用setalias来设|一个方便的别名。如果所有公开的程序中Q只有我q个E序叫做translateQ那么其他用户不打ck.translate而直接打translate也可以成功调用?/p>

另外QJustType提供一U简单的数据存储。每一个程序在一个用L账户中会有一个独立的存储I间Q可以存?000行数据。例如我利用q个Ҏ开发了一个叫做note的小E序Q可以时记录一些小W记Q?/p>

image

那么之后我就可以看到我的W记Q?/p>

image

所有的E序和数据,都存攑֜服务器端Q用户不用担心不同机器的问题。无Z走到哪里Q都可以像在一台机器上一栯问所有服务和数据?/p>

新服务刚刚搭建好Q欢q大家试用和提供意见喔。网址?a >http://justtype.cloudapp.net



陈坤 2009-06-02 16:27 发表评论
]]>
命o的执着---整个世界装q一个TextBox中!http://www.shnenglu.com/ckyap/archive/2008/10/09/63592.html陈坤陈坤Thu, 09 Oct 2008 14:29:00 GMThttp://www.shnenglu.com/ckyap/archive/2008/10/09/63592.htmlhttp://www.shnenglu.com/ckyap/comments/63592.htmlhttp://www.shnenglu.com/ckyap/archive/2008/10/09/63592.html#Feedback11http://www.shnenglu.com/ckyap/comments/commentRss/63592.htmlhttp://www.shnenglu.com/ckyap/services/trackbacks/63592.html未读q本pd文章的,请先参?a title="http://www.shnenglu.com/ckyap/archive/2008/10/06/63287.html" href="http://www.shnenglu.com/ckyap/archive/2008/10/06/63287.html">http://www.shnenglu.com/ckyap/archive/2008/10/06/63287.html

BoxSharp 最新进展!

image

输入盘地址时的自动提示Q另外还有按TAB键即可切换目录,行ؓ与cmd命o行里面输入地址栏时cM

image 

Note功能Q可以随时记下一下小事情。命令ؓ/note something。输?note会打开当前所有notes列表?/p>

工具栏自定义按钮功能Q输?toolbutton add "button name" command卛_自定义一个按钮,按下即会执行指定的command命oQ效果与在文本框中输入command然后按回车一栗?/p>

之前一位朋友提到的/define功能Q我觉得如果需要参敎ͼ应该写成新插gQ而不是定义成另外一个命令;如果不需要参敎ͼ那就可以通过现在q个toolbutton实现。所以暂时不做了?/p>

全局热键在WPF下面貌似很有问题。。。至我q没扑ֈ解决ҎQ这几天太忙了,有空我还要l想办法?/p>

最新版q里下蝲 http://code.google.com/p/boxsharp/downloads/list



陈坤 2008-10-09 22:29 发表评论
]]>
命o的国?--- 整个世界装q一个Textbox中!http://www.shnenglu.com/ckyap/archive/2008/10/06/63287.html陈坤陈坤Sun, 05 Oct 2008 16:13:00 GMThttp://www.shnenglu.com/ckyap/archive/2008/10/06/63287.htmlhttp://www.shnenglu.com/ckyap/comments/63287.htmlhttp://www.shnenglu.com/ckyap/archive/2008/10/06/63287.html#Feedback11http://www.shnenglu.com/ckyap/comments/commentRss/63287.htmlhttp://www.shnenglu.com/ckyap/services/trackbacks/63287.htmlq篇文章是l上一《命令的~纷》来阐述的。未阅读q前一的请参见这里:http://www.shnenglu.com/ckyap/archive/2008/09/12/61641.html

功能可以看下面几个图Q?/p>

 

image

总而言之,BoxSharp提供一U可扩展的方式让你在一个TextBox中干M事情?/p>

此项目已l正式作为开源项目放在Google Code上啦Q大家可以在q里讉K目主页Q?a >http://boxsharp.googlecode.com/

那啥Subversion搞了我一个小时。。。真是感叹现在的高科技啊?/p>

在这里可以下载最新的可执行文Ӟ只能q行在Win32q_上,需?net framework 3.5支持Q?/p>

http://code.google.com/p/boxsharp/downloads/list

在这里可以查看最新的文档Q?/p>

http://code.google.com/p/boxsharp/w/list

在这里可以查看源代码Q(要有Subversion才能下蝲C码)

http://code.google.com/p/boxsharp/source/checkout



陈坤 2008-10-06 00:13 发表评论
]]>
命o的缤U?--整个世界装q一个TextBox中!http://www.shnenglu.com/ckyap/archive/2008/09/12/61641.html陈坤陈坤Thu, 11 Sep 2008 16:29:00 GMThttp://www.shnenglu.com/ckyap/archive/2008/09/12/61641.htmlhttp://www.shnenglu.com/ckyap/comments/61641.htmlhttp://www.shnenglu.com/ckyap/archive/2008/09/12/61641.html#Feedback6http://www.shnenglu.com/ckyap/comments/commentRss/61641.htmlhttp://www.shnenglu.com/ckyap/services/trackbacks/61641.htmlq篇文章是l上一《命令的痴狂》来阐述的。未阅读q前一的请参见这里:http://www.shnenglu.com/ckyap/archive/2008/09/09/61427.html

q一ơ我做了一个可以自定RSS源的新闻滚动播放器插Ӟ滚动新闻放在TextBox的旁边,鼠标放过L新闻介,点击可以打开览器浏览新闅R这样在工作之余Q抬起头p看看当时最新的新闻Q不亦乐乎!

image 

 

除了新闻播放器,q两天主要做的就是一个智能提C框。就像Firefox那个“棒极了的地址栏”一P我希望这个框框能的提C我一些操作和命o。大多数时候,我们想通过一些熟悉的名字来启动一些程序,比如输入QQQ就l我启动QQQ输入IEQ就l我打开IE。有时候我们也希望通过一些简U来讉K一些网站,比如输入baiduQ就l我打开癑ֺQ输入googleq我打开googleQ而不需要输入完整的http://www.baidu.com 。当Ӟ如果让我们手动添加所有的命oQ比如我亲自告诉E序Q“如果我输入baiduq我打开http://www.baidu.com”,q当然很LQ但是我很懒Q我不想每次都亲自添加这U命令,我需要他自动帮我扑և来?/p>

W一个我能想到的地方Q就是开始菜单的“程序”目录里了。遍历里面所有的快捷方式Q把名字分析一下,加入待选列表,搞定。不q这个名字分析的q程比较ȝQ因为比如QQ他的快捷方式默认是叫“腾讯QQ2009”,但是我只惌入QQ打开它。另外比如Microsoft Visual Studio 2008Q我只想输入MVSq个U来讉K它。这个就是一些特征的提取了,也不会太难?/p>

image

image

除了E序目录QProgram Files也是一个好地方Q里面的exe一般都是有用的E序Q提取出来,一hq来Q它p提示我更多东西了?/p>

W二个主要地方,是收藏夹和览器历史了。遍历里面所有的目Q分析一下,也加入待选列表。同h分析q程比较重要Q决定了能否得到正确的提C?/p>

image

image

选到需要的目上,按回车就行了。这里我准备对用次数做排名Q用得多的目会Q到最上面去,也就是直接按回R׃启动的位|?/p>

 

OKQ现在这个框框可以干的所有事情,ȝ一下:

1.可以输入/exitQ退出。(别扔砖头。。。)

2.可以输入/baiduQ?google{搜索引擎对一个词q行搜烦。搜索引擎可以通过配置文g指定?/p>

3.可以输入一个完整的路径名,或者一个完整的URLQ打开讉K?/p>

4.可以输入C#代码Q立x行。(可以q行表达式运等操作Q可以保存代码段Q以后通过一个名字来直接执行它?/p>

5.可以随时看到最新的新闻滚动播放Q点d可在览器中打开。RSS新闻来源可以自定?/p>

6.自动索引常用E序和网,可以通过输入它们的简Uͼ或Q何你惛_到的代表词语来运行它们?/p>

 

下一步准备做的,桌面搜烦?/p>

陈坤 2008-09-12 00:29 发表评论
]]>
命o的痴?--整个世界装q一个TextBox中!http://www.shnenglu.com/ckyap/archive/2008/09/09/61427.html陈坤陈坤Tue, 09 Sep 2008 14:58:00 GMThttp://www.shnenglu.com/ckyap/archive/2008/09/09/61427.htmlhttp://www.shnenglu.com/ckyap/comments/61427.htmlhttp://www.shnenglu.com/ckyap/archive/2008/09/09/61427.html#Feedback12http://www.shnenglu.com/ckyap/comments/commentRss/61427.htmlhttp://www.shnenglu.com/ckyap/services/trackbacks/61427.html朋友Q可曾想q把所有的事情都放C个TextBox里面dQ今天我做了一个,理论上可以干M事情的TextBox。嘿ѝ?/p>

实习的日子实在是挺忙QCNScriptq停留在语法分析的阶D,一直没旉L开那个大工E(其实是有旉的,可惜零碎的时间都被我拿来写这文章要讲的q些东西了Q?/p>

我们在浏览网|Q或怼H然x开某个E序Q比如计器Q算点东西;又可能想打开PhotoshopQ处理一下网上的某个图片;又可能想打开C本,摘抄一些文字。这时我们不得不回到桌面Q或者打开那个大的开始菜单,在程序里面去找我们想要的东西?/p>

有的时候,我们q会重复做一些机械的动作Q比如读一个文Ӟ查是否有变动Q比如检查某个文件夹Q看是否有新文g。当Ӟ你可以写一个程序来完成q个操作Q但是有时候这U操作你觉得最多就重复个两三次Q你不会愿意L开Visual Studio创徏一个工E?/p>

归结本质Q我们就是想要一个随叫随到的Q可以有一定能力帮我们做事情的东西。但是如果这个东西太大,会挡住我们正在浏览的|页或者正在处理的文档Q那׃好了。所以我想C一个Topmost的TextBoxQ放在屏q的端Q也是一般窗口的标题栏那里,q样子不会挡住你要做的事情,而且在需要的时?只要鼠标一U过d可以用了?/p>

是q样一个TextBox

OKQ有了这样一个TextBoxQ“随叫随到”已l完成了。但是我们需要这个TextBox有一定能力,比如我想q行一个程序,它能帮我q行Q我x索一个词语,他能帮我搜烦Q我x开一个URLQ他能帮我打开Q我惌一个表辑ּQ他能帮我计。但是h的需求是无限的,我们随时会有新的需要,他不可能拥有所有的功能Q那么如何让他有能力做到M事情呢?我们需要一U很强悍的可扩展性。玩q魔兽世界的朋友们一定知道,兽世界提供一个插件机Ӟ玩家可以为游戏写插gQ来丰富游戏的功能,现在已经有千千万万的兽世界插g在各大网站上提供下蝲了,正是因ؓ如此Q魔兽世界才拥有着q么强的可扩展性。所以,我们q个TextBox也要用插件机制来驱动。在C#的Microsoft.CSharp名字I间中有一个C#的编译器Q可以将C#代码~译成托组Ӟ直接生成在内存中Q以反射的方式来q行Q这个机制ؓ我们快速实C个插件系l提供了可能。因此我选用?net framework 3.5Q用Windows Presentation Foundation来做界面Q用C#来当我的脚本语言?/p>

俗话_一不做Q二不休Q既然提供了插gQ那我主E序除了q行插g以外׃么都不做了。运行了插g之后Q将界面所有控件的控制权都交给插gQ插件爱q啥干啥去。主E序是一个WindowQWindow上是一个StackPanelQPanel里面是一个TextBoxQ仅此而已。当Ӟ插g可以向StackPanel里面加东西,以丰富这个条条的外观内容?/p>

 

可执行程序的环境如下所C:QBoxSharp是这个程序的名字Q?/p>

image

其中BoxSharpCoreQBoxSharpRunPathQBoxSharpScriptingQBoxSharpSearch是我刚写好的几个插g?/p>

BoxSharpCore插g提供了最基本?exit命oQ用于退出程序。此插gq控制了一些外观方面的l节Q包括自动记住TextBox上次退出时的位|,大小Q用于下ơ启动时恢复外观。当输入在文本框内的命o是一个正命令时Q会出现功能提示?/p>

image

BoxSharpRunPath插g提供了打开文g夹,打开|址Q运行命令的功能?/p>

image image image

BoxSharpScripting插g提供了直接运行C#E序的功能。这个功能可以顺便当作表辑ּ计算器用Q有时候有些运(其是带N个括L复杂表达式)想立d出结果的Q就不用打开计算器了。Print函数是用于将参数值直接写在TextBox里面的?/p>

image

image

image

也可以直接用/script命o打开一个窗口进行复杂的~程?/p>

image

BoxSharpSearch插g是提供Web搜烦功能的,我们可以通过配置文g来配|搜索引擎,插g启动时会自动配|项的?/p>

image

image

我有旉的话Q完全可以写更多的插Ӟ比如自动电子邮Ӟ收发邮gQ比如滚动播放新闻,比如自动搜新歌下载试听,比如日历Q日E安排,U会提示Q闹钟,q些都可以作为插件写到里面去。而且Q如果,我是说如果,如果很多用户在用q个TextBox的话Q他们可以共享他们自己写的插Ӟ彼此的BoxSharp功能丰富?/p>

好吧Q说到底了,.net framework 3.5能办到的Q这个TextBoxp办到Q但是你估计不会Z计算一个表辑ּ而打开Visual Studio建工E的。这是TextBox的魅力所在了QHOHO?/p>

陈坤 2008-09-09 22:58 发表评论
]]>
W一行代?--- CNScript 成长日记Q?Q?/title><link>http://www.shnenglu.com/ckyap/archive/2008/08/09/58361.html</link><dc:creator>陈坤</dc:creator><author>陈坤</author><pubDate>Fri, 08 Aug 2008 17:27:00 GMT</pubDate><guid>http://www.shnenglu.com/ckyap/archive/2008/08/09/58361.html</guid><wfw:comment>http://www.shnenglu.com/ckyap/comments/58361.html</wfw:comment><comments>http://www.shnenglu.com/ckyap/archive/2008/08/09/58361.html#Feedback</comments><slash:comments>8</slash:comments><wfw:commentRss>http://www.shnenglu.com/ckyap/comments/commentRss/58361.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/ckyap/services/trackbacks/58361.html</trackback:ping><description><![CDATA[     摘要: 首先贺北京奥运会精彩开q!Q我亲眼见到了鸟巢的壮观景象Q跟一堆外国h在一L开q式时我W一ơ感觉这么自豪!加a奥运Q加油中国!今天把词法分析器写好了,一个巨大的switch。代码如下://CNScriptLex.h  1 #ifndef CNSCRIPTLEX_H 2 #define CNSCRIPTLEX_H 3 ...  <a href='http://www.shnenglu.com/ckyap/archive/2008/08/09/58361.html'>阅读全文</a><img src ="http://www.shnenglu.com/ckyap/aggbug/58361.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/ckyap/" target="_blank">陈坤</a> 2008-08-09 01:27 <a href="http://www.shnenglu.com/ckyap/archive/2008/08/09/58361.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>你好Q状态图 --- CNScript 成长日记Q?Q?/title><link>http://www.shnenglu.com/ckyap/archive/2008/08/08/58293.html</link><dc:creator>陈坤</dc:creator><author>陈坤</author><pubDate>Thu, 07 Aug 2008 16:15:00 GMT</pubDate><guid>http://www.shnenglu.com/ckyap/archive/2008/08/08/58293.html</guid><wfw:comment>http://www.shnenglu.com/ckyap/comments/58293.html</wfw:comment><comments>http://www.shnenglu.com/ckyap/archive/2008/08/08/58293.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.shnenglu.com/ckyap/comments/commentRss/58293.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/ckyap/services/trackbacks/58293.html</trackback:ping><description><![CDATA[<p>上一我已经各个词法标记都设计好了Q现在我们需要写Z个程序,他读入一个字W串Qƈ输出一pdTokenQ其中每个Token是一个词法标讎ͼ例如KeywordQIdentifierQNumberQOperator?br><br>假设我们输入int a=100;q样一个字W串作ؓ代码Q那么我们将如何分析呢?<br><br>首先diQ?#8220;i”W合Identifier的规则,但是l箋M去还有个nQ一共是“in”Q?#8220;in”也符合Identifier的规则,再读Q变?#8220;int”Q?#8220;int”W合Type的规则,l箋d后面的空|变成“int ”Q这个可不符合Q何规则了Q因此我们不能承认这一步,只好取上一步的可接受的l果TypeQ?#8220;int”。这h们就生成了第一个TokenQ他的类型是TypeQ值是“int”。以此类推,我们可以d整个E序Qƈ完成整个词法分析的过E?br><br>但是每一ơ都d断整个已d的字W串是否匚w某个规则Q效率非怽Q我们需要一U线性读入字W串Qƈ实时掌握目前字符串匹配状늚办法。确定性有I动机QDFAQ就是这样一U状态机?br><br>下面是我为CNScriptd的状态图Q?br><img height=479 alt="" src="http://www.shnenglu.com/images/cppblog_com/ckyap/status_1.jpg" width=308 border=0><br><img height=562 alt="" src="http://www.shnenglu.com/images/cppblog_com/ckyap/status_2.jpg" width=567 border=0><br><img height=454 alt="" src="http://www.shnenglu.com/images/cppblog_com/ckyap/status_3.jpg" width=480 border=0></p> <p><img height=121 alt="" src="http://www.shnenglu.com/images/cppblog_com/ckyap/status_4.jpg" width=420 border=0><br><br>例如刚才ȝint a=100Q?br>我们一开始是在编号ؓ0的状态,现在输入iQ因为i属于a-zA-Z的范_所以通过最后一q图我们看到Q我们将q向~号?4的状态。再输入nQ因为n属于a-zA-Z0-9_的范_所以我们l走在编?4的状态,t也如此,但是输入I格Ӟ我们发现44L态没有接受空格字W的出口Q也是无法l箋CMQ而且44L态是一个可接受状态,所以我们接受已l输入了?#8220;int”?br>在这里我们的44L态,接受意义是一个nameQ可以是IdentifierQ也可以是KeywordQ也可以是TypeQ当我们取得nameQ?#8220;int”Ӟ我们再判断发现这是一个TypeQ所以我们得出TokenQTypeQ?#8220;int”。然后状态回?Pl箋输入刚才的空根{以此类推?br><br>所以我们只要按q个状态图去遍历字W串Q我们就会不断的在各个状态中辗{反复Qƈ不断的得出Tokens。这是我们词法分析的基本原理?br>下一我会写个DFA的代码和具体使用Ҏ?/p> <img src ="http://www.shnenglu.com/ckyap/aggbug/58293.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/ckyap/" target="_blank">陈坤</a> 2008-08-08 00:15 <a href="http://www.shnenglu.com/ckyap/archive/2008/08/08/58293.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>l制蓝图 --- CNScript 成长日记Q?Q?/title><link>http://www.shnenglu.com/ckyap/archive/2008/08/05/58099.html</link><dc:creator>陈坤</dc:creator><author>陈坤</author><pubDate>Tue, 05 Aug 2008 15:41:00 GMT</pubDate><guid>http://www.shnenglu.com/ckyap/archive/2008/08/05/58099.html</guid><wfw:comment>http://www.shnenglu.com/ckyap/comments/58099.html</wfw:comment><comments>http://www.shnenglu.com/ckyap/archive/2008/08/05/58099.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.shnenglu.com/ckyap/comments/commentRss/58099.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/ckyap/services/trackbacks/58099.html</trackback:ping><description><![CDATA[要写一个脚本引擎,首先要明脚本长什么样Q具备哪些功能,需要有怎样的能力?br>Since昨天我说W一版是面向q程Q强cdQ无闭包Q无自定义结构,支持数组Q那么我脚本设计如下:<br><br> <h1 style="MARGIN: 17pt 0cm 16.5pt"><span lang=EN-US><font face=Calibri color=#000000 size=6>CNScript 0.1 Draft</font></span></h1> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><o:p><font face=Calibri> </font></o:p></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><font face=Calibri><span lang=EN-US style="FONT-SIZE: 16pt">Functionality:</span><span lang=EN-US> </span></font></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri>Procedure Oriented, No Custom Data Structures, No Closures, Strong Typed, Array Supported.</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><o:p><font face=Calibri> </font></o:p></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US style="FONT-SIZE: 16pt"><font face=Calibri>Keywords:<o:p></o:p></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri>int,double,char,string,bool,void,if,else,for,do,while,return</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><o:p><font face=Calibri> </font></o:p></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US style="FONT-SIZE: 16pt"><font face=Calibri>Statements:<o:p></o:p></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><font face=Calibri>Single Expression:</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><font face=Calibri><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal"><span lang=EN-US>expression</span></em></strong><span lang=EN-US>;</span></font></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><o:p><font face=Calibri> </font></o:p></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><font face=Calibri>Chunk:</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><font face=Calibri>{</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">Statement1<o:p></o:p></em></strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">Statement2<o:p></o:p></em></strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><font face=Calibri>}</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><o:p><font face=Calibri> </font></o:p></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><font face=Calibri>Array Declaration:</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><font face=Calibri><em style="mso-bidi-font-style: normal"><span lang=EN-US>type</span></em><span lang=EN-US> <em style="mso-bidi-font-style: normal">name</em>[<em style="mso-bidi-font-style: normal">size</em>];</span></font></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><o:p><font face=Calibri> </font></o:p></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><font face=Calibri>Variable Declaration:</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><font face=Calibri><em style="mso-bidi-font-style: normal"><span lang=EN-US>type</span></em><span lang=EN-US> <em style="mso-bidi-font-style: normal">name</em> [= <strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression</em></strong>];</span></font></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><o:p><font face=Calibri> </font></o:p></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><font face=Calibri>Function definition:</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><font face=Calibri><em style="mso-bidi-font-style: normal"><span lang=EN-US>type</span></em><span lang=EN-US> <em style="mso-bidi-font-style: normal">FunctionName</em>(<em style="mso-bidi-font-style: normal">type paramName1, type paramName2</em>)</span></font></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal"><span lang=EN-US><font face=Calibri>Chunk<o:p></o:p></font></span></em></strong></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><o:p><font face=Calibri> </font></o:p></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><font face=Calibri>IF-ELSE:</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><font face=Calibri>if(<strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression</em></strong>)</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal"><span lang=EN-US><font face=Calibri>Statement1<o:p></o:p></font></span></em></strong></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><font face=Calibri>else</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal"><span lang=EN-US><font face=Calibri>Statement2<o:p></o:p></font></span></em></strong></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal"><span lang=EN-US><o:p><font face=Calibri> </font></o:p></span></em></strong></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><font face=Calibri>FOR-LOOP:</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><font face=Calibri>for(<strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">statement1</em></strong> <strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression2</em></strong>;<strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression3</em></strong>)</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal"><span lang=EN-US><font face=Calibri>Statement<o:p></o:p></font></span></em></strong></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal"><span lang=EN-US><o:p><font face=Calibri> </font></o:p></span></em></strong></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><font face=Calibri>WHILE-LOOP:</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><font face=Calibri>while(<strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression</em></strong>)</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal"><span lang=EN-US><font face=Calibri>Statement<o:p></o:p></font></span></em></strong></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal"><span lang=EN-US><o:p><font face=Calibri> </font></o:p></span></em></strong></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><font face=Calibri>DO-WHILE-LOOP:</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><font face=Calibri>do</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd; tab-stops: 171.75pt"><font face=Calibri><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal"><span lang=EN-US>Statement</span></em></strong><span lang=EN-US><span style="mso-tab-count: 1">                                               </span></span></font></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><font face=Calibri>while(<strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression</em></strong>);</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 10.5pt; mso-para-margin-left: 1.0gd"><span lang=EN-US><o:p><font face=Calibri> </font></o:p></span></p> <span lang=EN-US><font face=Calibri> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US style="FONT-SIZE: 16pt">Expressions:<o:p></o:p></span></p> </font></span> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span>Values:</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span>true</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span>false</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span><em style="mso-bidi-font-style: normal">number<o:p></o:p></em></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span><em style="mso-bidi-font-style: normal">string<o:p></o:p></em></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><em style="mso-bidi-font-style: normal"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span>char<o:p></o:p></font></span></em></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span><em style="mso-bidi-font-style: normal">Variable Name<o:p></o:p></em></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><font face=Calibri><em style="mso-bidi-font-style: normal"><span lang=EN-US><span style="mso-tab-count: 2">                   </span>Array Name</span></em><span lang=EN-US>[<em style="mso-bidi-font-style: normal">index</em>]<em style="mso-bidi-font-style: normal"><o:p></o:p></em></span></font></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><o:p><font face=Calibri> </font></o:p></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span>Assign:</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span><em style="mso-bidi-font-style: normal">name</em> = <strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression</em></strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><o:p><font face=Calibri> </font></o:p></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span>Function Call:</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span><em style="mso-bidi-font-style: normal">name</em>(<strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression1</em></strong>,<strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression2</em></strong>)</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><o:p><font face=Calibri> </font></o:p></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span>Compares:</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression1</em></strong> == <strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression2</em></strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression1</em></strong> != <strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression2</em></strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression1</em></strong> < <strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression2</em></strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression1</em></strong> > <strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression2</em></strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression1</em></strong> <= <strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression2</em></strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression1</em></strong> >= <strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression2</em></strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><o:p><font face=Calibri> </font></o:p></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span>Boolean Operations:</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span>!<strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression</em></strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression1</em></strong> && <strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression2</em></strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression1</em></strong> || <strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression2</em></strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><o:p><font face=Calibri> </font></o:p></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span>Calculating:</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression</em></strong>++</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression</em></strong>?/font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span>++<strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression</em></strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span>--<strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression</em></strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression1</em></strong> + <strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression2</em></strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression1</em></strong> – <strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression2</em></strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression1</em></strong> * <strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression2</em></strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression1</em></strong> / <strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression2</em></strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression1</em></strong> % <strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression2</em></strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 2">                   </span><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression1</em></strong> ^ <strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression2<o:p></o:p></em></strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><font face=Calibri><strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal"><span lang=EN-US><span style="mso-tab-count: 2">                   </span></span></em></strong><span lang=EN-US>(<strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression</em></strong>)</span></font></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><o:p><font face=Calibri> </font></o:p></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US style="FONT-SIZE: 16pt"><font face=Calibri>Lexical Tokens:<o:p></o:p></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US style="mso-bidi-font-size: 10.5pt"><font face=Calibri>Spaces:<o:p></o:p></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US style="mso-bidi-font-size: 10.5pt"><font face=Calibri><span style="mso-tab-count: 1">         </span>Space:<span style="mso-tab-count: 3">                         </span><strong style="mso-bidi-font-weight: normal">(space_bar+)|(\n+) (\r+)|(\t+)<o:p></o:p></strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US style="mso-bidi-font-size: 10.5pt"><font face=Calibri>TypeNames:<o:p></o:p></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US style="mso-bidi-font-size: 10.5pt"><font face=Calibri><span style="mso-tab-count: 1">         </span>Type:<span style="mso-tab-count: 2">                  </span><span style="mso-tab-count: 1">         </span><strong style="mso-bidi-font-weight: normal">(int)|(double)|(char)|(string)|(bool)|(void)</strong><o:p></o:p></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri>Keywords:</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span>Keyword_if:<span style="mso-tab-count: 2">               </span><strong style="mso-bidi-font-weight: normal">if</strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span>Keyword_else: <span style="mso-tab-count: 2">         </span><strong style="mso-bidi-font-weight: normal">else</strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span>Keyword_for:<span style="mso-tab-count: 2">            </span><strong style="mso-bidi-font-weight: normal">for</strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span>Keyword_do:<span style="mso-tab-count: 2">             </span><strong style="mso-bidi-font-weight: normal">do</strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span>Keyword_while:<span style="mso-tab-count: 1">       </span><strong style="mso-bidi-font-weight: normal">while</strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span>Keyword_return:<span style="mso-tab-count: 1">     </span><strong style="mso-bidi-font-weight: normal">return</strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri>Brackets:</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span>BigLeftBracket:<span style="mso-tab-count: 1">        </span><strong style="mso-bidi-font-weight: normal">{</strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span>BigRightBracket:<span style="mso-tab-count: 1">     </span><strong style="mso-bidi-font-weight: normal">}</strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span>MidLeftBracket:<span style="mso-tab-count: 1">       </span><strong style="mso-bidi-font-weight: normal">[</strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span>MidRightBracket:<span style="mso-tab-count: 1">    </span><strong style="mso-bidi-font-weight: normal">]</strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span>SmallLeftBracket:<span style="mso-tab-count: 1">    </span><strong style="mso-bidi-font-weight: normal">\(</strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span>SmallRightBracket:<span style="mso-tab-count: 1"> </span><strong style="mso-bidi-font-weight: normal">\)</strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri>Identifier:</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span>Identifier:<span style="mso-tab-count: 1">         </span><span style="mso-tab-count: 1">         </span><strong style="mso-bidi-font-weight: normal">(_+[a-zA-Z0-9_]+)|([a-zA-Z][a-zA-Z0-9_]*)</strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri>Number Value:</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span>Integer:<span style="mso-tab-count: 2">             </span><span style="mso-tab-count: 1">         </span><strong style="mso-bidi-font-weight: normal">0|[1-9][0-9]*</strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span>Double:<span style="mso-tab-count: 3">                       </span><strong style="mso-bidi-font-weight: normal">(0|[1-9][0-9]*)\.[0-9]+</strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri>Bool Value:</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span>BoolValue:<span style="mso-tab-count: 2">                 </span><strong style="mso-bidi-font-weight: normal">true|false</strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri>Char:</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span>CharValue:<span style="mso-tab-count: 2">                 </span><strong style="mso-bidi-font-weight: normal">‘(\\[^\r\n\t])|([^’\r\n\t])’</strong></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><font face=Calibri>String:</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; tab-stops: 21.0pt 42.0pt 63.0pt 84.0pt 105.0pt 126.0pt 147.0pt 168.0pt 189.0pt 380.25pt"><span lang=EN-US><font face=Calibri><span style="mso-tab-count: 1">         </span>StringValue:<span style="mso-tab-count: 2">               </span><strong style="mso-bidi-font-weight: normal">“((\\”)|[^\r\n])*”<span style="mso-tab-count: 1">   </span><span style="mso-tab-count: 1">                                                                                     </span><o:p></o:p></strong></font></span></p> <span lang=EN-US><font face=Calibri> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>Operators:</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-tab-count: 1">         </span>Operator:<span style="mso-tab-count: 3">                    </span><strong style="mso-bidi-font-weight: normal">=|\+|-|\*|/|%|^|(++)|(--)|(&&)|(\|\|)|(!)|<|>|(<=)|(>=)|(==)|(!=)<o:p></o:p></strong></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US>Seprators:</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><span style="mso-tab-count: 1">         </span>Seprator:<span style="mso-tab-count: 3">                    </span><strong style="mso-bidi-font-weight: normal">;</strong></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"></font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><o:p><font face=Calibri> </font></o:p></span></p> 以上是脚本设计初稿Q如果后面发现有错误Q会L正的?br><br>按这个设计,写出来的E序大概是下面这P<br><br> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080"> 1</span> <span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> Foo(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> value)<br></span><span style="COLOR: #008080"> 2</span> <span style="COLOR: #000000">{<br></span><span style="COLOR: #008080"> 3</span> <span style="COLOR: #000000">   </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> value;<br></span><span style="COLOR: #008080"> 4</span> <span style="COLOR: #000000">}<br></span><span style="COLOR: #008080"> 5</span> <span style="COLOR: #000000"><br></span><span style="COLOR: #008080"> 6</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> main()<br></span><span style="COLOR: #008080"> 7</span> <span style="COLOR: #000000">{<br></span><span style="COLOR: #008080"> 8</span> <span style="COLOR: #000000">   </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> a </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">100</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080"> 9</span> <span style="COLOR: #000000">   </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">100</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br></span><span style="COLOR: #008080">10</span> <span style="COLOR: #000000">   {<br></span><span style="COLOR: #008080">11</span> <span style="COLOR: #000000">      </span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">a;<br></span><span style="COLOR: #008080">12</span> <span style="COLOR: #000000">   }<br></span><span style="COLOR: #008080">13</span> <span style="COLOR: #000000">   </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(a</span><span style="COLOR: #000000">></span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">)<br></span><span style="COLOR: #008080">14</span> <span style="COLOR: #000000">   {<br></span><span style="COLOR: #008080">15</span> <span style="COLOR: #000000">      Foo(a);<br></span><span style="COLOR: #008080">16</span> <span style="COLOR: #000000">   }<br></span><span style="COLOR: #008080">17</span> <span style="COLOR: #000000">}</span></div> <br><br>基本上就是个没模板,没类Q没指针的C++了?br><br>设计p样了Q明天开始写词法分析喔!上面的Lexical Tokens是l词法分析用的,因ؓ代码是字W串Q我们先要把整个字符串读成一个一个的TokenQ才方便q行语法分析和更深入的处理,比如<br>int a = 100;<br>要先拆成[type:int] [space] [identifier:a] [space] [operator:=] [space] [integer:100] [seperator:;]<br>q个q程是词法分析了?br><br>词法分析完了得出q些Tokens然后再匹配到<br> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><span lang=EN-US><font face=Calibri>Variable Declaration:</font></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd"><font face=Calibri><em style="mso-bidi-font-style: normal"><span lang=EN-US>type</span></em><span lang=EN-US> <em style="mso-bidi-font-style: normal">name</em> [= <strong style="mso-bidi-font-weight: normal"><em style="mso-bidi-font-style: normal">expression</em></strong>];<br><br></span></font>才能建立赯法树来?br>Lexical Tokens中是每种Token对应的正则表辑ּ?/p> <img src ="http://www.shnenglu.com/ckyap/aggbug/58099.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/ckyap/" target="_blank">陈坤</a> 2008-08-05 23:41 <a href="http://www.shnenglu.com/ckyap/archive/2008/08/05/58099.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>摩拳擦掌 --- CNScript 成长日记Q?Q?/title><link>http://www.shnenglu.com/ckyap/archive/2008/08/05/58032.html</link><dc:creator>陈坤</dc:creator><author>陈坤</author><pubDate>Tue, 05 Aug 2008 00:46:00 GMT</pubDate><guid>http://www.shnenglu.com/ckyap/archive/2008/08/05/58032.html</guid><wfw:comment>http://www.shnenglu.com/ckyap/comments/58032.html</wfw:comment><comments>http://www.shnenglu.com/ckyap/archive/2008/08/05/58032.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.shnenglu.com/ckyap/comments/commentRss/58032.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/ckyap/services/trackbacks/58032.html</trackback:ping><description><![CDATA[我早想写一个脚本引擎了Q真的?br><br>事情可以q溯到大一的时候,很想做游戏(虽然后来发现工成了最大的问题Q,于是自己写了一套GUIQ用hq挺爽,但是是一直觉得缺了个脚本引擎?br><br>于是Q奉天承q,我开始着手脚本引擎的计划了?br><br>话说L得先跟字W串培养培养感情Q而且也是Z以后写脚本引擎时能省些苦力,q有很多其他因素影响Q我军_先写一个正则表辑ּ引擎。ؓ了方便,我又得封一个性格良好Q功能顽强的Stringc,要真的实现功能顽强,又得搞好Encoding斚w的事情,要方便调试程序,又得把Console和IO斚w的东西封好。于是我q脆p他拼了,了一个类.Net的小cd出来。ؓ了好看,名字I间搞得?Net的一模一P用v来也挺顺溜的?br><br> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080"> 1</span> <span style="COLOR: #000000">#include </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">System.h</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080"> 2</span> <span style="COLOR: #000000"><br></span><span style="COLOR: #008080"> 3</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000"> System;<br></span><span style="COLOR: #008080"> 4</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000"> System::Text::RegularExpressions;<br></span><span style="COLOR: #008080"> 5</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000"> System::Windows::Forms;<br></span><span style="COLOR: #008080"> 6</span> <span style="COLOR: #000000"><br></span><span style="COLOR: #008080"> 7</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> Program(</span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000"> String</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000"> arg)<br></span><span style="COLOR: #008080"> 8</span> <span style="COLOR: #000000">{<br></span><span style="COLOR: #008080"> 9</span> <span style="COLOR: #000000">    Application::RunConsoleApplication();<br></span><span style="COLOR: #008080">10</span> <span style="COLOR: #000000"><br></span><span style="COLOR: #008080">11</span> <span style="COLOR: #000000">    Regex exampleExp(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">(+\\w+):(+\\z+)</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br></span><span style="COLOR: #008080">12</span> <span style="COLOR: #000000">    String exampleString </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">hello:哈喽!!!</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">13</span> <span style="COLOR: #000000"><br></span><span style="COLOR: #008080">14</span> <span style="COLOR: #000000">    Int64 startTime </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> GetTickCount();<br></span><span style="COLOR: #008080">15</span> <span style="COLOR: #000000">    Match</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> m </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> exampleExp.Match(exampleString);<br></span><span style="COLOR: #008080">16</span> <span style="COLOR: #000000">    Int64 endTime </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> GetTickCount();<br></span><span style="COLOR: #008080">17</span> <span style="COLOR: #000000"><br></span><span style="COLOR: #008080">18</span> <span style="COLOR: #000000">    Console::WriteLine(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">---------KSystem Example Program---------</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br></span><span style="COLOR: #008080">19</span> <span style="COLOR: #000000">    Console::WriteLine(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Example Regex:\t</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> exampleExp.Pattern());<br></span><span style="COLOR: #008080">20</span> <span style="COLOR: #000000">    Console::WriteLine(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Example String:\t</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> exampleString);<br></span><span style="COLOR: #008080">21</span> <span style="COLOR: #000000">    Console::WriteLine(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Matched Value:\t</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> m</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">Value());<br></span><span style="COLOR: #008080">22</span> <span style="COLOR: #000000">    Console::WriteLine(m</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">Captures[</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">] </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">:</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> m</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">Captures[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">]);<br></span><span style="COLOR: #008080">23</span> <span style="COLOR: #000000">    Console::WriteLine(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Time Cost:\t</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> String::ToString(endTime </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> startTime) </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> ms</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br></span><span style="COLOR: #008080">24</span> <span style="COLOR: #000000">    Console::WriteLine(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">-----------------------------------------</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br></span><span style="COLOR: #008080">25</span> <span style="COLOR: #000000"><br></span><span style="COLOR: #008080">26</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">27</span> <span style="COLOR: #000000">}</span></div> <br>不要问我Z么字W串前面不加LQ也不要问我Z么没有delete那个mQ我的库会干q些事情的。表辑ּ中那个\z是匹配中文字的意?br>q行l果Q?br><img height=149 alt="" src="http://www.shnenglu.com/images/cppblog_com/ckyap/example.JPG" width=340 border=0><br><br>做这么个正则表达式,q输掉了我一pizza。当时跟vczh同学打赌Q他说我写完肯定有bugQ我说我肯定没bug。结果不出意料地有bugQ于是一华丽的pizza被送进了我们肚子。重要经验:是个E序必然有bugQ恩恩?br><br>q个正则表达式引擎刚写出来时性能奇差无比Q主要时间耗在了内存分配上。经q一pd优化Qvczh也跟着我一起优化了他那个正则表辑ּ引擎Q到最后某ơ性能试Ӟ我的׃13U,vczh同学的花?2U,也有时候是我的更快Q视表达式写法不同而略有差别,基本上^均下来是一L。(boost和greta׃40+NU)<br><br>有了正则表达式引擎,也有了跟字符串几个月的感情,现在l于开始计划脚本引擎了。由于还是第一ơ,L点畏首畏Q我军_先写一个非常菜的版本。强cdQ无闭包Q面向过E,支持数组Q不支持自定义结构。这是我计划的CNScript的第一版本Q也UCaiNiaoScript?br><br>其实我真的想实现的是CNScript的第二个版本QChinaScript。这会是一个类自然语言写法的中文脚本引擎。写h变量和函数命名绝对会很不习惯Q但是写完之后却会像一文章一h利?br><br><br>例如Q现在用C++Q模拟一个h使用某个交通工具去某个地方的行为?br><br>Class TrafficTool;<br><br>Class Car : public TrafficTool;<br><br>Class Man<br>{<br>   void TravelTo(Point destination, TrafficTool* trafficTool);<br>};<br><br>用v来就?br><br>Man Peter;<br>TrafficTool* BMW = new Car();<br>Point beijing;<br><br>Peter.TravelTo(beijing, BMW);<br><br>虽然E序员一看就能理解个大概Q但是非E序员很难用或l护它。在来的CNScript中,也许会是q样Q估计最后不会这么罗嗦)Q?br><br>有一U东西叫交通工P汽R是一U交通工兗?br>有一U东西叫人?//我承认这句话有点怪,语法l节问题需要仔l琢,谁有好的可以留言l我喔,感激万分<br>有一U东西叫做目的地?br><br>有一U行为:一个h乘坐一个交通工具去往一个目的地?br><br>//以上是声明,以下是用这几个cȝ代码<br><br>有一个h叫Peter?br>有一个汽车叫宝马?br>有一个目的地叫北京?br><br>Peter乘坐宝马d北京?br><br>q样的代码,虽然在函数和变量命名时要仔细考虑Q但是写出来的代码即使是不懂E序的h也能看明白,为的是兼游戏开发的各个环节的h员?br><br>好了Q想法到此ؓ止,今晚开始动工CNScript的第一版,CaiNiaoScript! 我会把我每个阶段的工作和工作原理都写在这日CQ有兴趣的朋友可以跟着一L玩喔Q? <img src ="http://www.shnenglu.com/ckyap/aggbug/58032.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/ckyap/" target="_blank">陈坤</a> 2008-08-05 08:46 <a href="http://www.shnenglu.com/ckyap/archive/2008/08/05/58032.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>лǵվܻԴȤ</p> <a href="http://www.shnenglu.com/" title="精品视频久久久久">精品视频久久久久</a> <div class="friend-links"> </div> </div> </footer> <a href="http://www.touzhi8.cn" target="_blank">99þۺϹƷ</a>| <a href="http://www.aipmusic.cn" target="_blank">Ʒþþ</a>| <a href="http://www.9r6.com.cn" target="_blank">þ99þóѲ</a>| <a href="http://www.loveindg.cn" target="_blank">91þþƷ91ɫҲ</a>| <a href="http://www.nsimple.cn" target="_blank">þó18վ</a>| <a href="http://www.tst5.cn" target="_blank">ɫۺϺϾþۺӿ</a>| <a href="http://www.dituibangbang.cn" target="_blank">þþƷ˵</a>| <a href="http://www.9xz.com.cn" target="_blank">þþþƷ</a>| <a href="http://www.73sd.cn" target="_blank">ɫۺϾþ</a>| <a href="http://www.rfqaod.cn" target="_blank">ھƷþþþӰԺվ</a>| <a href="http://www.jnyadz.cn" target="_blank">ձһƷþþþӰԺ</a>| <a href="http://www.qcwxfw.cn" target="_blank">þ99Ʒһ</a>| <a href="http://www.animin.cn" target="_blank">þþþùһëƬ</a>| <a href="http://www.weizhongjiang.cn" target="_blank">Ʒþþþþ֣ݹ˾ </a>| <a href="http://www.ehrmfye.cn" target="_blank">þþƷ99Ʒ</a>| <a href="http://www.alexa178.cn" target="_blank">þþþþ޾Ʒ</a>| <a href="http://www.zyydh.cn" target="_blank">þĻƵ</a>| <a href="http://www.3233567.cn" target="_blank">þùѹۿƷ3</a>| <a href="http://www.ssfbq5.cn" target="_blank">Ʒþۺ</a>| <a href="http://www.szlove.net.cn" target="_blank">þ޾ƷƵ</a>| <a href="http://www.asox.cn" target="_blank">ŷպĻþþò </a>| <a href="http://www.nxxdz.cn" target="_blank">þþþһ</a>| <a href="http://www.88815755.cn" target="_blank">2021þþƷѹۿ</a>| <a href="http://www.2tou.cn" target="_blank">ƷȾþþø</a>| <a href="http://www.sixyin.cn" target="_blank">һõþۺϺݺAV</a>| <a href="http://www.xh68.cn" target="_blank">һһþþƷۺ</a>| <a href="http://www.yunshujia.cn" target="_blank">þоƷƵ</a>| <a href="http://www.cstshs.cn" target="_blank">뾫Ʒþþɫ</a>| <a href="http://www.dmchs.cn" target="_blank">þ޾ƷƵ</a>| <a href="http://www.hzks666.cn" target="_blank">¾þƵ</a>| <a href="http://www.shangxin.net.cn" target="_blank">þer99ȾƷһ</a>| <a href="http://www.pnpxnc.cn" target="_blank">þùӰԺ</a>| <a href="http://www.zjjunyao.cn" target="_blank">޾Ʒþ</a>| <a href="http://www.cdz8.cn" target="_blank">һɫþۺϺݺ</a>| <a href="http://www.fx40.cn" target="_blank">þ޾ƷƷ</a>| <a href="http://www.pbxdt.com.cn" target="_blank">ɫþþ99Ʒ91 </a>| <a href="http://www.phatmedia.cn" target="_blank">99þþƷѿһ </a>| <a href="http://www.fkmlt.cn" target="_blank">97þþƷ</a>| <a href="http://www.ltbhs.com.cn" target="_blank">ާѡþþþƷ9966</a>| <a href="http://www.asook.cn" target="_blank">þþƷAV㽶</a>| <a href="http://www.1104f.cn" target="_blank">鶹ŷۺϾþ</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>