10 Attribute Grammars

10 Attribute Grammars - Attribute Grammars Well look...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Attribute Grammars Well look briefly (and informally) at an alternative framework for program analysis called Attribute Grammars . This framework was initially proposed by Knuth in 1968 for defining program semantics, and has since been extended in ability and scope and also used for program analysis. Attribute grammars are not mainstream, but there are still people who use them and who actively research attribute grammars themselves. Much of the material in these slides comes from Knuths original paper Semantics of Context-Free Languages, and the rest is due to Ben Wiedermann (a professor at Harvey Mudd). Ben Hardekopf () CS 290C Program Analysis Fall 2011 1 / 12 What Are Attribute Grammars? Definition (Attribute Grammar) An attribute grammar, informally, is a context-free grammar plus a set of functions (called attributes ) for each production of the grammar. Lets look at this concept using a very simple grammar (in fact, the same one Knuth used in his paper): Example (Context-Free Grammar) N ::= L | L . L L ::= B | LB B ::= | 1 Quick quiz: what does this grammar describe? Ben Hardekopf () CS 290C Program Analysis Fall 2011 2 / 12 Defining Semantics The grammar specifies sequences of binary digits, optionally followed by a point and another sequence of binary digits. For example: 101.11 . But how do we define the meaning of these sequences?...
View Full Document

Page1 / 12

10 Attribute Grammars - Attribute Grammars Well look...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online