guide03 - CSCI 3155 Student Notes Decorating a Parse Tree...

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

View Full Document Right Arrow Icon
CSCI 3155 Student Notes Decorating a Parse Tree and Building a Symbol Table 3.1 3. Decorating a Parse Tree and Building a Symbol Table Coursework and Goals for This Part of the Course : By the end of this section, you will be able to… o discuss issues that revolve around names in programming languages o describe the four common kinds of storage location for variables, giving examples from languages such as C++ and the CSCI 3155 Language o explain the difference between a variable’s lifetime and its scope o determine precisely which variable declaration will be used for an identifier in any given program (for either static or dynamic scooping) o determine whether examples of common compiler actions (such as binding) are primarily static or dynamic o identify alias in languages such as C++ and the CSCI 3155 Language o use the tree and symbol_table classes to build a parse tree that is decorated with the attributes defined in Section 3.6 of this guide Read Sebesta §3.4, 5.3, 5.4, 5.8, 5.9 Lecture topics: o What we have now: The lexer and the parser o A side-trip to Chapter 5: s Names s Variables Name Storage location o Static o Stack dynamic o Explicit heap dynamic o Implicit heap dynamic Data Type Lifetime Value Scope o Binding time o Scoping s Static scoping s Dynamic scoping o Our tree class o The lexer’s role in building a parse tree o The parser’s role in building a parse tree o Our symbol table class o The traverser s Maintaining the symbol table s Attaching attributes to the parse tree o Homework discussion including using a makefile Bison Reference: www.delorie.com/gnu/docs/bison/bison_toc.html Homework 3: Building and Traversing the Parse Tree
Background image of page 1

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

View Full DocumentRight Arrow Icon
CSCI 3155 Student Notes Decorating a Parse Tree and Building a Symbol Table 3.2 3.0. &ames, Variables, Bindings, Scope Before diving into the material for this guide, you'll need to be familiar with the concepts from Chapter 5 of Sebesta's book. A partial list of those concepts is given in the lecture topics on page 3.1 of this guide. 3.1. A Tree Class After completing Homework 2, you have a parser function, yyparse , that determines whether an input file is a valid CSCI 3155 Program. Our next task is to modify yyparse so that when the input file is valid, the parser will build a parse tree. At the end of a successful parse, we will have a pointer to a tree that is from the colorado::tree class in the tree.h and tree.cxx files in www.portmain.com/proglang/CU++/Part3. Here are some things to note as you read through the documentation of the tree class: 3.1.1. The tree class is part of the colorado namespace. Therefore, when you declare a pointer to a tree variable, you must use the fully qualified name colorado::tree* or make sure that you have written the directive: using namespace colorado; Keep in mind that you should never put a using directive in a header file. 3.1.2.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 11

guide03 - CSCI 3155 Student Notes Decorating a Parse Tree...

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

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