文件名称:postfix-notation
介绍说明--下载内容均来自于网络,请自行研究使用
1、给出文法如下:
G[E]
E->T|E+T
T->F|T*F
F->i(E)
对应的转化为逆波兰式的语义动作如下:
E-> E(1)op E(2) {E.CODE:= E(1).CODE||E(2).CODE||op}
E->(E(1)) { E.CODE := E(1).CODE}
E->id { E.CODE := id}
2、利用实验5中的算符优先分析算法,结合上面给出的语义动作实现逆波兰式的构造;
3、利用栈,计算生成的逆波兰式,步骤如下:
1)中缀表达式,从文本文件读入,每一行存放一个表达式,为了降低难度,表达式采用常数表达式;
2)利用结合语法制导翻译的算符优先分析,构造逆波兰式;
3)利用栈计算出后缀式的结果,并输出;-1 gives grammar as follows: E [E] E-> T | E+ T T-> F | T* F F-> i (E) the corresponding inverse Polish into semantic action as follows:
E-> E (1) op E (2) {E.CODE: = E (1) .CODE || E (2) .CODE || op}
E-> (E (1)) {E.CODE: = E (1) .CODE}
E-> id {E.CODE: = id}
2, the use of experimental 5 operator priority analysis algorithms, combined with semantic actions given above structure to achieve reverse Polish notation
3, the use of the stack, calculates the resulting Reverse Polish Notation, as follows:
1) infix expression, read a text file, each line deposited an expression, in order to reduce the difficulty of using a constant expression expression
2) the use of binding syntax directed translation of operator priority analysis, structural inverse Polish
3) Using the calculated postfix stack of results and outputs
G[E]
E->T|E+T
T->F|T*F
F->i(E)
对应的转化为逆波兰式的语义动作如下:
E-> E(1)op E(2) {E.CODE:= E(1).CODE||E(2).CODE||op}
E->(E(1)) { E.CODE := E(1).CODE}
E->id { E.CODE := id}
2、利用实验5中的算符优先分析算法,结合上面给出的语义动作实现逆波兰式的构造;
3、利用栈,计算生成的逆波兰式,步骤如下:
1)中缀表达式,从文本文件读入,每一行存放一个表达式,为了降低难度,表达式采用常数表达式;
2)利用结合语法制导翻译的算符优先分析,构造逆波兰式;
3)利用栈计算出后缀式的结果,并输出;-1 gives grammar as follows: E [E] E-> T | E+ T T-> F | T* F F-> i (E) the corresponding inverse Polish into semantic action as follows:
E-> E (1) op E (2) {E.CODE: = E (1) .CODE || E (2) .CODE || op}
E-> (E (1)) {E.CODE: = E (1) .CODE}
E-> id {E.CODE: = id}
2, the use of experimental 5 operator priority analysis algorithms, combined with semantic actions given above structure to achieve reverse Polish notation
3, the use of the stack, calculates the resulting Reverse Polish Notation, as follows:
1) infix expression, read a text file, each line deposited an expression, in order to reduce the difficulty of using a constant expression expression
2) the use of binding syntax directed translation of operator priority analysis, structural inverse Polish
3) Using the calculated postfix stack of results and outputs
(系统自动生成,下载前可以参看下载内容)
下载文件列表
postfix notation.cpp