* Improving P2Ada
@ 1999-08-19 0:00 Gautier
1999-08-19 0:00 ` Gautier
1999-08-26 0:00 ` Improving P2Ada (2) Gautier
0 siblings, 2 replies; 5+ messages in thread
From: Gautier @ 1999-08-19 0:00 UTC (permalink / raw)
Hi everybody. I'm about to improve
the P2Ada tool in order to translate Pascal
sources from the Borland constellation.
That should be feasible...
The point is that the yacc/aflex compiler
(a gnat/win32 version found on the net)
produces a code that hangs or does nothing
- it seems at initialisation.
The grammar is inchanged from M. Carlisle's
sources (v 2.2).
If anyone knows about the "dangerous curves" of
yacc/aflex, let me know...
--
Gautier
--------
http://members.xoom.com/gdemont/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Improving P2Ada
1999-08-19 0:00 Improving P2Ada Gautier
@ 1999-08-19 0:00 ` Gautier
1999-08-26 0:00 ` Improving P2Ada (2) Gautier
1 sibling, 0 replies; 5+ messages in thread
From: Gautier @ 1999-08-19 0:00 UTC (permalink / raw)
Thanks for replies...
The P2Ada way doesn't seem the only one.
Though, here is what I would/will add to current P2Ada (2.2) to
let it translate happily Borland-style sources:
* no forced order in CONST, TYPE, VAR, PROCEDURE/FUNCTION clauses
(like Ada 95) - most TP programs aren't "Pascal orthodox" on this
point (fortunately), so P2Ada fails there...
* CASE statements can have an ELSE part ( when others=> in Ada )
* there are ASM..END blocks like BEGIN..END (just comment out the
assembler opcodes...)
* there are SHL & SHR binary operators ( shift_left(.,.) in Ada )
* strings can have explicit ASCII characters: 'Blabla'#13#10're-blabla'
that would become "Blabla" & character'val(13) & ...
A later but more "banana-skinny" step is the OO part; to begin with...
TYPE xyz = OBJECT -> type xyz is tagged record
TYPE xyz = OBJECT(abc) -> type xyz is new abc with record
PROCEDURE xyz.toto; -> procedure toto(prefixed_obj: xyz) is
G.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Improving P2Ada (2)
1999-08-19 0:00 Improving P2Ada Gautier
1999-08-19 0:00 ` Gautier
@ 1999-08-26 0:00 ` Gautier
[not found] ` <7q5cih$msg$1@scharff.fys.ku.dk>
1 sibling, 1 reply; 5+ messages in thread
From: Gautier @ 1999-08-26 0:00 UTC (permalink / raw)
Hi. Here is a new (very provisory) version that
allows translation of many (not all) Turbo/Borland
Pascal sources (no OO yet but it will come...).
ftp://ftp.unine.ch/incoming/gautier/newp2ada.zip
The archive contains all you need to (re-)build P2Ada
and customize further...
Gautier
---
Enhancement list from 1997 version
==================================
26.VIII.1999 [GdM]
a) Borland-ish add-ons:
- Str translated ( bug: should be put(s,123) instead of put(123,s) )
- ' character, written '' ( bug: should trash the 2nd ' )
- arbitrary order of declaration kinds, instead of label-const-type-var-proc
- typeless var parameters
- DIV becomes /
- SHL & SHR operators ( bug: translated by "a Shift_left( ; ) b" )
- programs not beginning by 'Program' !
- global initialized VARiables - in the CONSTant parts - ; aggregates
- strings with contraints
- typeless files
- else part in case..of
- asm...end blocks ( bug: not complete)
- special directives in proc/func decl. (like near/far/assembler)
- characters with explicit ascii (#223)
- borland string constants ('aaa'#123'bbb')
b) Improvements or bugfixes (any Pascal)
- begin/end simplified when safe (then/else/do/case)
- outputs "Null;" for empty statement
- outputs "WHEN others=> Null;" when no else part
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Improving P2Ada (2)
[not found] ` <7q5cih$msg$1@scharff.fys.ku.dk>
@ 1999-08-27 0:00 ` Gautier
[not found] ` <7q5vuc$u3i$1@scharff.fys.ku.dk>
0 siblings, 1 reply; 5+ messages in thread
From: Gautier @ 1999-08-27 0:00 UTC (permalink / raw)
> >- outputs "WHEN others=> Null;" when no else part
> I know this is the correct translation, but would it be
> possible to have a flag that disables this feature?
It is - by enclosing the Text_IO.Put(...) in pascal.y
with an if flag then...end if;
But is it not complicating uselessly the tool ?
My arguments are:
- it's easier to remove a "WHEN others=> Null;" than
to add it
- the cases when "WHEN others=> Null;" is needed are
much more frequent than when it isn't
--
Gautier
--------
http://members.xoom.com/gdemont/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Improving P2Ada (2)
[not found] ` <7q5vuc$u3i$1@scharff.fys.ku.dk>
@ 1999-08-27 0:00 ` Gautier
0 siblings, 0 replies; 5+ messages in thread
From: Gautier @ 1999-08-27 0:00 UTC (permalink / raw)
> It appears that I have managed to argue that the flag isn't
> necessary after all. ;-(
Nice he he he. Hum, I prefer to wait a while to see
others' opinions.
Provisorily for your tests you could replace at line 1016 of pascal.y
| {pascalhelp.put_line("WHEN OTHERS=> Null; ");} -- EMPTY
with:
| -- EMPTY
BTW the "null;" for empty statements is not avoided for the case
of an empty statement appearing in a sequence, like
if abc then begin
x;
y; { empty statement after y ! }
end;
(NB: the ';' is a separator in Pascal) so there will
be protests, too... A way reprogram that can be the rules
- a single statement is either empty (crac: issue "null;") or not;
- a statement-in-sequence is either empty (don't issue "null;" !) or not;
- a sequence is either empty (crac: issue "null;") or not;
... with the risk to confuse ayacc a bit more.
--
Gautier
--------
http://members.xoom.com/gdemont/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1999-08-27 0:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-19 0:00 Improving P2Ada Gautier
1999-08-19 0:00 ` Gautier
1999-08-26 0:00 ` Improving P2Ada (2) Gautier
[not found] ` <7q5cih$msg$1@scharff.fys.ku.dk>
1999-08-27 0:00 ` Gautier
[not found] ` <7q5vuc$u3i$1@scharff.fys.ku.dk>
1999-08-27 0:00 ` Gautier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox