RE: [EiffelStudio Dev] How to modify "syntax_updater" ?

18 views
Skip to first unread message

Emmanuel Stapf

unread,
Apr 13, 2015, 3:07:00 AM4/13/15
to eiffelst...@googlegroups.com

Hi,

 

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.

 

Regards,

Manu

 

From: eiffelst...@googlegroups.com [mailto:eiffelst...@googlegroups.com] On Behalf Of Jimmy Johnson
Sent: Monday, April 13, 2015 04:35
To: eiffelst...@googlegroups.com
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)?

 

Thanks,

Jimmy J. Johnson

--
For more messaging options, visit this group at http://forum.eiffel.com.
Information on the Eiffelstudio project: http://dev.eiffel.com.

Jimmy Johnson

unread,
Apr 13, 2015, 3:02:41 PM4/13/15
to eiffelst...@googlegroups.com, ma...@eiffel.com
Thanks, I have that working now.

How do I get [the text of] the target of a qualified feature call?  as in:
     my_object.feature (arg1: TYPE)...
I want to find the text "my_object".
I've looked at ACCESS_FEAT_AS and EXPRE_CALL_AS.

jjj

Emmanuel Stapf

unread,
Apr 13, 2015, 3:22:10 PM4/13/15
to Jimmy Johnson, eiffelst...@googlegroups.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.

 

Regards,

Manu

Jimmy Johnson

unread,
Apr 13, 2015, 3:35:13 PM4/13/15
to eiffelst...@googlegroups.com, jjj...@g.uky.edu, ma...@eiffel.com
That seems to give me the name of the feature, not the target of the call.  ?

Emmanuel Stapf

unread,
Apr 14, 2015, 3:58:37 AM4/14/15
to Jimmy Johnson, eiffelst...@googlegroups.com

The target of the call is represented by the ACCESS_ID_AS node.

Jimmy Johnson

unread,
Apr 14, 2015, 6:19:07 PM4/14/15
to eiffelst...@googlegroups.com, jjj...@g.uky.edu, ma...@eiffel.com
Thanks Manu; that helped.

So now my syntax_updater can insert a feature with the target as argument after a feature call:
     x.f
becomes
     x.f
     my_inserted_feature (x)

But:
     x.y.f
becomes
     x.y
     my_inserted_feature  (x).f

Notice the inserted code is between the "x.y" and the ".f".  So what type of construct is "x.y.f".  I want to end up with:
     x.y.f
     my_inserted_feature (x)

Thanks,
jjj

Emmanuel Stapf

unread,
Apr 16, 2015, 9:43:34 AM4/16/15
to eiffelst...@googlegroups.com

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.

Reply all
Reply to author
Forward
0 new messages