Rascal:布尔在创建AST时的collectBindings有什么作用? [英] Rascal: what does the bool collectBindings in creating AST do?

查看:84
本文介绍了Rascal:布尔在创建AST时的collectBindings有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于在无赖中创建AST的问题。
我通常会执行以下操作:

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

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

首先,我将collectBindings设置为true。但是对于某些项目,我会得到一个堆栈溢出错误。这可能是因为我使用了Luna eclipse,但是这让我想知道collectionbinding的作用是什么?

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?

我尝试查找它,但是找不到任何文档(也许是我的Google技能不好)。我也尝试在具有不同设置的集合绑定的同一项目上运行它,并进行比较,但是我什么都看不到。

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?

谢谢!

推荐答案

CollectBindings在解析Java代码之后执行另一步骤,该步骤是在代码中尽可能解析所有名称和类型。然后从Java编译器收集此信息,并将其直接存储到Rascal AST中。

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.

因此,如果您需要精确的限定名称或表达式和变量的类型,则 collectBindings 应该设置为 true 。例如下面的代码:

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;

没有resolveBindings绑定 a 的两种用法AST中的代码不会通过 @decl 注释指向声明,说 | java + variable:/// something / a | ,并且通过 @typ 注释他们不会知道它们是 int()。甚至 int 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.

<$ c $您看到的c> StackOverFlowError 是josvr在github上报告的: https ://github.com/cwi-swat/rascal/issues/735 。这是由JDT Java编译器中的语义变化引起的(可能是错误,可能是其他)。

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.

这篇关于Rascal:布尔在创建AST时的collectBindings有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