1 / 6

Lex 補充說明

Lex 補充說明. Chang Chi-Chung 2009.05.04. 工具介紹 (1). Lex and Yacc 是每套 unix-like 都必備的工具 Lex Lexical Analyzer Generator Yacc Yet Another Compiler-Compiler Linux 系統則有 Flex and Bison Flex Fast Lexical Analyzer Generator 由 Lex 所改寫,改進了原本的缺點,並且更快。 Bison

sinead
Télécharger la présentation

Lex 補充說明

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lex 補充說明 Chang Chi-Chung 2009.05.04

  2. 工具介紹(1) • Lex and Yacc 是每套 unix-like 都必備的工具 • Lex • Lexical Analyzer Generator • Yacc • Yet Another Compiler-Compiler • Linux 系統則有 Flex and Bison • Flex • Fast Lexical Analyzer Generator • 由 Lex 所改寫,改進了原本的缺點,並且更快。 • Bison • Yacc 的另一個選擇,極度相容於 Yacc,更是由鼎鼎大名的自由軟體之父 - Richard Stallman 所領導製作的。

  3. 工具介紹(2) • Lex & Yacc for windows • 如果你想要在 windows 下執行,可以參考以下網頁 • http://www.bumblebeesoftware.com/ • Java 版本的 Lex • jlex • jflex • http://www.jflex.de/

  4. 參考資訊 • Lex and Yacc 與 Visual C++的整合 • http://www.csie.nfu.edu.tw/phpBB2/viewtopic.php?p=72977 • Lex and Yacc 電子書 • http://www.epaperpress.com/lexandyacc/index.html • 編譯器工具介紹 • http://jsliu.no-ip.info/DOC/COMPILERS/

  5. Lex 的 Global Variable • Lex 的預設變數,在寫 *.l 檔的 definition & rule時,可以直接使用這些變數 • yyin • lex 的input來源,型態為 FILE * ,初始預設為stdin • yyout • lex 的input來源,型態為 FILE * ,初始預設為 stdout • yytext • 當rule中match一個pattern時,match的string就會存在 yytext中,型態為char * • yyleng • 記錄 yytext 的長度 • yylineno • 記錄目前的yyin讀到第幾行了 • yylval • an external global variable storing the attribute of the token

  6. Lex 的函數 • yylex() • 呼叫產生出的 lexical analyzer。換言之呼叫這個函數,可以得到下一個 token。 • 剩下的自己研究了!

More Related