CST 8152 Compilers - Assignment #1Due: 8:45am Monday, January 20, 1997
Purpose and Instructions:
This is a review of C coding style and an introduction to Lexical Analysis.
Design, write, and thoroughly test a C program that will recognize, count, and output simple double-quoted C language strings. It will scan a given input file (which may or may not be a complete C program), locate the start and end of each string, and correctly handle two embedded string escapes:
- escaped double quotes within the string (\"), which will be replaced by unescaped double quotes
- the escape sequence backslash-N (\n), which will be replaced by an ASCII newline character.
Other escape sequences in the strings need not be recognized or handled, such as escaped backslashes (\\). Strings appearing inside C comments (/* */) may also be output, though clearly a real scanner would not do this. If you have time, make your scanner skip C comments.
The output will be only the contents of the strings found in the input, each string preceded by its ordinal number as found in the input file. Note that the enclosing double quotes are not part of the string.
The structure of the program will involve a main() program that prompts the user for a file name to be processed, opens the file, then calls a function to locate and return a pointer to the first recognized string in the file (if any). The recognized string is output by the main program. The main program keeps calling the function and printing strings until no strings are left, at which point the function returns an indication that it is done to main, and the main program tidies up and exits. Output will appear either on the users terminal or in a second file opened by the main() program (your choice).
Your assignment is due in the Ian Allen assignment box before 8:45am Monday, January 20.
Please fasten all pages of your assignment firmly, or place all parts into a full-size brown envelope.
Identify your assignments:
Make obvious on your assignment these things (type or print clearly):
- your name,
- your student ID number,
- your weekly Lab section number, and
- the the course number: CST8152.
Deliverables for this assignment:
1. The fully documented source listing of your program (including your own .h files). Programming must follow the Algonquin standard guidelines.
2. A listing of your input test file(s) showing the test cases you selected.
3. Your generated output for each input test file.
Please review the C Programming Style comments. Assignments are marked for clarity and simplicity as well as correctness.Late assignments are handled according to the policy given in the course outline.Inside every big program is a little program struggling to get out.