I am implementing a simple tool using ASIS(Ada Semantics interface Specifications).
I am having problem with listing child elements in a given Elements.for example i am having assignment statement as
C := A + B;
i am able to get the element(expression) which represents "A + B", from the above assignment statement but need to extract A, B elements individually from the above expression.
what is the query in ASIS for doing the same. i have tried "Traverse_element" but not able to succeed.
Asked
Active
Viewed 66 times
1

Lakshman Naik
- 45
- 7
1 Answers
3
A + B
is a function call, so you have to extract the actual parameters of the function call using:
declare
use ASIS.Expressions;
begin
for Parameter_Association of Function_Call_Parameters (Expression => Element,
Normalized => True) loop
declare
Formal : constant Asis.Element := Formal_Parameter (Parameter_Association);
Actual : constant Asis.Element := Actual_Parameter (Parameter_Association);
begin
...
end;
end loop;
end;

Jacob Sparre - at CLDK
- 430
- 3
- 8
-
Does the method will work, if the expression contains more functions(eg : A + B*C)? – Lakshman Naik Jun 11 '18 at 08:07
-
Yes, but then one of the actuals will be a function call. – Jacob Sparre - at CLDK Jun 11 '18 at 09:24