The following example shows a typical grammar in a programming language. It's for a list of declarations, simple declarations that declare variables. For now, let's not allow pointers or references or arrays, etc. The list may be empty. An example of a declaration list is int i, j, k; float x, y; char a, b, c, d; bool found; Because it's easy to run out of meaningful names, use "list" in a nonterminal name when it's for a list. Notice that this example has the two typical kinds of syntax: the semicolon, a terminator, and a comma, a separator. The semicolon terminates every declaration. The comma separates identifiers from the rest of the identifier list. Use recursion, a declaration list is made up of one declaration (the int line in the above example) followed by a declaration list (a smaller list that has the same format, the float/char/bool lines). The base case is an empty list. --> empty | Now expand the non-terminal. As soon as you see a list is needed, create another non-terminal and expand it later. --> ";" Using the same recursive problem-solving on . It has one identifer followed by a comma separator, followed by an . It can't be empty, so the base case is one identifer. --> <> | <> "," The <> is a token. When you want a specific character, just the symbol or quotes can be used around the symbol to show it, but an identifer can be many strings, yet it is still a token, recognized by the lexical analyzer. It is not a non-terminal and is not expanded. The double pointed brackets is how we show this. Only <>, <>, and <> are these kind of tokens. Expanding give production rules for all the non-terminals and finishes this grammar: --> "int" | "float" | "char" | "bool" | and so on ------------------------------------------------------------------------ Using the grammar developed, here is a parse tree for the code above. Grammar: --> empty | --> ";" --> <> | <> "," --> "int" | "float" | "char" | "bool" | and so on Code: int i, j, k; float x, y; char a, b, c, d; bool found; Abbreviate as DL, as OD, as IL, <> as I, and as T. The recursive --> is used four times to generate four lines. The base case terminates the generation. The children of the lefthand non-terminal of the rule are the components of the righthand side of the rule used. The children, the rule components, include terminals and non-terminals. Only the first is expanded. Expand the others in a similar manner by using the recursive --> <> "," generating <>s for the variables. For the last <>, use the base case. DL / \ OD DL / | \ / \ T IL ; OD DL / / | \ / \ int I , IL OD DL / / | \ / \ i I , IL OD DL / / \ j I lambda / k The leaves of the tree, the terminals, become the code.