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

非 Y 不嫁゛ 提交于 2019-12-12 16:19:38

问题


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!!!


回答1:


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.



来源:https://stackoverflow.com/questions/27397593/rascal-what-does-the-bool-collectbindings-in-creating-ast-do

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!