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

Questions on Sum2000 P3 Milestone

Ask questions here...

Can we use Lex and Yacc?

What in the world does "You should also implement
explore: which accepts the same string input, but returns the MathEquation object after the parse, so that the internal objects are inspectable." this mean? Could someone post an explanation of what they are asking for?
Collin Lobb

No you cannot use Lex or Yacc. It must all be implemented in Squeak. Use parsing stuff in Squeak or write you own.
Try sending the message explore to an instance of any object and see what comes up. Now are you getting a better picture of what we want? Eric Anderson

What are we supposed to type in to use MathOperation?
eg. \plus {2}{3}? \minus {5}{3}? \multiply {3}{4}?
can someone tell me what is BitBlt error and how do i get rid of that

As to the BitBlt error, you might want to make sure you are not sending a point that is a fractions. For example myForm displayAt: myVar where myVar = (5/3)@3. Basically you are telling Squeak that it need to display at a fraction of a pixel instead of as an Integer. Try converting or rounding your numbers before you display. Eric Anderson

Can someone post some sample LaTex input, especially something complex?
Collin Lobb

Are the normal character parens suposed to be resized based on stuff inside them?? The sentence:

A fuzzy bear(who happened to be good at math \frac{x}{\frac{55}{eorusldf}} was a pretty had equation is fine)

would make huge parens far away from the math, so it seems that it shouldn't resize.

–Michael Langford,

Should the strings passed to MathEquationLaTeX explore: start and end with $ like they do in real LaTeX??

–Michael Langford,

Why aren't the last week's lectures in Squeak Book format? I'm not
a M$ honky, so I can't read power point.

You can download a free PowerPoint viewer for Windows (and Macintosh) at
Chris Campbell

What about the Linux folks?

Well, I am fairly confident that StarOffice 5.2 from Sun can read and convert PowerPoint presentations, but I am not entirely certain. Its a huge download, runs slowly, and looks exactly like Windows running inside and X window... but it will let you view them =)

Give it a try, or you can go download them in the lab and convert them into something more universally viewable if you like.

Jonathan LaCour
Here's what I can offer in the short term: parsing-ppt.pdfMark Guzdial

Nah, no $'s in this stuff. Mark Guzdial

What is the return character( like '\n' in C) in Squeak, can someone help?

Look at the cr message that is sent to causes one...

Michael Langford –

Character cr asString should do what you want. Mark Guzdial

What are we supposed to type in to use MathOperation?
eg. \plus {2}{3}? \minus {5}{3}? \multiply {3}{4}?
can someone answer this please?

Ok... I've got a problem with Subscript and Superscript. Is there any specific format to determine what the base will be? From what I'm seeing in TGen, you can't have multiple start symbols in the grammar, which sort of makes sense. But, assuming that you could have any format for an equation to be sub/superscripted, you would need to have (for instance {Sub = Equation SubMarker Argument}, which would create a second start symbol, as Equation is defined previously for all of the possibilities. The only way around this that I see is having a separator telling you what is delimiting it, or allowing it to only be a string. HELP!!! Please.

Rich Glazerman
Brian McNamara is working on a grammar to provide you. Any time now... Mark Guzdial

Could someone post some more complicated examples of LaTeX expressions?

Here's Brian's grammar:
   Greek ::=  \alpha  |
              \beta   |

   SpecialPunct ::= \{  |  \}  |
                    \\  |  \#  |
                    \$  |  \%  |
                    \&  |  \~  |
                    \_  |  \^

   Text ::= Char |
            Char Text

   Char ::= Greek | SpecialPunct | any normal character

   Exp  ::= Term Op Exp |

   Term ::= Super       |
            Sub         |

   Foo  ::= Fraction    |
            { Exp }     |

   Fraction ::= \frac{Exp}{Exp}

   Super ::= Foo^{Exp}

   Sub   ::= Foo_{Exp}

   Op ::= + | - | * | / | 

Other Examples

\alpha + \gamma

4 + 3 - (5 * \Delta)








External Image

