piclist 1998\10\07\170104a >
Thread: FORTH / Expression parsing
face BY : Scott Dattalo email (remove spam text)

John Payson wrote:

> For a PICbasic-style interpreter, a postfix representation of expressions
> is generally far superior to an infix one (prefix can sometimes be okay,
> but the execution stack can get a little complicated).  Conversion of an
> infix expression to prefix, postfix, or result (i.e. evaluation of the
> expression) isn't too hard to write but a lot of the code ends up looking
> a bit redundant.  Assuming you have routines to 'peek' at and 'munch' the
> next token in the input stream, things proceed pretty straightforwardly:

<algorithm snipped>

I've written an RPN type equation parser in CPP (for Borland) that does
what you describe - except it doesn't spew pic code.


Maybe this be could be the basis for gpforth?


PS - Several people have told their inability to compile my parser.
That's because I (foolishly) used Borland's non-standard containers.
Perhaps after gpsim settles I'll fix that design bug.

<361B71B9.F36002BE@unix.sri.com> 7bit

See also: www.piclist.com/techref/index.htm?key=forth+expression
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) FORTH / Expression parsing

month overview.

new search...