Programming Project 1

Programming Project 1
Flex and Bison for use in
Leet to English conversion

Due: Thursday December 19, by 11:59pm.

NOTE: The description file has been updated on 12/13/02. If you downloaded it before this date, please re-download it. Take a look at the submission info - it's all there now.

Scenario (to be read if you like reasons for doing these assignments :)

An English teacher comes to you with complaints about her high school students writing in some strange language called leet speak. It's not like the old pig latin and she can kind of read it, but she's not happy with it. For one thing, there are multiple ways to say the same words. As an example, if a student wanted to say the words "leet speak", the student could write: "133+ $p34k" or if they're really leet they could write: "||:|:-|- _\-|*|:/\|<".

The teacher would like to play a trick on students who turn their next homework assignment in using leet speak - she would like to automatically translate it, correct a certain subset of misspelled words, highlight those words, and then give the assignment back to the students.

Your first thought upon hearing this is to ask whether or not students submit assignments in ms-word as you don't really want to have to deal with those kind of formatting issues... luckily the documents will be given to you in ascii text [editors note: this is a bit contrived, but works for this particular assignment]. The teacher doesn't even mind if you convert them to HTML - after all, the format is easy to read and easy to generate. And so you decide that they should be in HTML.


In this programming project, you will do the following:

  1. Use flex to translate the leet into English. This involves the following steps:
  2. Create a grammar for turning the text into an html document. As an example, you may want your grammar to handle sentences, words, and letters differently.
  3. Use bison to:

Assorted files you will need

  1. I have collected a variety of letter translations, words, and their corresponding colors that you need to deal with in a text file.

  2. The starting leetScanner.h and leetScanner.lex files for use with flex. I've defined A in this file to help you out. This scanner will tokenize a file containing only an a. You can compile the file in the following 2 steps:

  3. The starting leetParser.h and leetParser.y files for use with bison. I've defined letters in this file to help you out. This parser will parse a file containing only an a (but it won't turn it into html).You can compile the file in the following 2 steps (assuming that the file lex.yy.c already exists!):

  4. An example text file along with output from the scanner and the parser.


As usual, use lots of comments and make your files as readable as possible (for example, by making use of the definition and code sections, using descriptive names, and using good indentation (spaces, NOT tabs)). Start each file with comments containing your name(s) and account(s). Make sure that your lines are at most 80 characters long.


You may work on and submit this project with another student as stated in the syllabus, If you choose to work with another student, both of you should contribute significantly to the whole programming project. You should submit only one copy of the project with both your names on it.
You should only submit work that is completely your own and you should be able to explain your work to me.


You will be using try to submit your projects this quarter. For this particular project there are 2-3 submissions:

  1. (10 points) You must all register for the course separately as the course registration gives me info. on where to send your email. The registration command is:

    try jdb-grd register /dev/null

  2. (90 points) Submitting the project code. Of these points, 50 will be for the scanner and 40 will be for the parser. The code submission command is:

    try jdb-grd project1-1 leetParser.h leetParser.y leetScanner.h leetScanner.lex

  3. (helps with the above credit) An optional writeup file in which you can describe any problems that you might have had with the project, any difficult-to-understand code that you might have created, or any particular cases (for instance the damn problem where damn will be scanned as dmm) that you have handled specially. You are more likely to get partial credit if you are aware of your problems and describe them to me. The writeup file command is:

    try jdb-grd project1-2 writeup.txt

You can resubmit as often as you like before the deadline. Late submissions will not be accepted for any reason, but the lowest of the four programming project grades will be dropped if you do all of the projects. However, a zero for cheating will not be dropped.
If you work as a pair, you should submit all work from one account and both partner's names should appear on all submitted files.

Flex and Bison Sites and Information

The Unix man pages for flex and bison are fairly complete. With that said, you can also find information at:
The on-line Bison manual