سؤال

I have seen some code samples which convert infix to postix expressions which include precedence table for operator, as well as have logic for parsing braces. Here is my point.

If braces are part of input then we dont need precendence table, while converting infix to postfix. In other words we need precendence table iff braces are not part of input.

Am I correct ?

هل كانت مفيدة؟

المحلول 2

If the infix expression is fully parenthesized, then no, you don't need a precedence table.

نصائح أخرى

If braces are part of input then we dont need precendence table, while converting infix to postfix. In other words we need precendence table iff braces are not part of input.

That's only true if the input expression is fully parenthesised according to the desired precedence. You can't assume that. Implementing precedence isn't so difficult that you should be looking for excuses to omit it. See here for how.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top