|
|
CS 3723
Programming Languages
Fall 2014 |
Homework 1. Using a DFA
to Recognize Doubles
|
Week 1: Aug 27 - 29
|
Submit following directions at:
submissions
and rules at:
rules.
Deadlines are:
- 2014-09-08 23:59:59 (that's Mon, 08 Sep 2014, 11:59:59 pm)
for full credit.
- 2014-09-12 23:59:59 (that's Fri, 12 Sep 2014, 11:59:59 pm)
for 75% credit.
|
[Refer to the Calendar page under "Week 1"
for links related to Python and to finite automata.]
Using a DFA
to Recognize a Double:
Below is a DFA presented as a diagram. This DFA describes or
recognizes a double as it is usually defined in major
programming languages:
For this homework, you are to simulate the DFA above,
as illustrated in the program to simulate the DFA
that represents the RE (a|b)*abb:
abb.
That DFA is quite a bit simpler than the DFA above for
a double, but the idea is the same.
In case the diagram above looks too complicated, as another
strategy for writing this program, you could first work with
the simpler DFA below (which doesn't include the "exponent"
part of a double).
What to Submit:
The input date is given below, and is in the
file double.data.
Input Data |
11
7
2143
62.47
0.0000376
.1423
876.
12.75E2
12.75E+4
12.75E-4
.75E2
.75E+4
.75E-3
|
113.E2
113.E-3
113.E+4
117E2
117E-3
117E+4
345.5782E25
1234.5678e-17
6E
1.3E
4.2E+
.88E-
|
While you are debugging your program, you might want to
produce quite a bit of output, as shown with the "abb"
example above. For the final program, you can have one
of three outputs:
- Accept an int,
- Accept a double, or
- Reject.
Of course, the first 3 inputs should be accepted as an int
and the final 4 rejected. The remaining ones should be
accepted as a double.
You should turn in:
- Your source Python program that recognizes doubles.
- The results of a run with the given input data.
(It would be acceptable to have a separate run for each
input, but better would be to do them all at once.)
For credit, your recognizing program must be based on
the DFA for a double.
Any DFA is equivalent to a RE, and it would be possible
to write a program that uses regular expressions to
recognize a double, but you are not to do this.
( Revision date: 2014-09-01.
Please use ISO
8601, the International Standard.)
|