This is an old revision of the document!


10. Context-Free Languages & Lexers

For each context-free grammar G:

  1. describe L(G)
  2. algoritmically construct a PDA that accepts the same language
  3. run the PDA on the given inputs
  4. is the grammar ambiguous? If yes, write a non ambiguous grammar that generates the same language

10.1.1 input: aaaabb
$ S \leftarrow aS | aSb | \epsilon $

10.1.2 input: xayxcayatabcazz

$ S \leftarrow a | xAz | SbS | cS \\ A \leftarrow SyS | SyStS $

10.1.3 input: aaabbbbbccc

$ S \leftarrow ABC \\ A \leftarrow aA | \epsilon \\ B \leftarrow bbB | b \\ C \leftarrow cC | c $

Given the following specs, construct the lexer DFA as presented in Lecture 14:

  • PAIRS: $ (10 | 01)* $
  • ONES: $ 1+ $
  • NO_CONSEC_ONE: $ (1 | \epsilon)(01 | 0)* $

Separate the following input strings into lexemes:

  • 010101
  • 1010101011
  • 01110101001
  • 01010111111001010
  • 1101101001111100001010011001