5.4 Attribute Grammars
The processing required to build up the meaning of a higher syntactic construct from the meaning of a sequence of lower constructs is formalized by the use of attribute grammars.
We augment a grammar by associating attributes with each grammar symbol that describes its properties. An attribute has a name and an associated value, which may be a string, a number, a type, a memory location, an assigned register – whatever information we need to associate with that symbol in order to specify its meaning. For example, variables may have an attribute type, which keeps track of the declared type of a variable, useful later in type-checking or an integer constant may have an attribute numerical value, which we will later need to ...
Get Compilers: Principles and Practice now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.