


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



The Mathematical Interpreter in Java (Mij) is a system that accepts simple mathematical expressions from the user and calculates the numeric results. For example, here is a sample run of the program (user input shown in italics):
4 * 3^2 โ 2 * 3 + 1
set(x, 3)
4 * x^2 โ 2 * x + 1
cos(Pi) -1. int(2*sin(x), x, 0, 2 * Pi) -1.1038300434557547E-
The expressions entered by the user must match the following grammar:
AddExpr โ AddExpr AddOp MultExpr | MultExpr AddOp โ + | - MultExpr โ MultExpr MultOp ExponExpr | ExponExpr MultOp โ * | / ExponExpr โ UnaryExpr ^ ExponExpr | UnaryExpr UnaryExpr โ AddOp ValueExpr | ValueExpr ValueExpr โ id | number | ( AddExpr ) | id ( ) | id ( Params ) Params โ AddExpr | AddExpr , Params
Within the grammar, the id type is an identifier name, like variable names in Java. These identifiers can start with a letter or underscore, and can contain any number of letters, numbers, or underscores.
This lab has the following two stages:
Stage 1: Identifying Iterator Pattern
Identify the classes that participate in each of the two instances of the iterator pattern in the system. Follow the official iterator pattern UML class diagram and identify the role of each of these classes within the pattern.
Stage 3: Identifying the interpreter pattern.
Identify the classes that participate in the interpreter pattern, and their roles within the pattern. Draw its UML class diagram.