No announcement yet.

Discussion on Reverse Polish Notation (Sourcecode)

  • Filter
  • Time
  • Show
Clear All
new posts

  • Discussion on Reverse Polish Notation (Sourcecode)


    This is just a thread for you to engage in the discussion on the Reverse Polish Notation implementation.


    So here we are, this is the end.
    But all that dies, is born again.
    - From The Ashes (In This Moment)

  • #2

    It looks pretty good imo, yet I only have PBCC3 so it doesn't run for me as is,

    but it looks like it works, and a lot going on there, I assume you want honest critique

    a honestly it looks like a powerful piece of code, yet I think it's overkill for parsing an equation, look at all the variables that need to be stored, which costs time,

    what I think is most efficient is, since you have a limited number of alpha chars to parse, ie SIN, TAN, etc, we should hard code the filtering, ie (read it)

    for SIN, for instance, on "S" jump to code to look for "I" next, if not "I" or no other alpha of interest, then "syntax error", etc, (resolving or terminating SIN w/ a "(", also allowing for the whitespace/s),

    if you take care in spacing the jump distance in the source, the near jumps are superfast,

    I now remember that i did have a more complete example running, I'll try to find tonight, anyway just some ideas, otherwise it looks good!


    • #3
      Polish notation

      Coding a math parser is indeed very complex. If you search the source code forum for 'math parser' you will find a couple of fairly complete parsers written in PB in 2003. I have not done much coding recently so my memory is not fresh but my parser converts input into Polish notation using a non-recursive process. For added speed the operators were recoded as numbers rather than strings. The whole algorithm was extremely fast. How it exactly works can only be understood by working an example through with pencil and paper and the code in front of you. Erik Christensen also wrote a very complete and elegant parser in PB.
      Hope this helps.
      Gunar Zagars.