Re: How to convert Infix notation to postfix notation
- From: spinoza1111 <spinoza1111@xxxxxxxxx>
- Date: Tue, 3 Nov 2009 08:22:16 -0800 (PST)
On Nov 3, 5:24 pm, Nick Keighley <nick_keighley_nos...@xxxxxxxxxxx>
wrote:
On 2 Nov, 17:36, Gene <gene.ress...@xxxxxxxxx> wrote:
On Nov 2, 10:48 am,spinoza1111<spinoza1...@xxxxxxxxx> wrote:
On Nov 2, 10:10 pm, Gene <gene.ress...@xxxxxxxxx> wrote:
On Oct 25, 11:33 pm, Tameem <etam...@xxxxxxxxx> wrote:
i have a string as (a+b)+8-(c/d) in Infix form.
how can i convert it to postfix form using C language,,,????
I suppose that if this is homework, the due date has passed.
<snip neat code>
Thanks for this. Looks like you stole my approach,
good grief
You snipped the other alternative, which was "great minds think
alike".
but I find that
most gratifying if true, and an indication that "great minds think
alike" if not. Your contribution at a minimum is to show just how
gnomic and terse one can be in C.
looks pretty straightforward C to me. It's clearer than yours.
I really wish people would qualify "clarity" and relativise it to
their perception. Like Seebach, you use the word "clarity" here. His
code is more to your taste: I can deal with that. But not "clearer"
except for a reader who prefers a terse style.
It would not be appropriate to
credit me since it is a common and solid algorithm that has been
around for years.
riight
Yup.
Hope you don't mind, but I'm going to copy this code and incorporate
it in what will not be a three way test: of my C Sharp version, my C
version and your gnomic C. I want to add more testing (using a random
generator in C Sharp), a GUI and timing comparisions and shall report
back.
one idea would be to make you tester() function silent. Only print
something if the test fails. This will also mean your timeing tests
are testing the algorithm rather than the i/o.
....not if the test material is a constant...
This doesn't qualify as anything like theft or great thinking. For
fun, I wrote the code in about 5 minutes after the OP posted (based onhttp://groups.google.com/group/comp.lang.c/msg/fe772c9d6a28fdc4), but
refrained from posting it because it was probably homework for the
OP. This is a standard example or homework assignment for just about
any undergrad course that covers recursive descent parsing.
I don't see the words "recursive descent parsing" in the OP
I don't think the professor taught him RDP. That would be material
introduced in a compiler course.
The
gramamr with minor variations is in at least a dozen complier design
textbooks including ASU. Usually it's given in left-recursive form,
and then the author or student go through the L-rec removal, left-
factoring, and BNF conversion. RPN generation is a trivial example of
attribute evaluation.- Hide quoted text -
- Show quoted text -
.
- Follow-Ups:
- References:
- Re: How to convert Infix notation to postfix notation
- From: Gene
- Re: How to convert Infix notation to postfix notation
- From: spinoza1111
- Re: How to convert Infix notation to postfix notation
- From: Gene
- Re: How to convert Infix notation to postfix notation
- From: Nick Keighley
- Re: How to convert Infix notation to postfix notation
- Prev by Date: Re: How to convert Infix notation to postfix notation
- Next by Date: Re: How to convert Infix notation to postfix notation
- Previous by thread: Re: How to convert Infix notation to postfix notation
- Next by thread: Re: How to convert Infix notation to postfix notation
- Index(es):
Relevant Pages
|