【发布时间】:2014-11-04 17:26:06
【问题描述】:
这更像是一个简单的个人尝试,以了解 Rascal 内部发生的事情。必须有更好的(如果尚未支持)解决方案。 代码如下:
fileLoad = |home:///PHPAnalysis/systems/ApilTestScripts/simple1.php|;
fileAST=loadPHPFile(fileLoad,true,false);
//assign a simple id to each node
public map[value,int] assignID12(node N)
{
myID=();
visit(N)
{
case node M:
{
name=getName(M);
myID[name] =999;
}
}
return myID;
}
ids=assignID12(fileAST);
给我
|stdin:///|(92,4,<1,92>,<1,96>): Expected str, but got value
loadPHPFile 返回一个类型为:list[Stmt] 的节点,其中每个 Stmt 都是程序中可能出现的多种语句之一(在我的例子中是 PHP)。不谈为什么我会这样做,为什么上面的代码不起作用?尤其令人沮丧的是,在线文档中提供了一个非常简单的示例。见:http://tutor.rascal-mpl.org/Recipes/Basic/Basic.html#/Recipes/Common/CountConstructors/CountConstructors.html
【问题讨论】:
标签: rascal