6.0 Introduction

6.1 Static Checking

6.2 Attribute Grammars

6.3 Translation to an IR

6.4 Semantic Analyzer Generators

6.5 More on Attribute Grammars

6.6 Attribute Evaluation

6.7 Summary

Web References

Exercises

6.5.3 S-Attributed Attribute Grammars

Attribute in an S-attributed grammar can be evaluated at parse time by a bottom-up parser. Interestingly, these grammars form a subset of the L-attributed grammars.

      An attribute grammar is S-attributed if and only if:

  • It is L-attributed.
  • Nonterminals have only synthesized attributes.

           This allows attributes to be evaluated during LR-parsing.

      L-attributed and S-attributed grammars allow efficient evaluation---either during parsing or as a single pass after parsing.

      In Section 6.6, we see another method and a different attribute restriction that allows attribute evaluation during top-down parsing.

     For the next few sections, we focus on restrictions to attributes that allow for efficient attribute evaluation.

Send questions and comments to: Karen Lemone