Comments (5)
- 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 eithero1
is left-associative and its precedence<= o2
oro1
is right-associative and its precedence< o2
- pop
o2
from the operator stack, and add it to the output queue
- pop
- push
o1
to the operator stack
- while there is an operator
- 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
- while the top of the operator stack is not left parenthesis
- 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
- while the top of the operator stack is not left parenthesis
- 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
- when there are operators in the operator stack
- exit
from calculator.
attention1
- transfer infix expression into postfix expression
- output queue
- operator stack
- transfer infix expression into value
- operand stack
- operator stack
from calculator.
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.
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.
attention4
- operand is float
- support the function without paramters or non-fixed length paramters
from calculator.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from calculator.