[英]How to generate a postfix notation from code segment?
任何人都可以在不使用任何编程语言工具的情况下解释一下,将代码段(不是表达式)转换为后缀表示法的规则是什么....谢谢我提前感谢您的回复
Intermediate Code, and Final Code uses prefixed notation, not posfixed Notation.中间代码和最终代码使用前缀表示法,而不是后固定表示法。
Example (Prefixed Notation) :示例(前缀符号):
Sum B, Mem[6455];
Example (Posfixed Notation) :示例(带固定符号):
B, Mem[6455], Sum
Let's suppose you mean "prefixed notation".假设您的意思是“前缀符号”。
There are two groups of instructions that can be converted into a prefixed notation.有两组指令可以转换为前缀符号。
The first are expressions like:第一个是像这样的表达式:
somevar <- (x + y);
Second, non return functions also know as "procedures" or "subroutines".其次,非返回函数也称为“过程”或“子程序”。
GotoXY(Column, Row);
In the second, the I'd of the function becomes the prefixed Id.在第二个中,函数的 Id 成为前缀 Id。 of the instruction, followed by the parameters.
指令,后跟参数。
GotoXY Column, Row
Usually the Id.通常是Id。 Indicates an address:
表示地址:
Load RegisterA, Column;
Load RegisterB, Row;
Load RegisterC, GotoXY
Call RegisterC
This may differ from one intermediate code to another.这可能因一个中间代码而异。
It's common, to have both expressions and instructions combined.将表达式和指令结合使用是很常见的。
GotoXY (Sum(Delta, W), B - Z);
So, you may have to transform the inner expressions and inner functions calls first.因此,您可能必须首先转换内部表达式和内部函数调用。
假设您正在尝试将中缀符号转换为后缀, Shunting-yard Algorithm可能是您正在寻找的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.