{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

10 Attribute Grammars

10 Attribute Grammars - Attribute Grammars Well look...

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

View Full Document Right Arrow Icon
Attribute Grammars We’ll 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 Knuth’s 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
Image of page 1

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

View Full Document Right Arrow Icon
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. Let’s 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 ::= 0 | 1 Quick quiz: what does this grammar describe? Ben Hardekopf () CS 290C Program Analysis Fall 2011 2 / 12
Image of page 2
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?
Image of page 3

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

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern