What is the source of smoky flavor for barbecued foods?
Harold McGee's "On Food and Cooking" has an interesting explanation on the chemistry of smoke (pg 448 on my edition). This is a summary of what it says:

The three main component of wood are:

Cellulose



Hemicellulose



Lignin



(Source: Wikimedia)

Cellulose and hemicellulose make up the "scaffold" of plant cells and ligning binds cells together.

These three compounds release specific compounds when they burn. Cellulose and hemicellulose release sweet/fruity compounds such as furans, lactones, acetaldehyde, acetic acid and diacetyl. These are similar to what you get during caramelization: indeed those hexagonal rings you see in the first two structures are common to many sugars.

Lignin, on the other hand, releases other smoky/spicy flavours, due to the presence of aromatic rings (those hexagons with a circle inside in its formula): guaiacol, vanillin, isoeugenol, phenol, syringol. 

The specific amount of each compound that is released depends on the specific type of wood and the burning temperature; it obviously affects taste.


  Maximum flavor production takes place at relatively low, smoldering temperatures, between 570 and 750°F/ 300-400 °C; at higher temperatures, the flavor molecules are themselves broken down into simpler harsh or flavorless molecules.