For TGen, in the grammar, what exactly do the directives inside the brackets do? For example, {liftRightChild}, {liftLeftChild}, {LetNode}, {PlusNode}, etc? As far as I can tell, they have no effect on the tree that TGen builds.
Also, after creating your grammar and "install"ing it, what are the commands to get it to do stuff? Say I install TestMeParser and TestMeScanner... what's the command to send them a String and get back the Tree that is generated? Thomas Annandale

The directives have to do with how data gets shuttled through the parser. Check the parser lecture notes – I don't remember the exact message names now, but I know that I figured them out for that lecture. Mark Guzdial

For the explore method. I've tried going to various objects and calling explore on them like it was suggested. Are you looking for the explorer menu like when you use ObjectExplorer on a window or are you looking for something similar to:

3 + 4

This translates to MathEquation from: (MathOperation operator: '+' with: '3' and: '4'). Shall we print out something like:

or something similar. Is THAT what you are looking for? Or can we
just go and use ObjectExplorer???
Collin Lobb

Just use ObjectExplorer! There seems to be lots of confusion on this point, so let me explain our rationale. The "explore" message is meant to be CYA for YOU!. We're concerned that some of you may get parsing right (or nearly right), but won't be able to display the equation. By having an "explore" option, we can see the results of the parse and potentially give partial credit for that EVEN IF the graphical display bombs. Does that make sense? Mark Guzdial

We've come up on a couple snags in our TGen parser. First, we tried using Brian's grammar given, but any way we arranged it, it always came out to be non deterministic. Walking through it step-by-step showed that there was a problem with:

Term ::= Super |
Sub |

Super ::= Foo^{Exp}

that it didn't like and try as we may, we could generate a sub language or change what we wanted to get a parser out of it. Is this a known problem (that Brian's grammar is non-deterministic)? Second, we built our own grammar, and got pretty far but we're stuck on subscript and superscript. The problem is based on the fact that they can't have the same object at the beginning for the base or it becomes nondeterministic since it can't figure out which to go to: the subscript or the superscript. For example:

Super ::= Foo^{Exp}
Sub ::= Foo_{Exp}

wouldn't work since it couldn't tell which one to pick. However, if we rearranged it in a prefix fashion:

Super ::= ^Foo{Exp}
Sub ::= _Foo{Exp}

it had no problem recognizing it. The idea is that if one of the scripts has something different initially (parentheses, commas, whatever), it can determine which one to choose from. This seems to be the case as well in Brian's grammar, as it has a similar form to ours. Therefore, we would need an LL(2) or more parser, which I don't believe TGen can't create. Is there something that we are missing? Thanks for any help on the matter.

Adam Blaiss

This is not an official answer cause I am not a TA or anything, but I think that the point of the project is to recognize LaTeX commands and if you change the commands then they are no longer in LaTeX and that would defeat the whole purpose... I dunno, this is just to give you an opinion so you do not go and spend half of the night working on it this way and then find out tomorrow afternoon that it was all worthless...

Agreed – you MUST parse LaTeX. Mark Guzdial

Is it okay to use a space as the delimiter for our tokens? And then the user would be required to enter 3 + 4 instead of 3+4, if we state in the instructions that this is the way it needs to be done?

Absolutely not okay. You can't force whitespace. See the examples above – these will probably be the test cases that the TA's use! Mark Guzdial

I'm having difficulties getting Tgen's scanner to recognize
the '\' character. For instance:

\alpha + 3

SCANNER ERROR: illegal character encountered:

Is '\' included as part of your tokenizer? Mark Guzdial

I've tried specifying '\' in ascii, escape sequences,
etc, but no dice.

any ideas?

Greg Bosworth
Try delimiting the \ character in quotes. or, if you're making it a terminal, try [\\]. Hope this helps. Rich Glazerman
Tried both, still no luck.

I'm testing with greek symbol token specifications:
\alpha | \beta | ...

Things I've tried:
[\\]alpha, '\'alpha, [\134]alpha, [\x%C]alpha, etc...

try '\alpha' Rich Glazerman
It was recently pointed out to me that the grammar I made above is not LL(1) and TGen requires LL(1) grammars. I have rewritten the grammar with left-factoring so it is now LL(1); I've also fixed one other "bug" in the original grammar:

