10. Context-Free Languages & Lexers
10.1. Context-Free Grammar to PDA conversion
For each context-free grammar G:
- describe L(G)
- algoritmically construct a PDA that accepts the same language
- run the PDA on the given inputs
- 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 $
10.2. Lexer Spec
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