• <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來說,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就可以用來處理你的source program, 將里面能夠match這個(gè)pattern的lexeme全都找出來。按照這樣的流程,對(duì)于一種編程語言,不管是常用的語言,還是腳本語言,只要對(duì)所有的pattern構(gòu)造DFA,就能夠?qū)懗鲎约旱膌exical analyzer了。
            有兩篇關(guān)于正則表達(dá)式到DFA的文章寫的很好:
            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://m.shnenglu.com/vczh/archive/2008/05/22/50763.html
            閱讀完上面兩篇文章,寫個(gè)能夠運(yùn)行的lexer就不成問題了。
            另外附上龍書(Compilers, principles techniques and tools)里一段token,pattern和lexeme術(shù)語的區(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 閱讀(526) 評(píng)論(0)  編輯 收藏 引用 所屬分類: Dev log


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


            久久久久久久综合综合狠狠| 久久精品草草草| 久久国产视屏| 伊人久久精品无码av一区| 久久亚洲日韩精品一区二区三区| 久久国产精品成人片免费| 亚洲一区二区三区日本久久九| 亚洲乱亚洲乱淫久久| 中文字幕精品久久| 99久久精品免费看国产一区二区三区 | 久久频这里精品99香蕉久| 久久亚洲精品无码aⅴ大香| 久久精品人人做人人妻人人玩| 国产一级做a爰片久久毛片| 久久久国产99久久国产一| 狠狠色婷婷综合天天久久丁香| 久久天天躁狠狠躁夜夜av浪潮| 午夜精品久久久久久毛片| 蜜臀久久99精品久久久久久| 久久精品中文无码资源站 | 久久九九久精品国产| 精品免费久久久久久久| 久久精品国产亚洲AV久| 成人亚洲欧美久久久久| 2021久久精品国产99国产精品| 久久久久久精品免费看SSS| 久久激情五月丁香伊人| 97久久精品人人澡人人爽| 99久久免费国产精品热| 日日噜噜夜夜狠狠久久丁香五月| 综合久久给合久久狠狠狠97色| 九九热久久免费视频| 伊人热人久久中文字幕| 久久久精品一区二区三区| 久久99久久99精品免视看动漫| 亚洲精品无码成人片久久| 久久精品国产清自在天天线 | 潮喷大喷水系列无码久久精品| 亚洲国产精品无码成人片久久| 国产精品乱码久久久久久软件| 久久人人爽人人爽人人片AV不|