SEN-109:00040 Expression Evaluation: module / pattern-matching / generics / traits #8

Open
opened 2025-01-15 13:01:33 +07:00 by winsdominoes · 0 comments
Owner

You are given a partial starter code for a command-line interface (CLI) application in Rust. The application we will be building is an arithmetic expression evaluator. The application is essentially a simple calculator, but is implemented in a way that it extracts the input using a tokenizer, parses the expression into an abstract syntax tree, then evaluates the expression from the tree. This is similar to the way most compilers / REPL interpreters are implemented.

For example, if a user enters the following arithmetic expression on the command line:

1+2*3.2+(4/2-3/2)-2.11+2^4

The tool will print out the result 21.79.

In addition to basic arithmetic expression, our expression evaluator can also calculate bitwise AND (operator &) and bitwise OR ( operator | ) only for integer input operands. So the expression 6&4|2 will print out the result 6.0.

Your task is to complete the implementation of the given application. You may also modify the starting code to make sure that your expression evaluator works as expected. Please upload an archive of your source file for the submission.

Reference: You may also refer to the reading and example on Chapter 2: A Tour of the Rust Programming Language, Practical System Programming for Rust Developers book for detailed discussion on the design of the application. But please make sure to complete the code for this assessment by yourself!

You are given a partial starter code for a command-line interface (CLI) application in Rust. The application we will be building is an arithmetic expression evaluator. The application is essentially a simple calculator, but is implemented in a way that it extracts the input using a tokenizer, parses the expression into an abstract syntax tree, then evaluates the expression from the tree. This is similar to the way most compilers / REPL interpreters are implemented. For example, if a user enters the following arithmetic expression on the command line: 1+2*3.2+(4/2-3/2)-2.11+2^4 The tool will print out the result 21.79. In addition to basic arithmetic expression, our expression evaluator can also calculate bitwise AND (operator &) and bitwise OR ( operator | ) only for integer input operands. So the expression 6&4|2 will print out the result 6.0. Your task is to complete the implementation of the given application. You may also modify the starting code to make sure that your expression evaluator works as expected. Please upload an archive of your source file for the submission. Reference: You may also refer to the reading and example on Chapter 2: A Tour of the Rust Programming Language, Practical System Programming for Rust Developers book for detailed discussion on the design of the application. But please make sure to complete the code for this assessment by yourself!
winsdominoes added this to the CMKL - Spring 2025 project 2025-01-15 13:01:33 +07:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: winsdominoes/cmkl#8
No description provided.