CS286 -- Lab 1: Prerequisite Assessment



->Courses
->CS286
-->Homework
->Lab 1
-->Lab 2
-->Lab 3
-->Lab 4
->Electronic Submission
->MSVC++ Info
->STL Info
->MFC/GUI Info
->Tentative Schedule
->Course Policies

[Courses]
[Rich][Home][Rich]
[PHome]

Spring Quarter 2001

Purpose

The purpose of this lab assignment is to review concepts from previous courses. This is accomplished through designing and implementing a C++ program to convert C++ source code into an XML formatted document.

Assignment

You should write a C++ program that will convert one or more C++ source files into XML elements that, when added to a report submission, will format the C++ source code in the same manner as MSVC++'s editor does. Your program should accept one or more filenames from the command line prompt and send the results to standard console output.

In particular,

  • A section should be created to contain the source code.
  • Each source file should be in it's own subsection.
    The name of the subsection should be the same as the source file's name.
  • A cpp start and end tag should be placed immediately before and after each source file.
  • Each line of the original source file should be numbered (using the cppln command.
    The line numbers should be right justified (see example below).
  • A line break tag, <br/>, should be placed at the end of each line.
  • All C++ keywords and preprocessor directives (along with the # symbol in front of the preprocessor directive) should be placed within cppkey start and end tags.
  • All C++ comments should be placed within cppcmt start and end tags.
  • Whenever multiple spaces are found sequence, the odd numbered spaces should be replaced with: &#160;. Examples (where _ represents a space):
    • Two spaces: &#160;_
    • Three spaces: &#160;_&#160;
    • Four spaces: &#160;_&#160;_
  • Each tab should be replaced with: &#160; &#160;
  • Each less than symbol (<) should be replaced with: &lt;
  • Each greater than symbol (>) should be replaced with: &gt;
  • Each apostrophe (') should be replaced with: &apos;
  • Each quote (") should be replaced with: &quot;
  • Each ampersand (&) should be replaced with: &amp;

Here is a list of all the C++ keywords: __multiple_inheritance, __single_inheritance, __virtual_inheritance, asm, auto, bad_cast, bad_typeid, bool, break, case, catch, char, class, const, const_cast, continue, default, delete, do, double, dynamic_cast, else, enum, extern, false, float, for, friend, goto, if, inline, int, long, namespace, new, operator, private, protected, public, register, reinterpret_cast, return, short, signed, sizeof, static, static_cast, struct, switch, template, this, throw, true, try, type_info, typedef, typeid, union, unsigned, using, virtual, void, volatile, while, xalloc.

Here is a list of all the C++ preprocessor directives: define, elif, else, endif, error, if, ifdef, ifndef, line, include, pragma, undef, warning.

An example of the program usage is given below. Click on the source files to see what the input looks like and on the XML file to see what the output should look like.

C:\>programName enterInt.h main.cpp enterInt.cpp > lab1.xml

Programming consideration: Please note that this is not as simple as it make appear at first glance. Be sure to dedicate an adequate portion of time to understanding the requirements. It may be particularly helpful to study the example file carefully. Also, students in the past have forgotten that the + and - operators are not defined for the bidirectional itererator. You will need to use increment and decrement operators instead.

Your design must include at least one user defined abstract data type.

Program Extras

It should be clear that the rule that I have given for the conversion of tab characters is too simplistic. While not required, you may wish to improve your program so that it handles tabs correctly.

You may wish to allow the user to enter a project filename and have your program generate the code subsections for all of the source files in the project. If you choose to do this, you should not remove the ability to specify a list of source files. This could be done by adding a command line option. For example:

C:\>programName -project projectName > lab1.xml

The -project flag signifies to your program that a project file has been entered instead of a list of source files. Your program will then need to read the project file(s) to find the list of source files. Hint: take a look at the *.dsp file.

Lab report (due 11:00pm, the day prior to week 3 lab)

The lab report should be self-contained. That is, it should be possible for someone to understand what you did and why without seeing anything other than your report. Your report should include:

  • Educational Objective
  • Problem Statement
  • Procedure: what approach you used to solve the problem
  • Discussion: reasons for defining the classes as you did, reasons for selecting the data structures you used, any problems you encountered, etc...
  • PSP spreadsheet
  • Conclusions (what you learned, suggestions of how the lab could have been better, things you would have done differently, etc.)
  • Documented source code (using your program to format the code)

As with any report you submit, correct spelling and grammar are required. In addition, your report should be submitted electronically following the Electronic Submission Guidelines. (You may wish to consult the sample report before submitting your report.) Be sure to keep copies of all your files, in case something gets lost. It may be wise to keep a diskette backup as well.

If you have any questions, consult the instructor.

© 2001 Dr. Christopher C. Taylor Office: CC-27C Phone: 277-7339 Last Updated: March 28, 2001
I am responsible for all content posted on these pages; MSOE is welcome to share these opinions but may not want to.