c0fec0de / anytree

Python tree data library
Apache License 2.0
947 stars 133 forks source link

Determination of direct children counts #160

Closed elfring closed 3 years ago

elfring commented 3 years ago

I would like to determine the number of direct children (for non-leaf nodes). I imagine that unique identifiers will be needed then as references for relevant nodes. But the tree iteration is working with the attribute “name” (which might not be unique) so far. Thus I imagine also that the usage of paths would become helpful (so that an auxiliary node attribute can be avoided as long as pointer alternatives would not be applicable).

Will a configurable formatting become relevant for the display and further data processing of the calculated counts?

JuliaLawall commented 3 years ago

I have no idea what this is asking about. Nodes in what? The AST? The CFG? Something else? This is not appropriate for Coccinelle. If you want to use the Coccinelle AST or CFG to write a visitor in OCaml, go ahead.

elfring commented 3 years ago

I have no idea what this is asking about.

I imagine that you can contribute a bit more help according to your experiences from various knowledge areas.

The general data structure “tree” triggers some software development challenges. One of them is to count children based on known selection criteria. :thinking: How do you think about to clarify possibilities for counting?

If nodes should be adjusted in-place, unique references would be needed for involved objects.

JuliaLawall commented 3 years ago

On Thu, 1 Apr 2021, Markus Elfring wrote:

  I have no idea what this is asking about.

I imagine that you can contribute a bit more help according to your experiences from various knowledge areas.

The general data structure “tree” triggers some software development challenges. One of them is to count children based on known selection criteria. 🤔 How do you think about to clarify possibilities for counting?

If nodes should be adjusted in-place, unique references would be needed for involved objects.

Maybe what yyou want is the number of statements + the number of expressions.

julia

elfring commented 3 years ago

Maybe what yyou want is the number of statements + the number of expressions.

JuliaLawall commented 3 years ago

On Fri, 2 Apr 2021, Markus Elfring wrote:

  Maybe what yyou want is the number of statements + the number of expressions.
  • Another answer depends on views for a specific software development task at the moment.
  • It seems that we are still trying to achieve a better common understanding also according to the use case “Replacing #define directives with the help of SmPL”.

I don't see why you would want the number of children of an AST to remoace

defined with enums.

julia

elfring commented 3 years ago

I don't see why you would want the number of children of an AST to remoace #defined with enums.

:thinking: I imagine that a few macros can be converted to enumerations if their identifiers share (prefix) patterns. I presented a conversion approach where such identifiers can be transformed into trees so that prefixes (or key words) which will occur more than once can be determined in a systematic way.

JuliaLawall commented 3 years ago

On Fri, 2 Apr 2021, Markus Elfring wrote:

  I don't see why you would want the number of children of an AST to remoace #defined with enums.

🤔 I imagine that a few macros can be converted to enumerations if their identifiers share (prefix) patterns. I presented a conversion approach where such identifiers can be transformed into trees so that prefixes (or key words) which will occur more than once can be determined in a systematic way.

This has nothing to do with Coccinelle. You made a data structure. Surely you can figure out how to count the children in this data structure.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.[AAD2ZGUNNBVQ25SAKDHMCBDTGWDGLA5CNFSM42HT3L6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOGBWPBDI.gif]

elfring commented 3 years ago

This has nothing to do with Coccinelle.

:thinking: I find that related applications can be considered and accordingly clarified.

Surely you can figure out how to count the children in this data structure.

This is the purpose of this issue in combination with a software like “anytree”. Do any development considerations become relevant then for the distinction of mutable and immutable data structures?

elfring commented 3 years ago

Will any extensions become helpful also for the software documentation?