
Boolean Expressions and Control Flow in Compiler Construction
This lecture covers topics such as numeric implementation and positional encoding of Booleans, short-circuit evaluation, debugging, syntax-directed definitions (SDD), and dealing with attributes in Pascal-like declarations. It also touches on YACC-generated parsers, symbolic tables, and hierarchical symbol tables, providing insights into generating compilers efficiently.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
CSCE 531 Compiler Construction Lecture 16 Boolean Expressions and Control Flow Topics Numeric Implementation of Booleans Positional Encoding of Booleans Short Circuit Evaluation Debugging Readings: 5.7, 6.3, 7.4 March 27, 2018
Overview Last Time Attribute Grammars Type Systems ILOC Symbol Table Last Time Didn t Finish Pascal like declarations Hierarchical Symbol Tables Today s Lecture Numeric Implementation of Booleans Positional Encoding of Booleans Short Circuit Evaluation Debugging YACC generated parsers References: Sections 7.4 Homework: CSCE 531 Spring 2018 2
Pascal like declarations What if the language gets it wrong? Pascal x,y,z : integer; Grammar? CSCE 531 Spring 2018 3
Syntax-Directed Definitions (SDD) A syntax-directed definition (SDD) is a context-free grammar together with attributes and rules. Attributes are associated with grammar symbols and rules are associated with productions. If X is a symbol and a is one of its attributes, then we write X:a to denote the value of a at a particular parse-tree node labeled X . CSCE 531 Spring 2018 4
Synthesized an Inherited attributes W e shall deal with two kinds of attributes for nonterminals: 1. A synthesized attribute for a nonterminal A at a parse- tree node N is defined b y a semantic rule associated with the production at N . Note that the production must have A as its head. A synthesized attribute at node N is defined only in terms of attribute values at the children of N and at N itself. 2. An inherited attribute for a nonterminal B at a parse-tree node N is defined by a semantic rule associated with the production at the parent of N . Note that the production must have B as a symbol in its body. An inherited attribute at node N is defined only in terms of attribute values at N 's parent, N itself, and N 's siblings. CSCE 531 Spring 2018 5
Synthesized Attributes Example 5.1 n = end marker, why not ; or I don t know CSCE 531 Spring 2018 6
Figure 5.3 CSCE 531 Spring 2018 7
Example 5.3, Figure 5.4 val a synthesized attribute of T, F; the value inh an inherited attribute * F T1 -- inherits the left operand of * T CSCE 531 Spring 2018 8
Fig 5.5 Inherited Attribute T * F T CSCE 531 Spring 2018 9
Hierarchical Symbol Tables From last time figure 5.12 page 246 CSCE 531 Spring 2018 10
Test 2 CSCE 531 Spring 2018 11
History of Compilers The first compiler was written by Corrado B hm, in 1951, for his PhD thesis. The term compiler was coined by Grace Hopper.[1][2], referring to her A-0 system which functioned as a loader or linker, not the modern notion of a compiler. The FORTRAN team led by John W. Backus at IBM introduced the first commercially available compiler, in 1957, which took 18 person-years to create.[3] The first ALGOL 58 compiler was completed by the end of 1958 by Friedrich L. Bauer, Hermann Bottenbruch, Heinz Rutishauser, and Klaus Samelsonfor the Z22 computer. CSCE 531 Spring 2018 12