Cheat sheets

CD-11Cheat sheet1 pageIn a paid pack

Syntax-Directed Definitions and Attributes

Syntax-directed definitions: grammar plus semantic rules, synthesized and inherited attributes, the annotated parse tree of 2 * 3 + 4 with every value, dependency graphs and topological evaluation order. S-attributed and L-attributed definitions compared, a routine that classifies any rule, an inherited attribute passing a declared type down a list of names, and solved past questions on classification and evaluation. Values come from a script that runs the rules on a real parser.

Diagrams from CD-11

CD-12Cheat sheet1 pageIn a paid pack

Translation Schemes and Evaluations

Syntax-directed translation schemes: actions embedded in production bodies, postfix schemes executed at reductions, and marker non-terminals for actions in the middle of a body. Script-run evaluations: infix to postfix output, the print order of a scheme with ε-productions, operators with invented semantics where the grammar decides precedence and associativity, a type-and-width computation for arrays, an inherited attribute carried through an LL grammar, and bottom-up evaluation with a value stack.