1.3-3,14solution

1.3-3,14solution - <integer> ร<digit> |<digit><integer><digit> ร 0 | 1 | 2 | | 9<optional exponent> ร<exponent>

This preview shows page 1. Sign up to view the full content.

CS314 homework 3 solutions, January 31, 2008 Here are some suggested solutions to 1.3(3, 14). 3. Here’s a possible grammar, G = <N,T,<double>, P>. Of course, N and T are implied by the set of productions without your having to state them explicitly. I borrowed some notation from Alex Diehl’s good answer. Thanks! There are several ways of interpreting the problem. If by “Java double” you mean Java constants, then the following is a solution. If instead you mean Java literals, then omit the productions labeled (*). N = {<double>, <sign>, <number>,<integer>, <digit>, <optional exponent>, <exponent>, <D>, <E>, } T = {Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NaN, 0, 1, . .., 9, +, –, . , e, E, d, D} P = { <double> ÷ <sign><number><optonal_exponent> | <sign><integer><D> | <sign><integer><exponent> | (*) Double.POSITIVE_INFINITY | Double.NEGATIVE_INFINITY | Double.NaN <sign> ÷ + | – | 8 <number> ÷ <integer> . <integer> | . <integer>
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: <integer> รท <digit> | <digit> <integer> <digit> รท 0 | 1 | 2 | . .. | 9 <optional exponent> รท <exponent> | 8 <exponent> รท <E> <sign> <integer> <D> รท d | D | . <E> รท e | E Matt jokingly offered the following as well, which is the underlying bit pattern guaranteed by the Java documentation. <IEEEdouble> รท <bit><bit><bit><bit> . .. <bit> [there are 64 <bit>s here] <bit> รท 0|1 If I were writing the grammar of an IEEE double, Matt, I would instead tell you what that bit pattern represented in order from left to right, by using meaningful names as follows. <IEEE double> รท <sign> <exponent> <mantissa> <sign> รท <bit> <exponent> รท <bit> <bit> . .. <bit> [there are 11 <bit>s here] <mantissa> รท <bit> <bit> <bit> . .. <bit> [there are 52 <bit>s here] <bit> รท 0 | 1 14. The following Mealy machine by Doyle or by Das solves problem #14. Notice the convention of labeling the states meaningfully....
View Full Document

This homework help was uploaded on 04/19/2008 for the course COMP 314 taught by Professor Chase during the Spring '08 term at Dickinson.

Ask a homework question - tutors are online