2. Given the following grammar: S -> aB | b | cC B -> aB | bS C -> aaS | b | caB
ID: 3549287 • Letter: 2
Question
2. Given the following grammar:
S -> aB | b | cC
B -> aB | bS
C -> aaS | b | caB
1) Perform the pairwise disjointness test for each rule to show that this grammar allows top-down parsing.
2) Write a recursive descent parser for this grammar in Java. Submit the source code of your parser (including the very simple lexer for this grammar). The main method will ask the user for a string and will attempt to parse it, displaying the result of this attempt and all the steps followed. Report all syntax errors.
3) Verify that the following string is recognized: caaabccabb.
Explanation / Answer
1)
FIRST(aB)=a
FIRST(b)=b
FIRST(cC)=c
They don
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.