CSCI 5220
Spring 2016
Practice Questions for Exam 1

  1. Write 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.

    Answer

  2. Write a regular expression in Flex notation that describes the set of all strings of lower-case letters that contain exactly one a, exactly one b and exactly one c, in that order.

    Answer

  3. Write a regular expression in Flex notation that describes the set of all strings of lower-case letters that do not contain the letter x at any point after the letter y. That is, the string cannot match regular expression [a-z]*x[a-z]*y[a-z]*.

    For example, axe, xyzy and abc are acceptable, but eyex and xyzabcxyz are not.

    Answer

  4. Write a program using Flex that copies the standard input to the standard output, except that it replaces every occurrence of frog by toad. The occurrence of frog could be part of a word. It does not need to be a full word.

    This program is not a typical lexical analyzer, but a full program.

    Answer

  5. Does a lexical analyzer normally return a token for a comment? Why or why not?

    Answer

  6. Write a Flex regular expression that describes the set containing only two strings, happy and joyful.

    Answer