Terminally Incoherent

Utterly random, incoherent and disjointed rants and ramblings...

Monday, March 06, 2006

Homeworks From Hell

I just spent an inordinate amount of time on Dr. Deremer's BNF homework. I'm still not sure if I got everything right but I just don't feel like looking at it again. I still haven't figured out a way to typeset BNF's in latex.

What I do is I use the inline math environment to treat the BNF as a math formula. This has an unfortunate side effect, as the default latex behavior is to break line on inequality symbols. Most BNF tokens are of the form <token> so, if the line is broken on < or > it looks absolutely ridiculous. I simply enforced manual line breaks, and forced alternate spacing using \quad and \qquad. This is far from optimal solution. I need to find a better way to do this for the future.

On the other hand, I found a great way to draw parse trees using the pstricks package which should be bundled by default with most modern latex installations. I drew all my trees by hand, and then just coded them up. The syntax is super easy:

\pstree{ \TR{root} }
{
\TR{child-1}

\pstree{ \TR{child-2} }
{
\TR{sub-child-of-2}
}
}


It was quite painless to modify and change these things. I really don't envy people who were doing these things in Word. I wouldn't even attempt to make tree's in word if someone paid me to do this. As far as I'm concerned, WYSIWYG office suites are retarded. The only proper way to write documents is to typeset in latex. But that's just me...

Btw, if you are wondering about problem 13 here is a hint: the parse tree for the grammar needs to grow symmetrically on both right and left. Focus on the middle node. Think "christmas tree". The grammar is a one liner actually - very simple and elegant in a way. It took me hours to figure this damn thing out. I think I was over thinking it way to much.

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home