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…
| Nhà phát triển | Dr.-Ing. Frank-Rene Schäfer |
|---|---|
| Phiên bản ổn định | 0.59.6
/ 14 tháng 7 năm 2011 |
| Hệ điều hành | Cross-platform |
| Thể loại | Công cụ Phân tích từ vựng |
| Giấy phép | LGPL |
| Website | quex.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 C và C++. 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
- Phân tích từ vựng
- Descriptions of Thompson construction and Hopcroft optimization can be found in most textbooks on compiler construction such as Compilers: Principles, Techniques, and Tools.
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.
- 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:
- 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.
- 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.
- 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.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.