• <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://www.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久久 | 久久久久亚洲av综合波多野结衣| 久久久亚洲裙底偷窥综合| AAA级久久久精品无码片| 久久99精品久久久久久野外| 久久青青草视频| 久久被窝电影亚洲爽爽爽| 一级做a爰片久久毛片毛片| 亚洲国产精品无码成人片久久| 欧美亚洲国产精品久久蜜芽| 97视频久久久| 国内精品久久久久久不卡影院| 久久人人爽人人爽人人片AV麻烦| 99久久99久久精品国产片果冻| 久久亚洲AV成人无码软件| 91久久精品无码一区二区毛片| 亚洲综合精品香蕉久久网| 品成人欧美大片久久国产欧美| 人妻少妇久久中文字幕一区二区| 狠狠久久综合伊人不卡| www.久久精品| 精品一二三区久久aaa片| 久久国产精品视频| 99久久www免费人成精品| 国产精品18久久久久久vr | 久久免费视频一区| 亚洲国产精品久久久久婷婷老年 | 婷婷久久综合九色综合98| 久久发布国产伦子伦精品| 人妻精品久久久久中文字幕一冢本| 思思久久99热免费精品6| 久久93精品国产91久久综合| 国产福利电影一区二区三区久久久久成人精品综合 | 亚洲国产综合久久天堂 | 性做久久久久久久久| 久久伊人五月天论坛| 久久久艹| 四虎亚洲国产成人久久精品|