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 grammar S -> 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.

  1. Let S1 = a according to the 3-rd production.
  2. From the 1-st production we get: S2 -> S1 S1 + => S2 = aa+
  3. 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.


1 Answer 1


Your example question looks more like computer science than language design or implementation, and at least I don't think you'd get the answers you're looking for here for questions of that sort. It's likely there are other exercises out of the book that are a closer match here, although "check my solution" is not really much of a fit for Stack Exchange questions in most cases.

I don't know how welcoming Computer Science SE is to the sort of question you're interested in, but I suspect that questions that are purely about checking a proposed exercise solution with no actual topical question involved are probably not overly well received.

If you aren't able to come up with a solution to some exercise as expected then you have an actual question about how to move forward, and then you can pick an appropriate site to ask about that underlying issue.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .