This page is an accumulation of (we hope) helpful notes, hints, etc., that might be useful to you in doing Project #3.
A ()
and render it as an ordinary call in which the "function" is the type A and the type of A() is A (i.e., (type (id .... "A"))). Likewise, don't do anything special with __init__ for this project (treat as an ordinary def).
setselect
analogously to
select
when selecting from a type. That is,
(setselect (id I) T E)becomes simply
(assign (id I) E)
[For a call f(a1,...,an)]:A. When f is a simple identifier (i.e, no dots), there is no definition of f in scope, n>=1, and there is an instance method of a1 named f, then the function that is called is (a1).f. So, if foo is not otherwise defined, foo(x) becomes ((x).foo)(x), but rewrite rule B, below is {\it not subsequently applied.
B. When f is a selection of the form E.g, E is a value (not a type), and g is defined as an instance method..., a copy of the value of E is inserted as the first parameter of g. That is, E.g. (a1,\dots,an) becomes in effect (E.g)(E,a1,\dots,an), where E is evaluated only once. This rewrite rule applies at most once (so as not to cause an infinite regress).
for x in L: ...assigns to "x", and should count as a declaration, just like an assignment statement.
def a = 3 def f (x): global ais illegal.
Q: Is "x = 3" a declaration (such that x is declared as of type Any)?
A: Yes, except in situations where x is already declared. For example, only one x is declared in
def f (): x = 3 x = x+y # Same xor in
x = 3 def f (): global x x = 42 # NOT a new x.or in
def f (x): x = 42 # Same as parameter x.
Q: By my understanding i:T does not get populated into the symbol table—it is there for the type checking phase of the semantic analyzer.
A: Well, you can use the symbol table as you like, but in my suggested outline, you are correct that one does not need to put this i into the symbol table: it will have been decorated with the appropriate decl elsewhere and you simply have to update the static type on that decl when you do the typing pass.
Q: In the prelude there were these two lines
None: Void def None = Void.__None__ ()now would this be declaring the symbol "None" twice and thus cause an error when populating the symbol table?
A: No. Type declarations do not define symbols. For example, the program consisting solely of
Foo: Intis illegal, since Foo is not defined.
Q: What are the "members of a class" that should be listed in classdecls? A: All instance variables, constants, defs, and class defs in the body of the class (not including inherited ones).
Q: The pretest wouldn't work until I had manually set SemanticTest (and ParsePyth) to be executable. Should I have to do that, am I doing something wrong?
A: You must have done something wrong at some point. When you "svn co" or "svn copy" the skeleton, these files are marked executable. I presume that what happened is that you entered these files in the first place by copying them without their executable bits and then svn adding them (or by some means other than svn copy).
To correct the situation, first chmod them to be executable in your working directory:
chmod u+rx ParsePyth SemanticTestand then inform Subversion:
svn propset svn:executable "*" ParsePyth SemanticTest svn commit
This last step is unnecessary when (1) the files are executable when you first svn add them, or (2) you check out or copy files that have the executable property.
[CS164 Homework]   [CS164 Home Page]
Page was last modified on Sun Mar 30 15:43:15 2008.