Coder Social home page Coder Social logo

Comments (5)

gaoxinge avatar gaoxinge commented on July 19, 2024
  • when there are tokens to be read
    • read a token
    • if the token is a number, add it to the output queue
    • if the token is an operator o1
      • while there is an operator o2 at the top of the operator stack, and safisfies that either o1 is left-associative and its precedence <= o2 or o1 is right-associative and its precedence < o2
        • pop o2 from the operator stack, and add it to the output queue
      • push o1 to the operator stack
    • if the token is a function, push it to the operator stack
    • if the token is a left parenthesis, push it to the operator stack
    • if the token is a comma
      • while the top of the operator stack is not left parenthesis
        • pop the operator from the operator stack, and add it to the output queue
      • if there is no left parenthesis encountered, either the comma was misplaced or the parenthesis were mismatched
    • if the token is a right parenthesis
      • while the top of the operator stack is not left parenthesis
        • pop the operator from the operator stack, and add it to the output queue
      • if there is no left parenthesis encountered, the parenthesis were mismatched
      • pop the left parethesis from the operator stack
      • if the token at the top of the operator stack is a function
        • pop it from the operator stack, and add it to the output queue
  • when there are no more tokens to be read
    • when there are operators in the operator stack
      • if the operator at the top of the stack is a left parenthesis, the parenthesis were mismatched
      • pop the operator from the operator stack, and add it to the output queue
  • exit

from calculator.

gaoxinge avatar gaoxinge commented on July 19, 2024

attention1

  • transfer infix expression into postfix expression
    • output queue
    • operator stack
  • transfer infix expression into value
    • operand stack
    • operator stack

from calculator.

gaoxinge avatar gaoxinge commented on July 19, 2024

attention2

  • transfer infix expression into postfix expression
    • can not check the operand number of an operator
    • can not check the parameter number of a function
  • transfer infix expression into value
    • can check the operand numer of an operator
    • can check the paramter number of a function

from calculator.

gaoxinge avatar gaoxinge commented on July 19, 2024

attention3

  • the parenthesis were mismatched
    • there is no corresponding left parenthesis before the comma
    • there is no corresponding left parenthesis befoe the right parenthesis
    • there is no corresponding right parenthesis after the left parenthesis

from calculator.

gaoxinge avatar gaoxinge commented on July 19, 2024

attention4

  • operand is float
  • support the function without paramters or non-fixed length paramters

from calculator.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.