CSE 321 Lab 5


Lab 5 Table of Contents


Objective

The objective for this assignment is to implement the BL_Tokenizing_Machine component.


Overview

You will be implementing the BL_Tokenizing_Machine_Kernel component using the representation and the algorithm described in class.


Materials Provided

The set up instructions will provide you with a user catalog containing the following components and auxiliary items:

You will need to fill in the operation bodies as indicated in BL_Tokenizing_Machine_Kernel_1. (Specifications and implementations for several useful private operations are already provided.)

To use a demonstration version of the test driver, just execute the command 321_Tokenizing_Machine_Demo < BL_Source_Program, where BL_Source_Program is any (possibly incorrect) BL source program.

Once you are done with your implementation of the BL_Tokenizing_Machine, you will have built all of the pieces used by the BL translator. After submitting your solution to the lab, if you would like to assemble your own version of the translator using all your implementations, simply copy the following components to your lab5 catalog and build the project.

From the lab2-part2 user catalog copy your implementation of Statement_Kernel:

From the lab3-part1 user catalog copy your implementation of Program_Parse: From the lab3-part2 user catalog copy your implementation of Statement_Parse: From the lab4 user catalog copy your implementation of Program_Generate_Code and the main program Translator.cpp: Finally, from the closed-lab4 user catalog copy your implementation of Program_Kernel:

Set Up

  1. Copy the lab5 course catalog to your group project directory (/project/c321axnn, where "x" is your section letter and "nn" is your team number):
    cp -r /class/sce/now/321/labs/catalogs/lab5 /project/c321axnn
    
  2. Make sure that the new catalog will be accessible to your partner. Perform this action now and as your last act whenever you finish a working session. Note that 'l' in the chmod command is the letter 'l' ("el"), as in "lock":
    cd /project/c321axnn/lab5
    
    chmod -R g-l,g+rwX .
    
    set-group-ID .
    
  3. Look around the new user catalog to familiarize yourself with its contents.

Using the Test Driver

The test driver for this lab reads a BL program from standard input, tokenizes it, and outputs a list of the tokens and their token types. It should be invoked with the command: Tokenizing_Machine_Test < BL_Source_Program. For example, if BL_Source_Program contains the following BL program:
    PROGRAM Test IS
    BEGIN # this is a test
        WHILE true DO
            infect
        END WHILE
    END Test
the test driver's output should be:
Running the test case . . .

TOKEN KIND      TOKEN TEXT
----------      ----------
KEYWORD         <PROGRAM>
WHITE_SPACE     < >
IDENTIFIER      <Test>
WHITE_SPACE     < >
KEYWORD         <IS>
WHITE_SPACE     <
>
KEYWORD         <BEGIN>
WHITE_SPACE     < >
COMMENT         <# this is a test>
WHITE_SPACE     <
    >
KEYWORD         <WHILE>
WHITE_SPACE     < >
CONDITION       <true>
WHITE_SPACE     < >
KEYWORD         <DO>
WHITE_SPACE     <
        >
IDENTIFIER      <infect>
WHITE_SPACE     <
    >
KEYWORD         <END>
WHITE_SPACE     < >
KEYWORD         <WHILE>
WHITE_SPACE     <
>
KEYWORD         <END>
WHITE_SPACE     < >
IDENTIFIER      <Test>
WHITE_SPACE     <
>

Test case completed.

What To Submit

Once you and your partner are convinced that all implementations are working correctly, get into your group's lab5 directory /project/c321axnn/lab5 in an xterm window and use the rcpp-submit command to submit your solution as follows (noting that you will need to use the appropriate suffix in place of ?? in this command, as posted next to your instructor's name on the CSE 321 Home Page):
rcpp-submit c321?? lab5
If you get an error message rather than a confirmation of success, please read the message; it contains useful information! Do not just run the same command again. Save the e-mail you get as a receipt of submission, just in case.