1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Grammar for Backus-Naur form postfix add/subtract

  1. Oct 31, 2013 #1
    I'm looking to write a grammar in Backus-Naur form for postfix addition and subtraction expressions involving the variables A,B,C

    Given the infix grammar:
    <expr> ::= <expr> + <term> | <expr> - <term> | <term>
    <term> ::= <term> * <factor> | <term> / <factor> | <factor>
    <factor> ::= (<expr>) | <id>
    <id> ::= A|B|C

    I assume that I need to create a parse tree, first, using the above grammar for an infix expression such as A + B + C and than traverse the parse tree in reverse order and read out the postfix version to form a postfix grammar?

    Would this be a valid way to go about this?
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?



Similar Discussions: Grammar for Backus-Naur form postfix add/subtract
Loading...