CSE 222 Lab #1


Objectives

The Problem

Web browsers interpret an easy-to-learn markup language (HTML).  So one approach to translating routine documents into nicely-formatted ones is to translate them into HTML, inserting markup "tags" as appropriate.  For example, if emacs didn't already know how to pretty-print Resolve/C++ files, you might choose to do it yourself by translating Resolve/C++ source files into HTML files containing tags to demarcate keywords, etc.  Then to pretty-print the document you could just view the HTML translation in a web browser and print it from there.

This was the task your employer gave to a former employee, Candace B. Rittenoff, who took some bad advice from her tax advisor, Lew Pole, and is now "working" for the IRS.  As the new intern hired by the boss, Dave Reckoning, you have inherited Candace's initial design and are to complete the assignment.  The program is supposed to read a Resolve/C++ source file from stdin and write to stdout an HTML file which, if viewed using a browser, is ready to be pretty-printed in the sense that:

An executable version of an acceptable -- yet not necessarily perfect -- solution to the assignment is available in:

You can see what this solution produces for the source file Hello_World.cpp either by viewing the HTML page source of this file in your browser:

or by opening it in emacs.  This will allow you to see what HTML tags are required to get italics, boldface, and colors.  Look closely!  Observe what happens when the embedded HTML tags are interpreted by a browser, and be careful to notice and understand subtle things that have nothing to do with italics, colors, or boldface text.

Your solution to Lab #1 is designed to be what is called a filter in Unix: it takes input from stdin and writes output to stdout.  To use your program, you will want to redirect input from a Resolve/C++ source file and redirect output to an HTML file.  For example, to markup the source file Something.cpp, creating the HTML document Something.html, the appropriate Unix command is:

Notice that the "<" and ">" in this command are not brackets around "Something.cpp". The "<" is followed by the name of a file from which stdin is to be redirected; the ">" is followed by the name of a file to which stdout is to be redirected. You may redirect either input or output or both, independently, and it doesn't matter in which order you do this.  So the following command is equivalent to the above:

Notice also that if you redirect output to a file then the file should not already exist, or you get an error message.  You can overcome this either by explicitly removing that file before executing the above command, or by using ">!" in place of ">" for output redirection.  The following command, then, effectively removes the file Something.html if it exists, and then redirects output to it:

Method

Here's what to do:

Possible Maintenance Activities

Here are some questions about possible maintenance activities involving this program:

Any extra work is strictly optional, for your own benefit, and will not directly affect your grade.