Phaeton
Phaeton

Reputation: 79

Rascal: what does the bool collectBindings in creating AST do?

I have a question about creating a AST in rascal. I normally do the following:

model = createM3FromEclipseProject(|project://testproject|);
decls = createAstsFromEclipseProject(model.id, false);

At first i would set the collectBindings to true. But for some projects i get a stack overflow error. This could be because i use Luna eclipse but it made me wonder what the collectionbinding does?

I tried to look it up but i could not find any documentation (maybe my google skills are bad). I also tried to run it on the same project with different settings for the collection binding and compare but i could not really see anything.

Can someone explain to me what the collectionbinding does, and why you would (not) use it?

Thanks!!!

Upvotes: 3

Views: 450

Answers (1)

Jurgen Vinju
Jurgen Vinju

Reputation: 6696

CollectBindings does another step after parsing the Java code, which is to resolve all the names and types where possible in the code. This information is then collected from the Java compiler and stored directly into the Rascal AST.

So if you need precise qualified names or the types of expressions and variables, then collectBindings should be set to true. For example in this code:

int a = 0;
int b = a + a;

Without resolveBindings the two uses of the a in the AST would not point to the declaration via the @decl annotation saying |java+variable:///something/a| and they would not know they are int() via the @typ annotation. Even the int a declaration itself wouldn't know its qualified name or its type.

The StackOverFlowError you see has been reported by josvr on github: https://github.com/cwi-swat/rascal/issues/735 . It is caused by a change in semantics in the JDT Java compiler (could be a bug, could be something else).

If you are stuck now, I would advise going back to Keppler.

Upvotes: 1

Related Questions