Show in graph
Σ*

Theory → Formal Languages

Grammar

A formal system of production rules for generating strings in a language.

Motivation

Grammar solves the problem of specifying how valid strings or programs are formed.

Where it fits

Grammar belongs to formal languages, parsing, and programming languages.

Mental model

A grammar is a rule system for building valid sentences from symbols.

Common mistakes

  • Confusing syntax rules with semantic meaning.
  • Assuming all grammars are equally easy to parse.

Grammar connects to formal language, parser, AST, context-free language, and compiler.