zoukankan      html  css  js  c++  java
  • 练习使用文法剖析工具:

                                   练习使用文法剖析工具


    yacc/bison 與 lex/flex

    1. 將本目錄的程式全部 copy 回你家.
    2. 下 make 命令, 會自動產生可執行檔 babylang
    3. 執行 ./babylang 即可輸入運算式 (只能夠有數字, 加, 乘, 小括弧). 要按 enter 並按 ^d 才表示輸入結束.
    4. 程式會印出該運算式的 parse tree.
    5. 作業: 請修改 grammar.y0, 讓你的程式可以分析邏輯運算式. !, &, | 等三個邏輯運算子當中, not (!) 的優先順序最高, 其次是 and (&), 最後是 or (|) 例如輸入 a & b | ! c & d 應該要印出類似下面的結果: [檔案產生流程]
      expr
          expr
              term
                  term
                      factor
                          a
                  &
                  factor
                      b
          |
          term
              term
                  factor
                      !
                      factor
                          c
              &
              factor
                  d
           
      
      修改過 grammar.y0 之後, 要記得重新 make, 才會產生新的 babylang.

    syngen

    1. SYNGEN 可以從一種類似 EBNF 的純文字檔產生出一個 syntax diagram
    2. 從上述網址出發, 取得 文件linux 版可執行檔
    3. 不論是 syngen 的文件, 或是它所產生的圖, 都是 postscript 檔, 所以要用 ghostscript 與 ghostview 來看. 在 linux 下, 可以直接使用 gv 命令; 在 windows 下, 要先下載 windows 版 的 ghostscript 與 ghostview.
    4. Login 到你的 penguin 帳號, 並將本目錄下的檔案全部 copy 回你的網頁子目錄: cp -a ~ckhung/public_html/b/pr/gr/ ~/public_html
    5. 在 ~/public_html/gramtut 內下 make syndia.ps
    6. 把你的瀏覽器指到 http://penguin.im.cyut.edu.tw/~sxxxxxxx/gramtut/syndia.ps 並指定用 gv 開啟這類 (postscript) 檔案.
    7. 以後每次修改過 syndia.mara 就重新 make syndia.ps 並重新整理你的網頁
    8. 其實你也可以下 make syndia.tiff 就可以讓 penguin 下所安裝的 gs 命令從 syndia.ps 產生 syndia.tiff, 這樣你的 windows 不需要裝 gv 就可以看了. 不過轉換時間很長 (1 分鐘?) 且轉出來的圖解析度低.

    其他相關程式

    1. showgrammar: a Python script to convert a yacc grammar to syntax diagrams.


    Warning: main(footer.php): failed to open stream: No such file or directory in /usr0/teacher/im/ckhung/public_html/b/pr/gr/index.php on line 110

    Warning: main(): Failed opening 'footer.php' for inclusion (include_path='.:/usr/local/php4/lib/php') in /usr0/teacher/im/ckhung/public_html/b/pr/gr/index.php on line 110

     相关链接:http://www.cyut.edu.tw/~ckhung/b/pr/gr/

  • 相关阅读:
    Team Foundation Server 2010
    Visual Studio 2010 建模学习 与TFS工作项进行集成
    Asp.net动态生成页面控件的办法
    信息系统开发平台OpenExpressApp - 学习必备知识
    如何培养一个人:从育儿谈起
    ExtJS 资料
    在asp.net中动态生成web控件1
    团队发展五阶段
    C#动态生成控件以及添加事件处理
    Learn More,Study Less!
  • 原文地址:https://www.cnblogs.com/enjoy233/p/3027379.html
Copyright © 2011-2022 走看看