This assignment should be straightforward. First, you have a simple task to do. Second, large parts of the assignment are covered verbatim in the text book. Third, you are writing a compiler using a specification for a compiler compiler, and so many details are totally hidden. Fourth, you are leveraging off of a foundation that I've already written.
You should not have to spend more than 2 hours on the assignment.
You must do this assignment on the instructional alphas or the instructional mips machines. It is unlikely that you'll get the right answers for the special floating point numbers on other boxes, such as on wintel boxes.
One special floating point number lexically appears as "NaN" or "NaNS", in any case. This means "Not a Number". You can call the function "double makenan()" to return a floating point number encoding a NaN. do NOT call atof to scan and convert this string.
One special floating point number lexically appears as "Inf", in any case. This means (positive) infinity. You can call the function "double makeinf()" to return a floating point number encoding an infinity. Do NOT call |atof| to scan and convert this string.
Aside from scanning these numbers and calling the special functions to make instances of these special numbers, you do not have to do ANYTHING else special to parse or attribute NaNs or Infs. Everything else should be done for you by the runtime system or by the underlying hardware.
This lex/yacc assignment was intended to "kill 2 birds with one stone": do a simple lex+yacc assignment (which entails copying pretty much directly from the text book, with some extensions), and to also "learn by experimentation" about some special floating point numbers.
Unfortunately, the second "bird" is wearing a bullet proof vest and will not work as intended.
I made the (terrible) assumption that the instructional machines (sanjuan, orcas) running on alphas under DEC's version of unix would handle floating point operations per the IEEE standard for floating point arithmetic and so they would handle 0.0/0.0 correctly and yield Infinity. These systems do NOT do this correctly by default (even though they are supposed to be IEEE compliant), and as some of you have pointed out, will take a floating point exception and then "dump core".
I am unable to figure out the proper minimal fixup to make these systems do the right thing, since it involves interactions with the operating system and interactions with the compiler: one has to force the compiler to generate the correction instructions in anticipation of possible divisions by 0!
My terrible assumption was that the DEC alphas would implement IEEE correctly, since, after all, the sparc on my desk at work does, and the Tera machine does. Wrong!
So: you do not have to check that your little lex/yacc assignment
implements IEEE boundary cases correctly (0/0, Inf+0, 0