How to write grammar production rules to describe recursive structures? I'm trying to describe a data structure by production rules. The structure is recursive; say a list of type $A$ made of elements of type $A$ or $B$.

Writing the grammar, I build this:


  $(S \rightarrow AS|ε)$
  $(A \rightarrow AA|bA|ε)$


where $b$ is a terminal representing element $B$ of my list.

The production $A \rightarrow AA$ got me a little baffled... is there something right? Thank you.
Yes, you can use context-free grammars to describe data structures, but only if the data structure is linear (e.g., a linked list of integers).  Context-free grammars are not well-suited for trees or graphs (for those, you need something more powerful).

There's nothing wrong with a production like $A \to AA$; that's a valid rule that can appear in a context-free grammar.