bbl@amdcad.UUCP (BBL Software) (12/14/84)
I am trying to study the feasibility of writing a 'C' to Pascal translator and viceversa using YACC and LEX. I would like to know if someone has tried such an exercise. I would appreciate comments on feasibility, issues involved and usefulness. If I receive enough interesting responses, I will summarise it on the net. rajiv c. mody ..!amd!amdcad!bbl
chris@umcp-cs.UUCP (Chris Torek) (12/16/84)
In general, it cannot be done. What would you do with union u { int (*f)(); char *c; } u; h() { u.c = "foo"; } g() { u.f = h; /* Remember, I'm actually allowed to make this assignment as complicated as I want. Maybe it depends on input data.... */ } main () { g(); (*u.f)(); printf("%s\n", u.c); } If you make some restrictions, then it can sort of be done. -- (This line accidently left nonblank.) In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (301) 454-7690 UUCP: {seismo,allegra,brl-bmd}!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland
robert@gitpyr.UUCP (Robert Viduya) (12/18/84)
> > union u { > int (*f)(); > char *c; > } u; > h() { > u.c = "foo"; > } > g() { > u.f = h; > } > main () { > g(); > (*u.f)(); > printf("%s\n", u.c); > } > > If you make some restrictions, then it can sort of be done. Actually, the restriction is not in the unions. Pascal can handle the concept of unions by using variant records with no tag field specifier. The restriction of translating C to Pascal is that Pascal does not support pointers to functions. robert -- Robert Viduya Office of Computing Services Georgia Institute of Technology, Atlanta GA 30332 Phone: (404) 894-4669 ...!{akgua,allegra,amd,hplabs,ihnp4,masscomp,ut-ngp}!gatech!gitpyr!robert ...!{rlgvax,sb1,uf-cgrl,unmvax,ut-sally}!gatech!gitpyr!robert
steve@hcradm.UUCP (Steve Pozgaj) (12/20/84)
Why bother trying to write one? There are already several available. Most notably [I wonder why I would say that?], HCR has a Pascal compiler which front ends on the machine's C compiler. It translates Pascal source to C; it fully passes the Tasmanian Test Suite; and, it is cheaper than doing it yourself. To each his own, I suppose. Steve Pozgaj, Human Computing Resources Toronto
steve@hcradm.UUCP (Steve Pozgaj) (12/20/84)
Ooops! Sorry about that brain-damaged response regarding HCR's Pascal-to-C translator. I was mesmerized by the falling snow (honest!) and read the whole thing in the wrong direction! I promise to eat three fewer Christmas puddings as punishment. Steve Pozgaj, Human Computing Resources, Toronto