0

As context-free grammar is

S --> aSbS|b|epsilon

How can I describe the language it accepted?

I can find the language in certain length, but I can't describe it.

albert
  • 8,027
  • 10
  • 48
  • 84
Jennifer Q
  • 257
  • 3
  • 12
  • I don't quite understand your question. The expression S --> aSbS|b|epsilon fully describes/defines your language since it is an extended BNF grammar (if I get the syntax correctly). I think it can't be defined via a regular expression. You can provide a list of samples of language sentences (b, ab, abb, aabbb, ...) but it is just that, not a description. – MaxP Apr 05 '16 at 06:49
  • Yep, I think so. But our homework asks us to describe it in nature language (e.g S --> aS|epsilon describes as "0 or more a"). I thought this grammar for an hour, but still can't transfer it to nature description. So confusing... – Jennifer Q Apr 05 '16 at 06:57
  • Now it is clearer. I think you have to apply some transformation to the definition to move the language in somewhat more manageable from the natural language PoV. E.g. `S --> TS` , `T --> aSb`, `S --> b`, `S --> epsilon` The `T --> aSb` suggests a parenthetical structure, while `S --> TS` states that the language is composed by a sequence of zero or more. – MaxP Apr 05 '16 at 08:49
  • I can understand that. If `T --> aTb`, it is easy to describe in nature language. But it's `T --> aSb`, it confused me to describe the structure of T. – Jennifer Q Apr 05 '16 at 13:25
  • Consider `S --> aSb`, `S --> epsilon`, `S --> SS`, which is very close to your grammar. This is similar to block structure in programming languages - a sequence of blocks that could include sequence of blocks, with each block delimited by character `a` and `b`. – MaxP Apr 06 '16 at 06:30

0 Answers0