• <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://www.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   管理


            精品亚洲综合久久中文字幕| 久久久国产精品网站| 性高湖久久久久久久久AAAAA| 久久久久人妻精品一区三寸蜜桃| 色婷婷噜噜久久国产精品12p | AAA级久久久精品无码片| 国产精品久久久久久福利69堂| 久久影院午夜理论片无码| 色欲久久久天天天综合网| 国产69精品久久久久9999| 99久久夜色精品国产网站| 久久九九免费高清视频| 亚洲国产欧洲综合997久久| 久久国产精品二国产精品 | avtt天堂网久久精品| 亚州日韩精品专区久久久| 一本一道久久精品综合| 久久99国产乱子伦精品免费| 中文字幕亚洲综合久久菠萝蜜| 91久久精品无码一区二区毛片| 久久精品国产亚洲αv忘忧草 | 亚洲一区中文字幕久久| 久久香蕉国产线看观看精品yw| 思思久久99热免费精品6| 成人a毛片久久免费播放| 久久国产精品99精品国产987| 久久亚洲精品国产精品| 无码超乳爆乳中文字幕久久 | 精品国产福利久久久| 久久精品无码专区免费东京热 | 国产成人久久精品一区二区三区| 久久久久婷婷| 亚洲精品国产自在久久| 漂亮人妻被中出中文字幕久久| 久久综合狠狠综合久久97色| 要久久爱在线免费观看| 亚洲精品99久久久久中文字幕| 久久天天躁夜夜躁狠狠| 97精品依人久久久大香线蕉97| 精品久久久久久无码不卡| 狠狠色婷婷久久一区二区|