FORTH / Expression parsing
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:
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.
See also: www.piclist.com/techref/index.htm?key=forth+expression
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the