Assignment 2

  1. This question refers to the definition of integer literals in Java. What are valid integer literals?
  2. Write a regular expression for each of the following languages over {a,b}:

  3. Strings in C are delimited by double quotes ("), and may not contain newline characters. They may contain double quote or backslash characters if and only if those characters are "escaped" by a preceding backslash. Write a regular definition for strings in C.

  4. Financial quantities in American notation have a leading dollar sign ($), an optional string of asterisks (*), a string of decimal digits, and an optional fractional part consisting of a decimal point (.) and two decimal digits. The string of digits to the left of the decimal point may consist of a single zero (0). Otherwise it must not start with a zero. If there are more than three digits to the left of the decimal point, groups of three (counting from the right) must be separated by commas (,). Example: $**1,234,567.89.

  5. Convert the regular expressions of Questions 3 and 4 to DFAs.

  6. Write a tokenizer for the toy language.