如何用 C 或C++ 编写简单的 compiler (scanner and parser) .
用以下Context Free Grammar(CFG) 编写一个简单的编译程序
<PROGRAM> → <STMTS>
<STMTS> → <STMTS> <STMT> | <STMT>
<STMT> → <ASSIGNMENT_STMT> | <IF_STMT> | <PRINT_STMT>
<ASSIGNMENT_STMT> → variable = integer ; | variable = <EXPRESSION> ;
<EXPRESSION> → <EXPRESSION> + <TERM> | <EXPRESSION> - <TERM> |
<TERM>
<TERM> → <TERM> * <FACTOR> | <TERM> / <FACTOR> | <FACTOR>
<FACTOR> → variable | ( <EXPRESSION> ) | integer
<IF_STMT> → if ( <CONDITION> ) then <STMTS> endif
<PRINT_STMT> → variable ;
<CONDITION> → <VALUE> <COND_OP> <VALUE>
<VALUE> → variable | integer
<COND_OP> → = | < | > | <= | >=
本人对如何将CFG 用C或C++表达不是很清楚, 希望可以得到大家的帮助, 谢谢.