Virtual Pascal

Classic Object Pascal for free

G'day Folks,

Does anyone have the code to build/display a typical
hierarchy pls ?

To clarify, I'm thinking of the sort of thing you'd find in
a business to display who's in charge of whom/what etc...

Tho' I wish to use it to see the hierarchy of all the
functions & procedures I've built over the years,
ie: in units etc.    And what depends on what etc.

I already have code to extract the info .. currently held
in a simple text line structure - tho' that could easily be
turned into a record/structured format if necessary.  

But it is getting it all into the correct hierarchical order
of what depends on what etc .. that currently eludes me :-)


I'm thinking that it seems to suggest some sort of tree
structure is needed - tho' I don't quite see how to ensure
the dependency order is correct.... 

NB:: I have tried playing with various forms of sorts - but
without finding the correct answer so far.

And it also seems it would need to be recursive ... but if
at all possible, I'd like to avoid that as well.  ie: the depth could

become significant .. (eg: almost everything needs to call 'Abort'

- sooner or later).

Does anyone have any - preferably Pascal - code to do this?
(Or even Assembler)!    But pls .. not any of the C-family
or similar - unless there's really no other choice.

Or at least some suggestions, comments etc ....

I would have thought that something like this must already
exist in the VP compiler - otherwise it couldn't process the
units in the correct order when compiling....

No doubt it's all quite obvious to most of you - but I
currently...  "can't see the wood for the trees" ...!  :-)

NB: I'm not interested in fancy graphics ... tho' that might
be nice ... (much) later.   

A simple display along the lines of the old Dos directory tree
would be quite helpful ... to get started.   But first, things have

to be organised into the correct order    ....n'est-ce pas..?  :-)

And yes, I've scoured the net ... but without success so far -
or maybe I just haven't found the right search terms ... :-(

Many Thanks,
Barry

Views: 52

Reply to This

Replies to This Discussion

There is a commercial tool called Pascal Analyser from Peganza which does a bunch of static analysis on Pascal/Delphi code.

The VP compiler is not open, and pure assembler, so that doesn't count, and compiler parsers are notoriously complicated anyway. Usually you go for highlighting/documentation oriented parsers.

Free Pascal has a fcl-passrc library. It might not work with VP though, the dialect is probably too old, so that would require you to work in FPC.

G'day Marco,

Thanks for the reply ...

I think I've seen what Peganza does & it's not what I'm looking for...

I'm really after a pictorial (tho' I'd live with a text output) of
what links to what ... sort of like a flow chart ... or a personnel
chart - except there will be multiple connections in most cases,
of course.

I suspect it needs to be a tree .. and I do have an implementation of
a Red/Black tree already (...converted by someone over your way, from
Gnu C).


And .. I like VP way too much ... vs FPC (which I have great
difficulty with).   In passing, I would comment that; given that
FPC is... ummm... Pascal, why is it so much of a pain to convert
anything in FPC... to VP...! ...?    
(It's pretty much impossible for most things)...

But .. that is a whole different discussion ... tho' I suspect the
point of your reply was to try & wean me off ..VP! ... :-)

Anyway, back to the subject...

Since the kind of output/chart/listing I'm after resembles something
like say a (genealogical) Family Tree.. the algorithm must surely be
fairly well-known.  ...No?

And, so far, all I can find on the 'net' has been in C (*if* what I've
'located' does indeed do what I'm seeking) ... And I'm (very) tired of
trying to convert C(++/# or similar) ... to Pascal.

And on that topic .. there don't seem to be any really good C to Pascal
converters around .. tho' the (very) old "CtoPas" does a fair job.

But that too, is another ... discussion ...  tho' I'd be very happy if
anyone *can* point me to something that does a really good job of
converting C to Pascal.

Cheers,
Barry

There is parsing and visualization. The parsing is the most work and most complicated, and even harder if you want it to create conditional dependencies (e.g. in the case of an IFDEF around an unit in the uses clause)

Besides the mentioned FPC library, I assume there are a few on the Delphi side too. (e.g. from Jedi for its reformatting tool). Not all might be written for easy reuse though.

A typical tool used for visualisation of dependencies is "dot" aka Graphviz. 

You can make whatever tool you make for parsing output dependency nodes in dot style and then run it through graphviz.

G'day Marco,

Thanks again for that.

As I haven't yet got an algorithm, the graphics are definitely something for later - tho' I'll keep the details you gave in mind.

As to the IFDEFS & other compiler directives, I'm not interested in those & I haven't collected that info.

Just the names of the Units involved and what calls (something in) them.  ie: I'm trying to get a 'view' of the

overall Unit call hierarchy.

I can imagine that - if I have to make my own 'tree' - it will involve searching the tree *every time* in order to be able to make the sibling link - as only the root/parent & child are known at the start.  

But .. that's only runtime :-)

And as we all have relatively powerful computers (now), that shouldn't really be an issue.

So yes, I can imagine it will be a fair amount of coding work - which is why I was hoping an algorithm already existed.

Cheers

Barry

RSS

© 2017   Created by Allan Mertner.   Powered by

Report an Issue  |  Terms of Service