• <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術語的區別:
            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) 評論(0)  編輯 收藏 引用 所屬分類: Dev log

            国产一区二区三精品久久久无广告| 亚洲欧美另类日本久久国产真实乱对白| 久久久www免费人成精品| 亚洲综合精品香蕉久久网| 国产精品无码久久综合| 狠狠精品久久久无码中文字幕 | 人妻无码久久精品| 久久精品国产亚洲AV香蕉| 国产一久久香蕉国产线看观看| 久久国产三级无码一区二区| 亚洲国产高清精品线久久| 伊人久久大香线蕉亚洲五月天| 一级做a爱片久久毛片| 久久久久亚洲av综合波多野结衣| 婷婷综合久久中文字幕| 久久强奷乱码老熟女网站| 国产叼嘿久久精品久久| 色婷婷综合久久久久中文一区二区| 久久精品成人欧美大片| 久久国产精品99国产精| 少妇熟女久久综合网色欲| 国产2021久久精品| 久久亚洲精精品中文字幕| 无码任你躁久久久久久老妇App| 97精品国产97久久久久久免费| 久久久久久毛片免费播放| 2020国产成人久久精品| 午夜肉伦伦影院久久精品免费看国产一区二区三区 | 亚洲中文字幕久久精品无码APP| 精品一久久香蕉国产线看播放 | 色99久久久久高潮综合影院| 久久午夜电影网| 久久综合久久综合九色| 久久久久亚洲Av无码专| 亚洲国产精品久久电影欧美| 久久亚洲sm情趣捆绑调教| 色欲综合久久躁天天躁| 色播久久人人爽人人爽人人片aV| 日本久久久久久久久久| 无码国内精品久久综合88| AV无码久久久久不卡蜜桃|