Greek ::= \alpha |
\beta |

SpecialPunct ::= \{ | \} |
\\ | \# |
\$ | \% |
\& | \~ |
\_ | \^

Text ::= Char |
Char Text

Char ::= Greek | SpecialPunct | any normal character

Exp ::= Term RestExp

RestExp ::= Op Exp | <nothing>

Term ::= Foo RestTerm

RestTerm ::= ^{Exp} RestTerm |
_{Exp} RestTerm |

Foo ::= Fraction |
{ Exp } |

Fraction ::= \frac{Exp}{Exp}

Op ::= + | - | | / | <nothing>



Are you sure that the grammar should have Op = "nothing"??? WIth this option, you can create two separate equations right next to each other. This option isn't a happy one for TGen. Without the "nothing" in Op, we've been able to parse all of your examples (aside from a minor problem with parenthesis).

Rich Glazerman

I am pretty sure that the "nothing" alternative doesn't change the LL(1) property of the grammar. I intended it to be just a convenient way to "paste" two expressions together (like "3\frac{1}{2}") without an operator. –Brian

if in milestone 1 you simply returned forms would the explore: really help? i mean all explore is doing when exploring the latex object is displaying info about the particular form.. and not about what mathobjects make it up.. i understand why explore would be useful if it could display the compenents, but as it is, i dont see why you would want to know about the particular form. if we implement explore to display this form info, would we still get credit for its implementation?

Jamin Hogan - jamin@cc

Okay, now that I know that Brian's parser can work, I've been implementing it step by step along with the methods next to it. Right now, I've just been trying to get it to work with simple strings, but I've run into a snag. Everytime I try to run it, it gives me an error saying "Error: Translation message selectors must have the same number of arguments as right hand side nonterminals". However, I've only got 3 productions and each of them have "translation message selectors" (which I'm guessing is the method calls in the braces) that are equal to the number of non-terminals. I've fooled around with it a bit and no luck. Anyone ever seen this problem and know what I could be doing wrong? I'm stuck here until I can get this resolved. Any help would be much appreciated.

Adam Blaiss

Okay, I figured it out. When TGen makes transformations for you, it doesn't necessarily carry the translation message selectors with it so you need to actually implement the translations that it makes in your own grammar. Therefore, any grammar with transformations is likely not to work since it won't have the correct method calls.

I tried to implement one of the examples in the TGen documentation (appendix). I get the error:
"MessageNotUnderstood: ignoreDelimeter".

This appears in upper left corner:

<id> : [a-z]+ ;
<number> : [0-9]+ ;
<space> : [\s\t\r]+ {ignoreDelimeter} ;

and yes, I did tab before the '{'

Anyone have any ideas? Please help-I am getting frustrated at my complete lack of progress i.e. I can't even run the example successfully, let alone get anything done on Milestone 3.

I just figured it out. it's ignoreDelimiter.

