My request is to make a compiler that transforms an expression like "add(5, mul(3, sub(10, pow(6, 4))))", in a equivalent mathematical expression, "5 + 3 * (10 - 6^4)" in this case.
Functions: add(x, y) (addition), sub(x, y) (subtraction), mul(x, y) (multiplication), div(x, y) (division), mod(x, y) (modulo), pow (x, y) (power), where x, y are operands
Operand: a number conforming to the following grammar:
<number> ::= <optional-sign> <digit-sequence> <optional-fraction> <optional-exponent>
<optional-sign> ::= "" | "+" | "-"
<optional-fraction> ::= "" | "." <digit-sequence>
<optional-exponent> ::= "" | "e" <optional-sign> <digit-sequence>
<digit-sequence> ::= <digit> | <digit> <digit-sequence>
<digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
Other elements: brackets ( and ) and whitespace (in the evaluated expression, there can be any number of whitespace characters, like spaces)
Desired result: A mathematical expression equivalent to the specified composition of functions. Make sure the order of operation application stays the same. Unnecessary brackets should be omitted.
The operator precedence has three levels, from lowest to highest:
1: +, -
2: *, /, %
The ^ operator is right associative, other operators are left associative.
Implementation language: C, C++ or Java
For lexical analysis you must regular expressions and finite automata; for syntax analysis, use context-free grammars and precedence-based parsing, NO RECURSION!
ALL PARTS OF THE CODE MUST BE LARGELY COMMENTED!
12 freelancers are bidding on average €67 for this job
Hello, sir. I have read your project details carefully. I am very interesting with your project. I have ever wrote C programe for the job just because of interesting. So i have already the solution.
To whom it may concern. As a fully experienced sw developer, I can say that it is very easy to make such program. I can make this in any of following languages. java/c++/python Feel free to contact me. Warm regards.
Hi there,thank you for your posting project. I have checked your project and I am very interested in your proejct. I can complete your proejct within a short time. Thank you.