CSE 3001/5040: Homework #1, Syntax

Due: Thursday, 28 January 1998, in class
  1. The program /software/gnu/bin/grep (man -M /software/gnu/man grep) uses regular expressions to match lines in the input. Use grep and the list of words /usr/dict/words to solve the following word problems. For example, to find words that begin and end with a vowel, use:
          grep -i -x -E '([aeiou].*[aeiou]|[aeiou])' /usr/dict/words
          
    Or, using grep twice
          grep -i -E '^[aeiou]' /usr/dict/words | grep -i -E '[aeiou]$'
          
    Explain how you used grep to come up with the solution.
    1. List all the words with four or more consecutive vowels
    2. List all the words in which the letter "q" is not followed by the letter "u".
    3. Find the longest words with letters in alphabetical order (no repeated letters), for example, "adept", "below", "dirty", and "empty".
    4. Find a nine-letter word whose third letter is 'r', remove the 'r', divide the remaining eight letters in half, reverse the order of the letters in each half, and get two four-letter antonyms. Hint: you may wish to use /usr/bin/sed to reverse the letters.

  2. Some formal languages cannot be described using regular expressions, for example, anbn cannot. Suppose we restrict n < 1000. Can this language be described using a regular expression? Explain why, or why not.
  3. #5, Chapter 3, Problem set, page 152. Ambiguity in CFG.
  4. #6, Chapter 3, Problem set, page 152. Write CFG for expressions with precedence.
  5. #7, Chapter 3, Problem set, page 152. Describe language for a CFG.

Ryan Stansifer <ryan@cs.fit.edu>
Last modified: Fri Jan 8 09:22:42 EST 1999