I am studying the Dragon Book about compilers and it has exercises which I try to solve. Unfortunately, there is no-one nearby who could check my solutions. Is it appropriate to post my solutions here asking someone experienced to check them?
Some of the exercises do not require writing code (like this):
Exercise 2.2.1:
Consider the context-free grammarS -> S S + | S S * | a
a) Show how the string aa+a* can be generated by this grammar.
b) Construct a parse tree for this string.
c) What language does this grammar generate? Justify your answer.
Example of the answer
a) Show how the string aa+a* can be generated by this grammar.
- Let
S1 = a
according to the 3-rd production. - From the 1-st production we get:
S2 -> S1 S1 + => S2 = aa+
- From the 2-nd production:
S3 -> S2 S1 * => S3 = aa+a*
We got the required string S3
using the rules of the grammar.
I asked the same question at https://softwareengineering.meta.stackexchange.com/questions/9573/is-it-appropriate-to-ask-to-check-exercises-from-dragon-book-here and was sent here.