L167AG - CS784 (Prasad) L167AG 1 Attribute Grammars...

Info iconThis preview shows pages 1–8. 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

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: CS784 (Prasad) L167AG 1 Attribute Grammars Attribute Grammar is a Framework for specifying semantics and enables Modular specification. http://www.cs.wright.edu/~tkprasad/papers/Attribute-Grammars.pdf CS784 (Prasad) L167AG 2 Correct Programs ( no run-time errors ) Regular ( lexer ) Context-free ( parser ) Context-sensitive ( type-checker ) CS784 (Prasad) L167AG 3 Semantics of Bit Pattern : 0101110 Number 46 ( if base 2) 101110 ( if base 10) Fraction 23/64 Unary encoding 13 ASCII Character . Switch positions ON-OFF-ON- Binary string 0101110 CS784 (Prasad) L167AG 4 Motivation for Precise Specification Capture subtly different semantics for the same syntax in various languages. : Arrays and strings. : Parameter passing mechanisms. : Scoping rules. : Primitive types vs Composite types. : Type equivalence. CS784 (Prasad) L167AG 5 Attribute Grammars Formalism for specifying semantics based on context-free grammars (BNF) Static semantics ( context-sensitive aspects ) Type checking and type inference Compatibility between procedure definition and call Dynamic semantics Associate attributes with terminals and non-terminals Associate attribute computation rules with productions CS784 (Prasad) L167AG 6 Synthesized Attributes - - 1 - N - N 1 . val = 0 . val = 1 . val = 2 N . val . val = 2 N . val + 1 CS784 (Prasad) L167AG 7 Derivation Tree N N N 1 1 110 ~> 6 CS784 (Prasad)...
View Full Document

This note was uploaded on 06/02/2011 for the course CS cs784 taught by Professor Tkprasad during the Spring '11 term at New York Institute of Technology-Westbury.

Page1 / 23

L167AG - CS784 (Prasad) L167AG 1 Attribute Grammars...

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

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