Answer the question
In order to leave comments, you need to log in
How to make a parser checkmate. expressions in which arguments can have length greater than 1?
In general, I figured out an example of how to calculate a mathematical expression, but at the moment the program calculates examples in which the arguments are in the range from 0 to 9.
How can I make the arguments be, for example, from 0 to 10k?
It would be possible to compare the range with the string "10000" in the range check, but xs how it will first pull out what is needed from the input string, it is not clear, for example, from the string 954 + *, what to take, 9 or 95 for example.
Stack for converting infix notation to postfix
Code for converting infix notation to postfix
Postfix notation parser and expression evaluation
Answer the question
In order to leave comments, you need to log in
First, describe the minimal language of your expressions:
<выражение> ::= <литерал> <оператор> <литерал>
<литерал> ::= <число> | (<выражение>)
<число> ::= [<число> | "-"]<0-9> // или всё, что парсится parseInt.
<оператор> ::= < + | - | * | / >
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question