Quex

Quex là một công cụ phát sinh phân tích từ vựng dùng trong ngôn ngữ lập trình C và C . Các tính năng nổi trội bao gồm khả năng…

quex
Nhà phát triểnDr.-Ing. Frank-Rene Schäfer
Phiên bản ổn định
0.59.6 / 14 tháng 7 năm 2011 (2011-07-14)
Hệ điều hànhCross-platform
Thể loạiCông cụ Phân tích từ vựng
Giấy phépLGPL
Websitequex.sourceforge.net

Quex là một công cụ phát sinh phân tích từ vựng dùng trong ngôn ngữ lập trình CC++. Các tính năng nổi trội bao gồm khả năng phát sinh các phân tích từ vừng hỗ trợ đầu ra mã Unicode, tạo mã trực tiếp (loại không cần bảng) phân tích từ vựng và dùng các quan hệ kế thừa trong chế độ phân tích từ vựng.

Ví dụ

Quex theo sau cú pháp của công cụ lex cổ điển và Flex cho mô tả của biểu thức chính quy. Ví dụ trong phần Flex có thể dịch sang mã nguồn Quex như sau:

header {
  #include <cstdlib> // Phiên bản C++ của 'stdlib.h'
}

define {
  digit [0-9]
  letter  [a-zA-Z]
}

mode X:
<skip: [ \t\n\r]> 
{
  "+"   => QUEX_TKN_PLUS;  
  "-"   => QUEX_TKN_MINUS; 
  "*"   => QUEX_TKN_TIMES; 
  "/"   => QUEX_TKN_SLASH; 
  "("   => QUEX_TKN_LPAREN; 
  ")"   => QUEX_TKN_RPAREN; 
  ";"   => QUEX_TKN_SEMICOLON; 
  ","   => QUEX_TKN_COMMA; 
  "."   => QUEX_TKN_PERIOD; 
  ":="   => QUEX_TKN_BECOMES;  
  "="   => QUEX_TKN_EQL;  
  "<>"   => QUEX_TKN_NEQ;  
  "<"   => QUEX_TKN_LSS;  
  ">"   => QUEX_TKN_GTR;  
  "<="   => QUEX_TKN_LEQ;  
  ">="   => QUEX_TKN_GEQ;  
  "begin"   => QUEX_TKN_BEGINSYM;  
  "call" => QUEX_TKN_CALLSYM;  
  "const"   => QUEX_TKN_CONSTSYM;  
  "do"   => QUEX_TKN_DOSYM; 
  "end" => QUEX_TKN_ENDSYM; 
  "if"   => QUEX_TKN_IFSYM; 
  "odd" => QUEX_TKN_ODDSYM; 
  "procedure"   => QUEX_TKN_PROCSYM;  
  "then" => QUEX_TKN_THENSYM;  
  "var" => QUEX_TKN_VARSYM; 
  "while"   => QUEX_TKN_WHILESYM;

  {letter}({letter}|{digit})* => QUEX_TKN_IDENT(strdup(Lexeme));
  {digit}+ => QUEX_TKN_NUMBER(atoi(Lexeme));
.   => QUEX_TKN_UNKNOWN(Lexeme);
}

Xem thêm

Tham khảo

Liên kết ngoài

  • Quex, official website

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.