Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

## Squeak Core Dumpers

SqueakCoreDumpers

### Team Members:

http://www.prism.gatech.edu/~gt6832a

http://www.prism.gatech.edu/~gte644h

http://www.prism.gatech.edu/~gte993k

Sample output:

# In P3, we made a MathEquation editor to create graphical equations via text input in the LaTeX format.

The following types of string would be accepted:

• Normal letters, numbers, and most punctuation.
• Greek letters created by preceding the name of the letter with '\', e.g., \alpha)
• Curly braces created by escaping with '\', e.g., \{ and \}.
• Backslash created by escaping itself, e.g., \\.
• #, \$, % &, ~, _, and ^ also created by escaping with '\',
• Fractions created with \frac{x}{y} where X and Y are the numerator and denominator respectively.
• Superscripts created with ^{s}, as in x^{2} to define x-squared.
• Subscripts created with _{s}, as in x_{i} to define x-sub-i.

Implementation

In doing this project we had to develop a grammar to handle this kind of a graphing tool. However, at this stage we realized what steps would be needed to not just to display a math equation but to evaluate them as well. This would make the tool we developed able to be used as a calculator as well as a displaying tool.

Originally, we made our design to handle only the graphing aspect of the problem. When the project was developing, we then realized that the changes we made to the grammar could handle not only the drawing aspect drawing, but also it could be used to handle evaluation as well, should a need for this arise. The grammar was adapted from the sample grammar given on the coweb by Brian McNamara with some changes. This alteration could be done by adding code that accumulates the value of each token in the action portion of each rule and passes it back to a global variable (which each message can see). We then can print this value out after finishing parsing the whole expression. The key changes we made to the grammar to handle this is making it handle numbers and proper parentheses.

Our original UML design looked like this and here is the corresponding CRC diagram.

After changes, our UML looked like this.

Instead of having to write the same code again to implement the math equation evaluator, we can take advantage of our original OO design by simply adding to it. This can be done since our design allows us to reuse the code.

The following grammar would allow us to so this:

<Exp> ::= <Term> <op> <Exp> | <Term>

<Term> ::= <factor> <RestTerm>

<factor> ::= <fraction> | { Exp } | ( Exp ) | <text>

<fraction> ::= \frac {Exp} {Exp} | \frac (Exp) (Exp)

<RestTerm> ::= ^{Exp}RestTerm | _{Exp}RestTerm | lambda

<text> ::= <char> <text> | <char>

<char> ::= <greeks> | <puncts> | <specialChars> | <regChars> | <numbers>

<greeks> ::= \alpha | \beta| …

<puncts> ::= \{  |  \} | …

<regChars> ::= a | A | b | B| …

<numbers> ::= [0-9]+

<op> ::= + | - | * | / | =

#### Problems encountered implementing Milestone 3

• We had to change our design in p2.5 to move expression, factor, term and token services to the Parser class in p3, since our design in p2.5 MathEquationLatex was the parser and the scanner, so it needed these services, but now the Parser class contains these services among others and will handle the parsing of the tokens.

• We initially had a parseTree that was to hold a parse tree for parsing the tokens; this was removed in favor of using the parser that did not require that.

• We decentralized the tasks handled, so that no one class will do most of the work, hence this allows usability of code and good O.O. design which will make this easier to code and maintain.

• Initially we had a Symbol class that handled all the Greek symbols, regular characters, and special characters and punctuation, so we made a more reusable and easier design by making Symbol an abstract class and then separate classes for each type we handle, so we had a GreekSymbol class, RegularCharacter class, SpecialCharacters class and Punctuation class. Thus the services that handled the different symbols in the old Symbol class had to be changed and moved to new symbol classes.

• Initially a new scanner was made in each class that required a scanner. As can be expected this resulted in very bad results, so we made from: will in the expression as a parameter and will then pass that expression to the scanner and then will pass the scanner as a parameter to the parser.

• We first tried using T-Gen to do the parsing, but this always gave us problems and did things differently form what we expected. Thus we had to stop using this and use recursion instead which worked well and handled the cases that did not work in p2, such as fractions of fractions.

Anticipated problems implementing evaluator

• In the actual implementation of the calculation part, we would probably need to make several calls to a math library to handle complex calculations such as polynomials, derivatives, etc. This may be hard to achieve if we use pure Squeak since its math libraries (if it has any) may not be powerful enough to do the job. However, there might be a short way to get around this. Since the parser would be running off the web, we could use CGI scripts to extract the results of the calculations using another language e.g. C. In this case, we would use the parser to parse the input and hand the tokens to some other module (which would be written in the other chosen language) to execute and the pass back the result. Our web server would then deliver the result to the user. The problem then boils down to communication between modules running under different compilers.

Conclusion:

Hence, we can see that it is possible to expand our original P3 program to handle the evaluation of mathematical expressions. This would enable us to make even greater use of this program. However, there are certain problems we would expect to encounter as we have discussed above. We are hoping at some point to come back and implement this part of the program, as it seems to have many uses. We welcome any suggestions or comments that you think might help us implement this phase of the program.