Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Pascal to ADA Converter

273 views
Skip to first unread message

arroy...@gmail.com

unread,
Jul 20, 2015, 7:51:35 AM7/20/15
to
Hello,

I have a source code written in pascal which works properly in a specific embedded system.

I want to use the same source code in another enhanced embedded system with a new processor.

This new processor has very poor pascal compiler and my pascal code does not run on it. I was recommend to use an ADA compiler which is good for my processor.

However, I do not want to modify my pascal code since is too large and I would like to use a Pascal to ADA converter (ADA 2012 if possible and runnable in Linux).

I have found one in this web-site:
http://www.adapower.com/index.php?Command=Class&ClassID=Utilities&Title=Ada+Utilities
However, the link is broken.

Does anyone have it? If not, does anyone can recommend me another p2ada converter? (wish: popular, generates ADA 2012 version and runnable in Linux)

G.B.

unread,
Jul 20, 2015, 8:27:33 AM7/20/15
to
On 20.07.15 13:51, arroy...@gmail.com wrote:

> I have found one in this web-site:
> http://www.adapower.com/index.php?Command=Class&ClassID=Utilities&Title=Ada+Utilities
> However, the link is broken.
>
> Does anyone have it? If not, does anyone can recommend me another p2ada converter? (wish: popular, generates ADA 2012 version and runnable in Linux)

Trying this,

https://www.google.de/search?client=safari&rls=en&q=Pascal/Delphi+to+Ada+Converter+(Gautier+de+Montmollin)&ie=UTF-8&oe=UTF-8

has produced a link to sourceforge.net for p2ada.


G.B.

unread,
Jul 20, 2015, 8:28:55 AM7/20/15
to
and sourceforge.net appears to be recovering from something,
so it might take a moment until any link is back again.


Mark Carroll

unread,
Jul 20, 2015, 8:37:48 AM7/20/15
to
"G.B." <bau...@futureapps.invalid> writes:

> and sourceforge.net appears to be recovering from something,
> so it might take a moment until any link is back again.

Yes, their storage array broke and they had to restore from backup.

-- Mark

gautier...@hotmail.com

unread,
Jul 20, 2015, 8:47:13 AM7/20/15
to
The access by the SF project page is still working

http://sourceforge.net/projects/p2ada/

Especially, you can grab the P2Ada sources there:

http://sourceforge.net/projects/p2ada/files/p2ada/Sources/

There are also precompiled binaries.
Cheers
_________________________
Gautier's Ada programming
http://gautiersblog.blogspot.com/search/label/Ada
NB: follow the above link for a valid e-mail address

Fernando Arroyo

unread,
Jul 29, 2015, 4:16:54 AM7/29/15
to
I have downloaded p2ada for Win32 and it works properly in Windows 7 and XP. The problem is that I would like to run this program in linux (or at least in a DOS simulator in linux called DOSEMU). When I try to run this program in DOSEMU, it says that "This program cannot be run in DOS mode". In the repository that you sent me there is not precompiled binaries for intel and linux.

Any idea? It would be preferably don't have to recompile the sources.

Jacob Sparre Andersen

unread,
Jul 29, 2015, 4:30:45 AM7/29/15
to
Fernando Arroyo wrote:
> On Monday, July 20, 2015 at 2:47:13 PM UTC+2, gautier...@hotmail.com wrote:

>> Especially, you can grab the P2Ada sources there:
>>
>> http://sourceforge.net/projects/p2ada/files/p2ada/Sources/

> I have downloaded p2ada for Win32 and it works properly in Windows 7
> and XP. The problem is that I would like to run this program in linux

Why don't you download the sources and compile the program? The output
from the program will not really be relevant anyway, if you don't have
an Ada compiler on the system.

Greetings,

Jacob
--
The so-called "desktop metaphor" of today's workstation
is instead an "airplane-seat" metaphor.

Fernando Arroyo

unread,
Jul 29, 2015, 10:59:32 AM7/29/15
to
I did't want to compile the sources since I have problems building it, I had to make some changes and I was afraid of modify the program behaviour.

