Computer Science 433
Programming Languages
Fall 2014, The College of Saint Rose
Lecture 5: Lexical Analysis
Date: Wednesday, September 10, 2014
Agenda
- Announcements
- Program/Problem Set 2: Syntax [HTML] [PDF] continues, due Monday night
- Lecture 4 assignment recap
- Lexical analysis
- The "front" lexical analysis for simple arithmetic expressions
Lecture 5 Assignment
Due at the start of class, Monday, September 15.
Please submit answers to these questions
in Submission
Box under "LA5" or in hard copy by the
start of our next class. We will discuss these questions at the
start of class, so no late submissions are accepted. Please be sure
that your name is clearly indicated in all submissions.
- Extend the state diagram from the notes that recognizes base 10
signed integers to recognize these other kinds of integer literals:
- octal constants, which begin with a 0
- hexadecimal constants, which begin with 0x
- e-notation constants, which consist of a number followed by e, followed by a number
Your diagram should have final states labeled as the different kinds of integer literals, e.g., octal-int, hex-int, e-int. (6 points)
- (10 points) Extend the front lexical analysis code from the
examples area as follows:
- recognize floating point constants (you may assume this consists of a series
of 1 or more digits, followed by a decimal point, followed by 0 or
more digits),
- recognize a semicolon token,
- allow underscore characters as part of identifiers.
Examples