Context-free grammar (CFG) is typically used to describe the hierarchical structure of most programming languages. They allow the definition of nested structures, such as matching parentheses, nested loops, and if-else statements, which are common in programming languages. Parsers such as LL, LR, and their variations use CFGs to generate parse trees that represent the syntactic structure of source code.