Computer Science 433
Programming Languages
Fall 2012, The College of Saint Rose
Lecture 9: Lexical Analysis and Parsing
Date: Wednesday, September 26, 2012
Agenda
- Announcements
- Back to regular grammars briefly
- Lexical analysis
- The "front" lexical analysis for simple arithmetic expressions
- Parsing
- Recursive descent parsing
Lecture Assignment 9
Due at the start of class, Monday, October 1.
Please submit answers to these questions
either as a hard copy (typeset or handwritten are OK) or by email to
terescoj AT strose.edu by the start of class. Please use a clear subject line
when submitting by email (e.g., CSC 433 Lecture
Assignment 9, Joe Student). We will discuss these
questions at the start of class, so no late submissions are
accepted.
- 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 in identifiers.
Examples