Sale!

EECS 337 Assignment #2 solution

$24.99 $17.49

Original Work ?

Download Details:

  • Name: hw02.zip
  • Type: zip
  • Size: 1.08 MB

Category: You will Instantly receive a download link upon Payment||Click Original Work Button for Custom work

Description

5/5 - (1 vote)

Part 1: Reading and Exercises Compilers – Principles, Techniques, & Tools, 2nd Edition, Sections 2.1, 2.2, 2.3, 2.6 Homework Exercises – problems 2.2.1, 2.2.2 (a,b,c), 2.2.3 (only for a,b,c), draw a state transition diagram for all the states implemented in this laboratory assignment.
Introduction In this assignment, you will look at the C pre-compiler operations (cpp) and you will expand the state machine to remove the macro statements (# to EOL). This is the same operation as the slash-slash type comments to EOL. Then you will then expand the state machine to handle a number of special characters ()*+,;=[]{}, single digit integer constants (CONSTANT), identifiers (IDENTIFIER), the C types void, char, int (VOID, CHAR, INT) and the keyword return (RETURN). From these states you will call a token_print function with a token and character buffer of the current input text. You need to terminate the text string with a null (0). You run a test script and submit the output file as the laboratory part of the assignment. Also add to the state machine the ability to handle a string literal “w:%d,\tx:%d,\ty:%d,\tz:%d\n”. Part 2: Laboratory Assignment From a console window, make a directory on your computer in your EECS337 directory under your Case ID and call it hw02. Change into that directory and copy the previous Echo2 and Code example programs from assignment 1 into the current working directory. (Note: if you did not develop a working version of Echo2 or the Code programs then consider re-using the solutions code posted to blackboard under the assignment 01 area.)
mkdir EECS337/caseid/hw02/ ; where caseid is YOUR Case ID, enter all in lower case cd EECS337/caseid/hw02/ cp ../hw01/Echo2.c . cp ../hw01/Code_1_6_1.c . cp ../hw01/Code_1_6_2.c . cp ../hw01/Code_1_6_4.c .
Download a copy of the hw02_caseid.tar file to the hw02 directory from https://blackboard.case.edu/ in the EECS337 homework assignment area. You are now ready to solve the laboratory assignment. To untar the tar file type the command. tar xvf hw02_caseid.tar
Your directory structure should now contain the extra files shown below: hw02_test.sh tokens.c Makefile
Part 3: Test and Update Echo2.c Include Build the Echo2 program and test the execution using the commands below. The output should show the C program source code with the C comments removed from the output. make clean make ./Echo2 < ../hw01/Code_1_6_1.c Edit the Echo2.c file and just below the #include