rascal - cannot traverse the nodes of an AST, while assigning each node an ID -
It is a simple personal effort to understand what is happening inside rascals should be better (if not already supported ) The solution here is the code:
fileLoad = | Home: ///PHPAnalysis/systems/ApilTestScripts/simple1.php | | FileAST = loadPHPFile (fileLoad, true, false); // Assign a simple ID to each node public map [value, int] ID12 (node N) {myID = (); Travel (N) {Case node M: {name = getName (M); IID [name] = 99 9; }} MyID return; } ID = Assigned 12 (file AST);
gives me
| Stdin: /// | (92,4, & lt; 1,92 & gt ;, & lt; 1,96 & gt;): Expected string, but found value
loadPHPFile returns a type of node : The list [STMT], where each STMT can be in a program that is one of the many types of statements (my case in PHP). Why do not the above mentioned code work without knowing why I am doing this? Especially frustrating because a very simple example is used in online documentation. See:
I started a new console, and it starts working. Of course, I changed the type of return from the map [value, et] [i.e. str, int] because it was originally in the example.
The problem was that I could have defaced the function by default in the past. When I fixed a clear problem soon, he kept errors in me. I realized that in Rascal, when you have started a console and imported some definitions, it is impossible to overwrite those definitions (think) interpreter keeps you in the context of the first definition provided. It can be just a type-checker interpreter, and can stop unintentional and / or inconsistent work under the road, it is understood for the variable (in the general program sense), but on this task (or methods) Apply does not seem to be the best idea. I think it gets cumbersome, because a user usually needs to go through some iterations before it is satisfied with the function definition. Just my opinion though ...
Comments
Post a Comment