Unformatted text preview:

HW 1: Lexical AnalysisCSC 4351, Spring 2018Due: 7 February 20181. Consider the following format for floating point literals. Assume a fraction part consisting of a stringof one or more decimal digits with an optional decimal point (period) that can be added immediatelybefore or after any of the digits. In addition, an optional exponent can be appended to the fractionpart, consisting of an e or E, followed by an optional sign, followed by one or more decimal digits. Afloating point literal must contain either a decimal point, or an exponent, or both.Examples: .0, 0., 0.1, .01e-01, 01E00(a) Give a regular expression for this construct. You may use .(b) Use Thompson’s construction to translate the regular expression into an NFA.Make sure that you don’t accept integers!2. Consider scanning literals for representing carbohydrates in chemistry. Such literals consist of oneor more parts, each consisting of C, H, or O, optionally followed by a decimal integer greater than1 (it can greater than 9). You may use D0to mean decimal digits 0–9, D1to mean 1–9, and D2tomean 2–9.1(a) Give a regular expression for these carbohydrate literals. You may use the iteration operators *and + and ?.(b) Give a DFA that recognizes exactly these literals (no  edges). Don’t forget to mark the startstate and all accepting states.Make sure that you don’t accept the empty string!1This is a computer science question, not a chemistry question. In particular, this specification allows bogus chemical formulassuch as


View Full Document

LSU CSC 4351 - HW 1: Lexical Analysis

Download HW 1: Lexical Analysis
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view HW 1: Lexical Analysis and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view HW 1: Lexical Analysis 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?