Therefore, I have decided to use the previous version in the repository at http://sourceforge.net/projects/p2ada/files/p2ada/Sources/ (newp2ada-24-aug-2008.zip), and according the instructions (newp2ada.txt), I unzipped the zip (unzip -aaLL) and in the newp2ada folder I have done "gnatmake p2ada" and it is built and runs properly.

However, I would like to use the 2010 version (p2ada-aug-2010-src.tgz) but according the instructions (newp2ada/README), I unzipped the zip (unzip -aaLL) and in the newp2ada folder I have done "gnatmake p2ada" and gives problems:



gnatmake p2ada
gcc -c p2ada.adb
p2ada.adb:27:06: file "pascal_io.ads" not found
gnatmake: "p2ada.adb" compilation error


Therefore I decided follow the instructions of "How to make P2Ada translator work?"

First of all the instructions says about a file newp2ada.zip which I don't have. I assume that file is equvalent to the one that I downloaded p2ada-aug-2010-src.tgz (So here the first weird thing). I have decided to uncompress the tgz, compress again to .zip and decompress with "unzip -aaLL".
Then, I create the folder acu and modify the file p2ada_options.ads. According the instrucctions, we have replace one string DOS by Unix, but the instrucctions are not clear, I assume that is the second one (here the second weird thing):

type Line_endings is (Unix,DOS,Mac); -- LF,CR/LF,CR
new_line_endings: Line_endings:= DOS; -- <-----This one

Then next step is make and if I do it(here the third weird thing):
$ make
make: *** No rule to make target `aflex', needed by `pascal_dfa.adb'. Stop.

Since the readme says that "aflex and ayacc must have been made (see below) and copy or link them here" I follow the instructions "How to change P2Ada for yet another Pascal dialect ?":

1. building AYACC :
- go to directory ayacc
- run "gnatmake ayacc"

it looks ok:
$ gnatmake ayacc
gcc -c ayacc.adb
gcc -c ayacc_file_names.adb
gcc -c command_line_interface.adb
gcc -c error_report_file.adb
gcc -c options.adb
gcc -c output_file.adb
gcc -c parse_table.adb
gcc -c parser.adb
gcc -c rule_table.adb
gcc -c source_file.adb
gcc -c string_pkg.adb
gcc -c symbol_table.adb
gcc -c tokens_file.adb
gcc -c str_pack.adb
gcc -c string_scanner.adb
gcc -c string_lists.ads
gcc -c actions_file.adb
gcc -c parse_template_file.adb
gcc -c goto_file.adb
gcc -c lalr_symbol_info.adb
gcc -c lr0_machine.adb
gcc -c shift_reduce_file.adb
gcc -c symbol_info.adb
gcc -c verbose_file.adb
gcc -c lexical_analyzer.adb
gcc -c lists.adb
gcc -c stack_pkg.adb
gcc -c ragged.adb
gcc -c stack_pack.adb
gcc -c set_pack.adb
gnatbind -x ayacc.ali
gnatlink ayacc.ali

- move the executable in a reachable directory (see: path)




2. building AFLEX :
- go to directory aflex
- run "gnatmake aflex"
- move the executable in a reachable directory (see: path)

it looks ok:
$ gnatmake aflex
gcc -c aflex.adb
gcc -c dfa.adb
gcc -c gen.adb
gcc -c main_body.adb
gcc -c misc.adb
gcc -c misc_defs.adb
gcc -c template_manager.adb
gcc -c ccl.adb
gcc -c ecs.adb
gcc -c int_io.ads
gcc -c nfa.adb
gcc -c skeleton_manager.adb
gcc -c tblcmp.adb
gcc -c tstring.ads
gcc -c parse_tokens.ads
gcc -c scanner.adb
gcc -c command_line_interface.adb
gcc -c external_file_manager.adb
gcc -c parser.adb
gcc -c file_string.ads
gcc -c vstrings.adb
gcc -c ascan_dfa.adb
gcc -c ascan_io.adb
gcc -c sym.adb
gcc -c aflex_scanner.adb
gcc -c parse_goto.ads
gcc -c parse_shift_reduce.ads
gnatbind -x aflex.ali
gnatlink aflex.ali


