* * *

Author Topic: convert fpc to c ?  (Read 4675 times)

jack616

  • Sr. Member
  • ****
  • Posts: 265
convert fpc to c ?
« on: March 09, 2015, 04:52:05 pm »
A bit of an odd question here I know but I need a simple FPC to C converter.
I've googled all over the place and not found anything that actually works.
I dont need a massive overcomplicated thing -

I don't need the C code to compile - I have a large number of FPC units to
maintain and need flow charts for - I use  crystal revs pro to produce flowcharts etc.
but that only works with C/C++

So if I can get a basic conversion program it would save me quite a bit of time.
I've tried things like delphi2cpp and the like with no luck.

Does anyone have any suggestions
thanks

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1831
Re: convert fpc to c ?
« Reply #1 on: March 09, 2015, 05:49:02 pm »
Are you looking for:
Code: [Select]
View -> Unit Dependencies
?
if something is missing in the tool, you should be able to easily update it to your needs, since it's open source.

You definitely should stop using Crystal Revs Pro until it actually supports pascal.
Currently you just violate the logic of work: There's a tool for source code. Not source code for a tool.


« Last Edit: March 09, 2015, 05:51:37 pm by skalogryz »

Leledumbo

  • Hero Member
  • *****
  • Posts: 7745
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: convert fpc to c ?
« Reply #2 on: March 09, 2015, 05:54:45 pm »
Does anyone have any suggestions
Use another tool that supports Object Pascal instead. Some results from simple googling (I have no idea why you can't find them):

jack616

  • Sr. Member
  • ****
  • Posts: 265
Re: convert fpc to c ?
« Reply #3 on: March 09, 2015, 06:04:54 pm »
Thanks but sorry
I need to do as I described.
lele - I need to use the tool described.
This isn't for a small hack - the methodology isn't alterable.

If I have to I will need to bash out a simple C converter myself
but I'm pushed for time and hoping I can get on with other tasks
without resorting to doing that.


jack616

  • Sr. Member
  • ****
  • Posts: 265
Re: convert fpc to c ?
« Reply #4 on: March 09, 2015, 06:07:42 pm »
skalogryz  - crystal revs is a professional development environment for C & C++
it doesn't and never will support pascal.






skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1831
Re: convert fpc to c ?
« Reply #5 on: March 09, 2015, 06:12:23 pm »
skalogryz  - crystal revs is a professional development environment for C & C++
it doesn't and never will support pascal.
I don't get it. since Crystal Revs produces the result not based on the pascal code, but rather on the translation of pascal code to C/C++.
I'd think there's would be a slight difference, thus using the flowchart might have some traps.

But, could you please provide an example of the flow chart, that you're using right now? (if you have any flow chart produced based of the pascal code)


jack616

  • Sr. Member
  • ****
  • Posts: 265
Re: convert fpc to c ?
« Reply #6 on: March 09, 2015, 10:17:50 pm »
skalogryz - yes you do seem a little confused.
I'll try and explain a little better.

What I am looking for is something that performs a conversion between fpc to C or C++
Nothing more than that.

I dont need it to be a very good conversion so long as it does the basic function of translating
the basic fpc  syntax into c syntax

given a conversion for example of this sort of thing:

function startfunction(somevar etc);
begin
xxx
end;

into

main (somevar etc) {
xxx

}

and so on - even just removing all other code (but allowing for the function tree of course)
I can then give the output to revs which will produce the flowcharts in the correct format for use.

If the converter can include variables, constants and comments etc then so much the better but the
actual output doesn't need to be compilable or even near it.
Simply producing flowcharts from fpc isn't any use in this case because I'm required to stick to
specific methods hence my need to do this round robin approach.

Looking round google I found many programs that claim to be able to do this but none of them I found
can. Others claim to be shareware when in fact they are just crippleware and therefore no use to anyone
to evaluate.

I was hoping someone here might have migrated some code to C and would know of a good program.

If you wanted to see what revs does there is a free download on their site but I dont know what the free
version is capable of (I bought mine a long time ago) . If you do any serious C programming I can  highly recommend it.



 

avra

  • Hero Member
  • *****
  • Posts: 1172
    • Additional info
Re: convert fpc to c ?
« Reply #7 on: March 10, 2015, 09:05:36 am »
I have used some tool (which I can not remember the name) to convert pascal code to flowchart with success, so I don't know what are your expectations.

For easier understanding of someone else's code SciTools Understand is very valuable.

Anyway, every debian distribution should have p2c pascal to c convertor. You might try some downloadable version from here:
http://schneider.ncifcrf.gov/p2c/
ct2laz - Easily convert components and projects between Lazarus and CodeTyphon

jack616

  • Sr. Member
  • ****
  • Posts: 265
Re: convert fpc to c ?
« Reply #8 on: March 10, 2015, 01:16:07 pm »
Thanks avra that link looks like it may well do the job.
I'll need to compile for centos possibly but assuming that goes well that should be job done
judging by the docs.

cheers

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus