View this PageEdit this Page (locked)Attachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

The Imagineers, Milestone III Case

laTex Equations

This essentially was a parser for the formatting language called LaTeX. We were assigned to parse a strict subset of LaTeX and display MathEquations based on the LaTeX. We were given the following options:

1. Use T-Gen (a Squeak lex/yacc parser generator).
2. Write our own parser.

Due to the complexity of T-Gen and the simplicity of the LaTeX we needed to parse, we went with a recursive descent parser. We further simplified our design by assuming that because LaTeX is a language for graphical formatting, all that mattered was that our parser resulted in an equation that appeared correct, not necessarily one that parsed into precisely the correct objects. We did this by heavily using the MathSequence object to generate strings, and by throwing unrecognized formats (plain strings) into a MathString object, and then generating a full MathEquation from the Sequence.

Here is a bit of a better explanation. To parse the LaTeX string:


We would progressively ask for each LaTeX type to be parsed (we had an object for each LaTeX type), and sucessful parses return an object. All parsed objects are placed into a MathSequence, which is in turn a MathEquation. The above would parse to something like this:

MathSequence(MathString(y),MathString(=),MathFraction(MathSequence(MathString(s),MathString(i),MathString(n)) / MathSequence(MathString(c),MathString(o),MathString(s))))

This is not correct in terms of objects, but the generated graphic looks absolutely beautiful =)

Thats it! Fairly simple project, that only took us a few hours.

Code:Missing File (/cs2340/uploads/ and graphics.tar...unzip the tar file and put the graphics that are inside it in the same directory as your image

To make it go, type
"a := MathEquationLaTeX from:"
then a string of laTeX that you would like to see rendered as a form,
then " .a display".
This will show you the laTeX string that you wrote.

The Imagineers are:

Links to this Page