17.01.2015 Views

Compiler

Compiler

Compiler

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.

Scope rules for names<br />

program L;<br />

var n: char; { n declared in L }<br />

procedure W<br />

begin<br />

writeln(n) { occurrence of n in W }<br />

end;<br />

procedure D;<br />

var n: char; { local declaration of n }<br />

begin<br />

n := ´D´;<br />

W { W called within D }<br />

end;<br />

begin<br />

n := ´L´;<br />

W; { W called from main }<br />

D { D called from main }<br />

end.<br />

Static scoping<br />

Output: L L<br />

53<br />

11/24/2011

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

Saved successfully!

Ooh no, something went wrong!