Then I follow the instructions:

-go to directory lypascal
- type "ayacc pascal.y"

$ ayacc pascal.y

Ayacc (File => "pascal.y",
C_Lex => Off,
Debug => Off,
Summary => On,
Verbose => Off,
Error_Recovery => Off,
Extension => ".a");

637 Productions
420 Nonterminals
105 Terminals
866 States
76 Shift/Reduce conflicts
92 Reduce/Reduce conflicts


- type "aflex -i -E pascal.l" (No output)
- change the file extensions (.a) of new Ada files if needed (e.g. for GNAT) and move them to upper directory

ls:

pascal.a pascal_io.a pascal.l01 pascal.l06 pascal_shift_reduce.ads pascal.y00 pascal.y03 pascal.y07
pascal_dfa.a pascal.l pascal.l02 pascal.l97 pascal_tokens.ads pascal.y01 pascal.y05 pascal.y97
pascal_goto.ads pascal.l00 pascal.l03 pascal.l99 pascal.y pascal.y02 pascal.y06 pascal.y99


(I assume that I have to change pascal.a, pascal_io.a and pascal_dfa.a to .ads and move to the upper directory., here the forth weird thing)

- build P2Ada ("gnatmake p2ada").and then:

$ gnatmake p2ada
gcc -c p2ada.adb
pascal_io.ads:91:01: end of file expected, file can have only one compilation unit
gnatmake: "p2ada.adb" compilation error


I don't understand what happends, it looks that the steps of the README does not correspond to this version.

Any idea?

The status of my files are the following:
https://www.dropbox.com/s/9h25jpumt1pzayp/p2ada-aug-2010-src.zip?dl=0

Thanks

Niklas Holsti

unread,
Jul 29, 2015, 12:03:48 PM7/29/15
to
On 15-07-29 17:59 , Fernando Arroyo wrote:

> - build P2Ada ("gnatmake p2ada").and then:
>
> $ gnatmake p2ada
> gcc -c p2ada.adb
> pascal_io.ads:91:01: end of file expected, file can have only one compilation unit
> gnatmake: "p2ada.adb" compilation error
>
>
> I don't understand what happends, it looks that the steps of the README
> does not correspond to this version.
>
> Any idea?

Well, there seems to be something that GNAT does not like in the file
pascal_io.ads, at line 91.

That error message usually means that the source-code file needs to be
divided into separate files, one for each compilation unit (package
declaration, package body, ...) in the original file. Some other Ada
compilers accept source-code files that contain several compilation
units, but GNAT does not.

> The status of my files are the following:
> https://www.dropbox.com/s/9h25jpumt1pzayp/p2ada-aug-2010-src.zip?dl=0

I did not find any file named pascal_io.ads there. Do you have a file by
that name?

--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .

gautier...@hotmail.com

unread,
Jul 29, 2015, 4:00:42 PM7/29/15
to
Hello,
My recommendation: use the 2008 .zip version (no further improvement in the translator itself), or do a checkout of the current version:

svn checkout svn://svn.code.sf.net/p/p2ada/code/ p2ada

, then look at the /newp2ada/current/ directory.

NB: if your Pascal sources are a bit of the Borland / Turbo / Delphi dialect, (especially with conditional defines and switches that change the language behaviour after them) then the bp2p preprocessor might help as well. Then "gnatmake bp2p" will build that as well. Run bp2p for instructions.

Fernando Arroyo

unread,
Jul 31, 2015, 6:40:20 AM7/31/15
to
Ok in this case I will use the 2008 one.

I have another problem when I convert a file from .pas to .ada. The p2ada generates with/use clauses that I would like to remove. Is there any file that I can modify for add/remove them?

Thanks
0 new messages