CSCI 5220
Spring 2003
Practice questions for exam 1

  1. Give a regular expression using flex notation that descibes the set of strings that start with a, end with c and have zero or more digits between them.

  2. Write a program using flex that copies the standard input to the standard output, except that it replaces each sequence of consecutive blanks and tabs by a single blank.

  3. Show that the following grammar is ambiguous.
    S -> S c S
    S -> d

  4. Show a parse tree for string cccdd with respect to grammar
    S -> c S d
    S -> c

  5. What are the FIRST and FOLLOW sets for the following grammar? The start nonterminal is E.
    E -> A
    E -> L
    A -> n
    A -> i
    L -> ( S )
    S -> E , S
    S -> E

  6. Build the finite state machine of LR(0) items for the grammar of the preceding problem, and show the SLR(1) parsing table for that grammar.