polish to BNF via recrusive

  1. Implement a recursive function?evalPolish(expression)?that shall evaluate (calculate) an expression written in the?. The expression shall be defined recursively in the??(BNF):

    1. expression ::= integer_or_floating_point_number #?A number is an expression; its value is the number itself
    2. expression ::= (operator, expression, expression) #?A 3-element tuple of an operator and another two expressions is also an expression; its value is the operator applied to the values of the expressions
    3. operator ::= “+” | “-” | “*” | “/” #?The list of supported operators; feel free to extend it

    全优代写 - 北美Essay代写,Report代写,留学生论文代写作业代写Here is a sample expression and its evaluation:

    >>> good = ("+", ("-", 3, 1), ("*", ("/", 3, 4), 7)) # Same as

Leave a Reply

Your email address will not be published. Required fields are marked *