DOC PREVIEW
CSU CS 453 - LECTURE NOTES

This preview shows page 1 out of 2 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS453 Intro and PA1 1CS453 Lecture Symbol Table 1Plan for Today Attributes– Inherited– Synthesized Calculating line and position for each AST node Scope– environments– static versus dynamic scope– scope examples– scoping for MiniJava Symbol Table– info maintained and basic operation– the SymTable class you will be implementingCS453 Lecture Symbol Table 2Calculating Lines and PositionsCS453 Lecture Symbol Table 3Example of calculating lines and positionsCS453 Lecture Symbol Table 4Scope Terms– environment– scope– visibility Example scopes– global scope– file scope– named space– package– unnamed scopes Scoping in MiniJavaCS453 Intro and PA1 2CS453 Lecture Symbol Table 5Static versus Dynamic Scope Static Scope– also called lexical scope because can determine scoping by analyzing theprogram– each use of a variable is bound to a location statically Dynamic Scope– each use of a variable is bound to the most recently visible defined valuefor that same variable nameint x = 0;int f () { return x; }int g () { int x = 1; return f(); }CS453 Lecture Symbol Table 6SymTable and STE classes SymTable interface (DO NOT change the SymTable members or interface)– SymTable pushClassScope(String classname)– SymTable pushMethodScope(String methodname)– SymTable popScope()– STE lookup(String sym)– void insert(STE ste)– int outputDot(java.io.PrintStream out, int nodeCount)CS453 Lecture Symbol Table 7Example SymTable dot outputclass VarError1{ public static void main(String[] a){ System.out.println(1); } }class Class1 { public int foo() { if (a) {} else {} return 0; }}CS453 Lecture Symbol Table 8Using the SymTable


View Full Document

CSU CS 453 - LECTURE NOTES

Download LECTURE NOTES
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view LECTURE NOTES and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view LECTURE NOTES 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?