Attribute grammar is a type of context-free grammar that augments syntactic rules with semantic rules by adding attributes to non-terminals. Attributes have defined value domains and can pass information between nodes in a parse tree. There are two types of attributes: synthesized attributes derive their values from child nodes, while inherited attributes can take values from parent and sibling nodes. Attribute grammars can be categorized as S-attributed or L-attributed based on whether attributes only flow bottom-up or both bottom-up and top-down, respectively.