• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            diceidea

            parser

            常用鏈接

            Others

            有用的東西

            最新評(píng)論

            DFA和lexical analysis

            對(duì)于hand written的lexical analyzer來(lái)說(shuō),NFA和DFA的運(yùn)用是不可避免的,除非你的grammer十分簡(jiǎn)單。
            一旦給出了source program(也就是你想處理的character stream)的一個(gè)pattern的正則表達(dá)式,就可以構(gòu)造對(duì)應(yīng)的NFA,然后轉(zhuǎn)換為DFA,這個(gè)DFA就可以用來(lái)處理你的source program, 將里面能夠match這個(gè)pattern的lexeme全都找出來(lái)。按照這樣的流程,對(duì)于一種編程語(yǔ)言,不管是常用的語(yǔ)言,還是腳本語(yǔ)言,只要對(duì)所有的pattern構(gòu)造DFA,就能夠?qū)懗鲎约旱膌exical analyzer了。
            有兩篇關(guān)于正則表達(dá)式到DFA的文章寫(xiě)的很好:
            1.Writing own regular expression parser By Amer Gerzic英文的
            http://www.codeproject.com/KB/recipes/OwnRegExpressionsParser.aspx
            有源碼
            2. 《構(gòu)造正則表達(dá)式引擎》新鮮出爐啦!中文的,by vczh,華南理工大學(xué)
            http://www.shnenglu.com/vczh/archive/2008/05/22/50763.html
            閱讀完上面兩篇文章,寫(xiě)個(gè)能夠運(yùn)行的lexer就不成問(wèn)題了。
            另外附上龍書(shū)(Compilers, principles techniques and tools)里一段token,pattern和lexeme術(shù)語(yǔ)的區(qū)別:
            1. A t o k e n  is  a  pair  consisting  of  a  token  name  and  an optional attribute
            value.   The  token  name  is  an  abstract  symbol  representing  a  kind  of
            lexical unit(lexeme), e.g., a  particular keyword, or a sequence of  input  characters
            denoting an identifier.  The token  names are the input  symbols that the
            parser  processes.  In what  follows, we  shall generally write the name of  a
            token  in boldface.  We  will often refer to a token  by  its token name.
            2. A pattern is a description of the form that the lexemes of  a token may take.
            In  the case of  a  keyword as  a token,  the pattern  is just  the sequence of
            characters that form the keyword.  For identifiers and some other tokens,
            the pattern is a more complex structure that is matched by many strings.
            3. A lexeme is a sequence of  characters in the source program that matches
            the  pattern  for  a  token  and  is  identified  by  the  lexical  analyzer  as  an
            instance of  that token.
             notes:
            1. more than  one lexeme  can  match  a  pattern
            2. 看看example 3.1


            posted on 2008-05-24 13:59 diceidea 閱讀(521) 評(píng)論(0)  編輯 收藏 引用 所屬分類: Dev log


            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            相關(guān)文章:
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


            少妇内射兰兰久久| 婷婷久久五月天| 欧洲成人午夜精品无码区久久| 久久天天婷婷五月俺也去| 久久频这里精品99香蕉久| 国产亚洲精品久久久久秋霞| 97久久久精品综合88久久| 久久午夜综合久久| 亚洲AV乱码久久精品蜜桃| 国产A级毛片久久久精品毛片| 亚洲国产成人久久综合区| 久久青草国产手机看片福利盒子| 91精品观看91久久久久久| 国产精品99久久久久久宅男小说| 久久久WWW成人免费精品| 久久久久亚洲av成人网人人软件 | 97热久久免费频精品99| 欧美久久亚洲精品| a高清免费毛片久久| 99久久免费国产精品特黄| 国产日韩欧美久久| 97久久久久人妻精品专区| 无码精品久久久久久人妻中字| 久久九九久精品国产免费直播| 久久亚洲精品中文字幕| 色综合久久88色综合天天 | 91亚洲国产成人久久精品| 久久偷看各类wc女厕嘘嘘| 久久久久久久女国产乱让韩| 亚洲一级Av无码毛片久久精品| 国产精品免费久久久久影院| 国产高潮国产高潮久久久| 热re99久久6国产精品免费| 精品无码久久久久国产动漫3d| 亚洲国产成人久久精品99 | 三级片免费观看久久| 国产成人精品久久亚洲高清不卡| 东京热TOKYO综合久久精品| 色欲综合久久中文字幕网| 久久久久国产精品熟女影院| 色婷婷综合久久久久中文一区二区|