New problem: I've made some good headway and I'm now trying to parse strings. The problem is that each string is just a concatenation of characters (according to Brian's grammar) and I'm having problems with the nothing delimiter that will always occur. If I don't give it any method to call, it will blow up on me. If I give it a method that doesn't do anything (empty body), it will automatically return its type and if I parse a string 'hello', will display 'helloanEquationBuilder'. If I return an empty string, it will parse strings okay but cause problems with fractions and Greek Symbols as it changes the makeup of them. I would just like it not to do anything but I'm not sure this is an option. Is there any "magic" thing that I can return or is there another way to do the grammar without getting a "nothing". Thanks for any help.

Adam Blaiss

Here's a good solution...pass back some symbol that you can recognize. If you get that symbol in later place, just ignore the symbol and return something else depending on the situation. For instance, for a string to be concatenated, if you get the symbol as the current string, just return the character that would be concatenated. Else, concatenate the character to the string and return the whole thing. I haven't had any problems since, but of course, different situations will have to be handled in different ways. Adam Blaiss

I have a question. (couldn't ask it on the coweb because it was interpretting what I wrote as html)

The previous version of my grammar allows greek symbols to be embedded in strings. I talked to Mark today and he said that was unnecessary. As a result, you can use this grammar instead:

Greek ::= \alpha |
\beta |

SpecialPunct ::= \{ | \} |
\\ | \# |
\$ | \% |
\& | \~ |
\_ | \^

Text ::= Char |
Char Text

Char ::= SpecialPunct | any normal character

Exp ::= Term RestExp

RestExp ::= Op Exp | <nothing>

Term ::= Foo RestTerm

RestTerm ::= ^{Exp} RestTerm |
_{Exp} RestTerm |

Foo ::= Fraction |
{ Exp } |
Greek |

Fraction ::= \frac{Exp}{Exp}

Op ::= + | - | | / | <nothing>

Note that Greek has moved from a Char alternative to a Foo alternative.

Also, for you people struggling with TGen, realize that TGen will require all the literals in the grammar above to be quoted (e.g. '\alpha', '\{', '}', etc.). It will also require that the ::=s become :s, and that semicolons terminate all the rules. "any normal character" should probably be a character class defined in the upper-left window in TGen. –Brian

To answer Jamin's question (way up there): I certainly hope that you're REALLY parsing, not just converting each piece to a Form as soon as you see it! The latter would be AWFUL design! If you're parsing, then you're creating some kind of structure to represent the parse. Show that to us. That's all – nothing complicated. Mark Guzdial

Some folks are asking me for examples of Morphic projects. Take a look at the Cases! These are all projects that got a 90 or better. Find a screenshot that's doing what you want, then check out the design and the code! Reuse of anything in Cases is fair game. Mark Guzdial

Alright.. I'm having some problems with TGen. I thought I knew what was going on, so I inputed my grammer, tokens, and examples, but I got the message, "No parser has been generated."

So... I decided to test the example from the lecture slides to see if it worked. Nope... same message.. "No parser has been generated." Anyone know why I might be getting this error?

Chris Haire

Superscripts are created with ^{s}, as in x^{2} to define x-squared.
Subscripts are created with _{s}, as in x_{i} to define x-sub-i.
From the above specifications it seems that the script part would always have to be inside the curly's. Why are you now giving examples with scripts not in the curly's? It sucks having to keep rewriting the grammar. Could you post the definative rules please.

In Tgen, when I try to accetp my grammar, I get the error:

"Checking grammar... grammar is not reduced,
non-generable nonterminals: Set (Text SpecialPunct Op Foo RestTerm Exp Term Fraction RestExp Char )
non-terminable nonterminals: Set ()."

Has anyone else run into this? I would guess that this means I've got a syntax problem, but I cant find it. Jason Foster

I've been running into the same problem. No matter what I do, I can't seem to be able to get rid of the non-generable nonterminals message.
Daniel Phommathep

Well, I'm not exactly sure but did you slam Brian's entire grammar into TGen and just try to get it work? Of course, I'm sure you changed the stuff that would make it interface with TGen, but I had problems just taking the entire grammar and just converting it to work. I would try starting with basic terminal types and keep compiling and building a grammar step by step. This worked quite well for me. This may not be what you want to hear, but it's a viable alternative if you're still having problems approaching the deadline. Adam Blaiss

does our parser have tp be LL1. Mine is SR1. The only difference is that it will parse from right to left, so that \beta ^ 2 + 4 returns beta^(2+4) as opposed to (beta^2)+ 4.
Please answer.

This isn't official, but I'm guessing that if the parser works, it shouldn't make a difference since the classes generated won't really tell what kind of parser they are. Also, all of the methods are called from "right to left" (really bottom to top) no matter what so even my LL1 parser currently has the same problem as yours. Adam Blaiss

Mark, which is correct?

In the milestone specifications, explore is supposed to return a MathEquation object to be explored. However, in one of your posts above, you stated you should display the parse tree that is created to eventually use methods to make the MathEquation object (like a DerivationTree of the LaTeX if you're using TGen). Which one should we explore or can it be either one?

Adam Blaiss

According to the user manual for TGen it is possible to go directly from the input to the target object - In order to do this we are required to define our own PTB directives (message selectors) and must implement these methods in our own subclass of AbstractSyntaxTreeBuilder. We then direct TGen to use the created PTB by selecting the builder item from the button menu of the transcript pane......
This is what I understood from the user manual, however each time I choose the builder option I get an error.... so obviously I'm doing something wrong. Could someone please correct me.
When you install the parser and scanner, go to the instance methods in the parser and change the value of treeBuilderClass from ^AbstractSyntaxTreeBuilder to whatever class you want the methods to be called from. This is how I did it and it worked fine. Also, I was never able to actually find this "builder" option. :-) Adam Blaiss

I have a question about the grammar.
Text := Char | Char Text
Char := Greek | .. | NormalCharacter

Text could be recursive; Char could be both Greek letter (orignally Ypatia) and String (different TextStyle). This means that we could have a mixed string of two different TextStyles. Do we need to handle this situation? Or could we modify the grammar? Thanks.
Toan Vu.

If you look up a little, Brian said he talked to Mark and found out that this was not necessary and gave a grammar for it. However, it still works if you want to leave it like that, it just does that unnecesary bit. Adam Blaiss

Ok, I'm trying to install my scanner and parser (straight from this webpage), and I get the following error:

Checking grammar... done.
Building scanner... starting at: 12:20:17 am
Scanner new or has changed - build required.

Scott Aday

Well, I'm not sure, but did you accept both the terminals and nonterminals in the upper and lower left corners before trying to install the parser? Red button (I think) click in the boxes and choose accept. After doing them both, it should tell you that the grammar has been produced and what type it is (LL(1),SLR(1), etc.) Then you can actually install it. Hope this helps. Adam Blaiss

Question about explore

I am trying to explore (using Squeak's explore method) the following:
(MathEquation from: (MathFraction from: 'x' over: 'y')) explore
The output is a derivation tree of a Form when what I really want is
a derivation tree of MathEquation with MathFraction. How do I tell Squeak not to evaluate what is in parens and just return the derivation?

Sara Harvey

Well, what you really need to do is make way to return the actual MathEquation objects and that is what you would want to explore. This needs to be dealt with in the MathEquation classes so you may need to go back and edit your code from Milestone #1. Make a special method explore: where they actually just return the objects and not forms to display. However, I'm still a little confused on exactly what to explore since Mark stated that exploring could be used to determine if you parsed correctly but didn't display correctly, but if you are able to build the MathEquation string to display, then evidently it'll display correctly. Therefore, exploring and displaying would essentially show the same thing, whether you did it all correct or wrong, which I don't believe was his intention. Adam Blaiss

Gee, we should hire Adam :-). To answer your question above, Adam: I want explore to let us see that you did the parse correctly. It doesn't have to show us the parse tree – it can show us the math objects already assembled. Just let us peek under the hood with explore. Mark Guzdial

Do we need to include all the classes from TGen in our submission, or will the TAs already have TGen installed?
Is there a way to send multiple objects to (Squeak's) explore. I was under the impression that we were supposed to use SQUEAK'S explore or openExplorerFor: in OUR explore: method.

Sara Harvey
In other words, would it be sufficient to explore an ordered collection containing the math objects already assembled?

Sara (again)
No, you cannot assume that TA's have TGen loaded. If you need to explore multiple objects, put 'em in an OrderedCollection and send it explore. Mark Guzdial

A question about turnin.... it says that we are supposed to turn in the design from 2.5, PLUS the UML/CRC if they have been changed. My question is, how are these things different? I thought the 2.5 design WAS the UML/CRC? Clarification would be appreciated...

Shaun Dishman

If you've changed your design from Milestone #2.5, include your old design, which is just Milestone #2.5, and the new design, which would be the CRC and UML analysis of the program you wrote. If the design hasn't changed at all since Milestone #2.5, then just include the old design, which is just Milestone #2.5. They just want to see how your design has changed as you began to actually program and work through the parsing. Adam Blaiss

I keep getting an error with the grammar in question:
'Parser generation failed; nondeterministic parser is available for inspection'

It's claiming the the grammar is not LL. Suggestions for what I'm doing wrong?

New question... what's this junk it keeps spitting about
'Block compiles more than 1K bytes of Code'

I do hope this message doesn't mean that I can't put more than this amount of code in a block...

Link to this Page