我正在尝试将 Ada 程序中的库从 ASIS 转换为 Libadalang,但我无法找到转换。
我不是 ASIS 或 libadalang 专家,但快速浏览文档表明,包Asis.Iterator
(描述、代码(中的(通用(Traverse_Element
函数可以(或多或少(映射到包Libadalang.Analysis
中定义的 libadalangTraverse
函数:
function Traverse
(Node : Ada_Node'Class;
Visit : access function (Node : Ada_Node'Class) return Visit_Status)
return Visit_Status;
-- Given the parent node for a subtree, traverse all syntactic nodes of
-- this tree, calling the given function on each node in prefix order
-- (i.e. top-down). The order of traversing subtrees follows the order
-- of declaration of the corresponding attributes in the grammar. The
-- traversal is controlled as follows by the result returned by Visit:
--
-- Into The traversal continues normally with the syntactic
-- children of the node just processed.
--
-- Over The children of the node just processed are skipped and
-- excluded from the traversal, but otherwise processing
-- continues elsewhere in the tree.
--
-- Stop The entire traversal is immediately abandoned, and the
-- original call to Traverse returns Stop.
跟
type Visit_Status is (Into, Over, Stop);
似乎还有另一个迭代器包,Libadalang.Iterators
,它提供了更多的迭代器功能。
AdaCore有几篇博客文章提供了如何使用libadalang
的API的示例。例如:
- 远征利巴达朗(演示
Traverse
功能( - 进一步远征利巴达朗