28.04.2014 Views

Names, Scopes, and Bindings Names, Scopes, and ... - Lrde - Epita

Names, Scopes, and Bindings Names, Scopes, and ... - Lrde - Epita

Names, Scopes, and Bindings Names, Scopes, and ... - Lrde - Epita

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Bindings</strong><br />

Symbol Tables<br />

Complications<br />

(Non Scoped) Symbol Tables<br />

<strong>Bindings</strong><br />

Symbol Tables<br />

Complications<br />

Scoped Symbol Table: symbol::Table<br />

An associative array<br />

put<br />

get<br />

Implementation<br />

a list<br />

a tree<br />

a hash<br />

...<br />

class Table<br />

template< class Entry_T ><br />

class Table<br />

{<br />

public:<br />

Table ();<br />

void put (Symbol key, Entry_T& val);<br />

Entry_T* get (Symbol key) const;<br />

void scope_begin ();<br />

void scope_end ();<br />

void print (std::ostream& ostr) const;<br />

};<br />

Not very C++...<br />

A. Demaille, R. Levillain <strong>Names</strong>, <strong>Scopes</strong>, <strong>and</strong> <strong>Bindings</strong> 29 / 55<br />

<strong>Bindings</strong><br />

Symbol Tables<br />

Complications<br />

Scoped Symbol Table Implementations<br />

A. Demaille, R. Levillain <strong>Names</strong>, <strong>Scopes</strong>, <strong>and</strong> <strong>Bindings</strong> 30 / 55<br />

Memory Management<br />

<strong>Bindings</strong><br />

Symbol Tables<br />

Complications<br />

Mixing Stacks <strong>and</strong> Associative Arrays<br />

Copying, or not copying?<br />

Functional (Non Destructive) Versions<br />

Mongrels<br />

When do you deallocate associated data?<br />

scope end deallocate everything since the latest scope begin<br />

pass end deallocate auxiliary data after the traversal is<br />

completed<br />

ast bind the data to the ast <strong>and</strong> delegate deallocation<br />

by h<strong>and</strong> thanks God for Valgrind <strong>and</strong> Paracetamol<br />

never tu sors<br />

A. Demaille, R. Levillain <strong>Names</strong>, <strong>Scopes</strong>, <strong>and</strong> <strong>Bindings</strong> 31 / 55<br />

A. Demaille, R. Levillain <strong>Names</strong>, <strong>Scopes</strong>, <strong>and</strong> <strong>Bindings</strong> 32 / 55

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!