• <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

            有用的東西

            最新評論

            DFA和lexical analysis

            對于hand written的lexical analyzer來說,NFA和DFA的運用是不可避免的,除非你的grammer十分簡單。
            一旦給出了source program(也就是你想處理的character stream)的一個pattern的正則表達式,就可以構造對應的NFA,然后轉換為DFA,這個DFA就可以用來處理你的source program, 將里面能夠match這個pattern的lexeme全都找出來。按照這樣的流程,對于一種編程語言,不管是常用的語言,還是腳本語言,只要對所有的pattern構造DFA,就能夠寫出自己的lexical analyzer了。
            有兩篇關于正則表達式到DFA的文章寫的很好:
            1.Writing own regular expression parser By Amer Gerzic英文的
            http://www.codeproject.com/KB/recipes/OwnRegExpressionsParser.aspx
            有源碼
            2. 《構造正則表達式引擎》新鮮出爐啦!中文的,by vczh,華南理工大學
            http://m.shnenglu.com/vczh/archive/2008/05/22/50763.html
            閱讀完上面兩篇文章,寫個能夠運行的lexer就不成問題了。
            另外附上龍書(Compilers, principles techniques and tools)里一段token,pattern和lexeme術語的區(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 閱讀(524) 評論(0)  編輯 收藏 引用 所屬分類: Dev log

            无码专区久久综合久中文字幕| 日韩人妻无码精品久久久不卡 | 久久九九亚洲精品| 久久99精品国产麻豆不卡| 激情久久久久久久久久| 日韩精品久久久久久| 亚洲伊人久久综合影院| 久久不见久久见免费视频7| 国产农村妇女毛片精品久久| 久久久久久国产精品美女| 久久福利青草精品资源站免费| 久久综合给合综合久久| 久久国产乱子精品免费女| 久久精品国产99国产精品导航| 精品久久久久久中文字幕| 久久精品国产亚洲av麻豆图片 | 久久久久无码中| 久久亚洲春色中文字幕久久久| 久久人人爽人爽人人爽av | 久久人人爽人人爽人人片AV东京热| 亚洲精品无码专区久久同性男| 日本人妻丰满熟妇久久久久久| 久久精品国产国产精品四凭| 国产精品欧美久久久天天影视| 青青草原综合久久大伊人导航| 久久久久久无码Av成人影院| 国产精品成人久久久| 久久久久国产日韩精品网站| 成人资源影音先锋久久资源网| 亚洲精品美女久久久久99| 久久精品极品盛宴观看| 欧美激情精品久久久久久久九九九| 久久国产亚洲高清观看| 麻豆成人久久精品二区三区免费| 久久青青草视频| 亚洲国产综合久久天堂| 青青草国产97免久久费观看| 香蕉久久夜色精品国产2020| 欧美午夜A∨大片久久| 色偷偷88欧美精品久久久| 久久久中文字幕日本|