The syntax_updater tool is a purely syntactical tool so it does not know about locals/arguments/attributes within the body of a routine. If you need to do that, then you need to add code to perform that detection. That is to say lookup the name of the identifier and compare it with either the arguments, locals of the routine, or the object test local if you are under the scope of one.
Note that the parser does not store the name but their ID. So it is sufficient to compare IDs to see if they refer to the same name.
From: eiffelst...@googlegroups.com [mailto:eiffelst...@googlegroups.com] On Behalf Of Jimmy Johnson
Sent: Monday, April 13, 2015 04:35
Subject: [EiffelStudio Dev] How to modify "syntax_updater" ?
My attempt to modify the compiler did not work, so I want to try a new tack. I want a pre-processor to insert code at the appropriate points. As before, I want to insert a line of code as the last line of [the body] of a routine, if one of the attributes of the enclosing class has been changed (through an assignment statement of creation call) in the body.
I have been trying to modify the "syntax_updater" to do this insertion. Using `process_assign_as' from SYNTAX_UPDATER_VISITOR I can add code after an assignment, but this inserts the code after EVERY assignment; not what I need. I thought maybe I could get a reference to a ROUTINE_AS in `process_body_as' and if the target of the assignment was not in `locals' or `object_test_locals' then it must be an attribute, right? The problem is that I do not see how to assess the xxx_AS items in `locals' in order to do the comparison.
Can y'all give me some help (... again)?
Jimmy J. Johnson
For more messaging options, visit this group at http://forum.eiffel.com.
Information on the Eiffelstudio project: http://dev.eiffel.com.
You will find a query called `feature_name’ in ACCESS_FEAT_AS of type ID_AS. From that, you can query `name’. Note that `name’ depends on NAMES_HEAP which is populated during parsing.
The target of the call is represented by the ACCESS_ID_AS node.
This is the nature of the encoding of nested calls. What you need to look at is descendants of CALL_AS. You will see the unqualified variants (descendants of ACCESS_AS), CREATION_EXPR_AS, NESTED_AS and NESTED_EXPR_AS.
So you should process instances of NESTED_AS as well and to perform your processing only once.