dillon@uhccux.uhcc.hawaii.edu (Ian Dillon) (10/19/89)
I'm sure this has been asked many times but please bare with me. I'm looking for a Pascal to C (and back again) conversion program. If you have experience with one or both of these programs, please e-mail the account listed below, rather than cluttering up the Internet. Thanks in advance. Ian P.S. Should you know of a similar Fortran to C package as well, please let me know. * All I really need to know | Ian Dillon * * I learned in kindergarden | * * | BITNET: dillon@uhccux.bitnet * * > R. Fulgham < | I-NET: dillon@uhccux.UHCC.HAWAII.EDU *
acu@mentor.cc.purdue.edu (Floyd McWilliams) (10/24/89)
In article <5164@uhccux.uhcc.hawaii.edu> dillon@uhccux.uhcc.hawaii.edu (Ian Dillon) writes: >I'm sure this has been asked many times but please bare with me. What is this, comp.lang.c.nudists? (I know, I know, spelling flames are verboten -- just couldn't resist. :-)) >I'm looking for a Pascal to C (and back again) conversion program. If >you have experience with one or both of these programs, please e-mail >the account listed below, rather than cluttering up the Internet. I'd like to see how a C-to-Pascal conversion program would handle this: int i, *pi; pi = &i; Or this: int *A; A = (int *) malloc((unsigned) (sizeof(int) * 20)); A[10] = 5; Or, for that matter, how a Pascal-to-C converter would take: var X : set of char; X := ['a','b','c']; if 'a' in X then X := X + 'A' else X := X * ['b','c']; Now I know all these conversions CAN be done (since C and Pascal are Turing-equivalent). But can they be done by currently available programs? Do C-to-Pascal and Pascal-to-C converters exist? Do they work only on small, non-offensive subsets of either language? >P.S. Should you know of a similar Fortran to C package as well, please > let me know. Fortran-to-C does exist, although I don't know any details. -- "You have angered the great Chac-mool. You will burn in the fiery pits of eternal damnation. That is all." Floyd McWilliams mentor.cc.purdue.edu!acu
chris@mimsy.umd.edu (Chris Torek) (10/24/89)
In article <4640@mentor.cc.purdue.edu> acu@mentor.cc.purdue.edu (Floyd McWilliams) writes: [various C constructs that cannot be expressed efficiently in Pascal] > Or, for that matter, how a Pascal-to-C converter would take: > var > X : set of char; > X := ['a','b','c']; > if 'a' in X then > X := X + 'A' > else > X := X * ['b','c']; It is worth noting that the above is not standard Pascal (unless, as is not too terribly unlikely, I have missed something that happened recently in Pascal standards). Pascal sets are limited to some small number of possible members. Some (many/most/almost-all) implementations allow larger sets (such as `set of char'), but the standard requires only a small number of elements per set. It does not say exactly what that number might be, only that it is `small' and has to do with the machine's word size. The limit might be, e.g., 36 (as it was in various 36-bit machine Pascals). `set of char' usually requires at least 64. Anyway, a Pascal-to-C converter could treat this as twofiftysixbitinteger X; X = bit('a') | bit('b') | bit('c'); if (X & bit('a')) X |= bit('A'); else X &= bit('b') | bit('c'); if you had 256-bit integers. As it is, this sort of thing normally requires bit-manipulation macros: SET(X, 256); /* char X[(256+7)/8] */ ZAPSET(X, 256), /* memset to 0, 256 bits */ BIS(X, 'a'), BIS(X, 'b'), BIS(X, 'c'); if (BIT(X, 'a')) BIS(X, 'A'); else SETINTERSECT(X, 256, 'b'), SETINTERSECT(X, 256, 'c'); which (as you can see) is not very nice. -- `They were supposed to be green.' In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris
unkydave@shumv1.uucp (David Bank) (10/24/89)
I am part of a team writing a largish program for a local contractor. We are using Microsoft C for our final compilations and Quick C 2.0 for most of our development. No flames, please, on our choice of compilers -- it wasn't entirely our decision. The version of Microsoft C is, by the way, 5.1. Anyway, our program compiles and runs fine under Microsoft C. But if we take the same exact code and put it into Quick C, we have problems. It compiles fine (admittedly, in C that doesn't count for much) and links OK. But when we run it we get a "far pointer" error and the program crashes with error code R6000 I think. Could be R2000. Would someone please do me two favors? 1) Pardon my ignorance and explain "near" and "far" pointers, memory allocations, and heaps (as appropriate). 2) Tell me how we can get around this (if possible). Thank you very much in advance. Unky Dave unkydave@shumv1.ncsu.edu P.S. Oh, yeah, two things. We're on IBM-clones and we are using the large (read: fat) memory models.
gateley@m2.csc.ti.com (John Gateley) (10/24/89)
In article <4640@mentor.cc.purdue.edu> acu@mentor.cc.purdue.edu (Floyd McWilliams) writes: >In article <5164@uhccux.uhcc.hawaii.edu> dillon@uhccux.uhcc.hawaii.edu > (Ian Dillon) writes: >>I'm looking for a Pascal to C (and back again) conversion program. > I'd like to see how a C-to-Pascal conversion program would handle this: > int i, *pi; > pi = &i; Basically, what you do is declare a huge array of integers; this represents `memory'. Now, an address is an index into the array. Whats that? You wanted it efficient too? :^) > Or this: > int *A; > A = (int *) malloc((unsigned) (sizeof(int) * 20)); > A[10] = 5; Same process, except you have to write malloc in pascal. > Or, for that matter, how a Pascal-to-C converter would take: > var > X : set of char; > X := ['a','b','c']; > if 'a' in X then > X := X + 'A' > else > X := X * ['b','c']; This one can be done easily. A set can be represented as a bit vector (also known as an integer), of appropriate lenght. So you get int x[16] /* you need 256 bits */ for(i=0;i<16;i++) x[i]=0; /* 'a' is 97 */ x[6]:=x[6] && 1 /* or &, I dunno, I dont speak C */ and so on, you get the idea. > Now I know all these conversions CAN be done (since C and Pascal >are Turing-equivalent). But can they be done by currently available >programs? Sure, you can write a program to do it. The question really is "can they be done so the output is useful". In the first case (addresses), Pascal doesn't have a mechanism for dealing with them easily, you might be able to fake them with pointers, or go with the approach I suggested above. In any case, there is an overhead associated with them. In the second case (Pascal Sets in C), the output is likely to be highly unreadable. I took a lot of shortcuts above, the code which would be generated automatically would be grosser. John gateley@m2.csc.ti.com
chris@mimsy.umd.edu (Chris Torek) (10/24/89)
In article <20355@mimsy.umd.edu> I wrote: [regarding >> X := X * ['b','c']; where `X' is a `set of char'] > SETINTERSECT(X, 256, 'b'), SETINTERSECT(X, 256, 'c'); >which (as you can see) is not very nice. Oops. It is also not very right. Set intersection done the hard way requires a temporary set. Since this is a constant intersection, a Pascal-to-C translator could rewrite it as X[0] = X[1] = X[2] = X[3] = X[4] = X[5] = X[6] = X[7] = X[8] = X[9] = X[10] = X[11] = X[13] = X[14] = X[15] = 0, X[12] &= (2|4); (assuming ASCII characters). More likely, it would create a local variable containing another 256-bit set, clear it all, set bits for 'b' and 'c', and then call a set-intersection macro. -- `They were supposed to be green.' In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris
diamond@csl.sony.co.jp (Norman Diamond) (10/25/89)
In article <20355@mimsy.umd.edu> chris@mimsy.umd.edu (Chris Torek) writes: >It is worth noting that [a program using SET OF CHAR] is not standard >Pascal (unless, as >is not too terribly unlikely, I have missed something that happened >recently in Pascal standards). Pascal sets are limited to some small >number of possible members. Some (many/most/almost-all) implementations >allow larger sets (such as `set of char'), but the standard requires >only a small number of elements per set. Just like any C program that contains more than one function-like macro is not standard C, eh? Yes, there can be compilers which meet the letter but not the spirit of the standard, and usually such compilers fail in the market-place. All languages are alike in this respect. Incidentally, the Extended Pascal standard also does not require support for SET OF CHAR. If the character set is ASCII or an ISO set of up to 256 characters, then everyone expects that compilers will accept SET OF CHAR and everyone uses it. However, if the character set is multibyte, then SET OF CHAR might be a bit demanding. So the standard did not require it. The market-place still demands sensibility, just as in C. -- Norman Diamond, Sony Corp. (diamond%ws.sony.junet@uunet.uu.net seems to work) Should the preceding opinions be caught or | James Bond asked his killed, the sender will disavow all knowledge | ATT rep for a source of their activities or whereabouts. | licence to "kill".
peter@ficc.uu.net (Peter da Silva) (10/26/89)
In article <10999@riks.csl.sony.co.jp> diamond@riks. (Norman Diamond) writes: > In article <20355@mimsy.umd.edu> chris@mimsy.umd.edu (Chris Torek) writes: > >It is worth noting that [a program using SET OF CHAR] is not standard > >Pascal... > Just like any C program that contains more than one function-like macro > is not standard C, eh? [i.e., it's a quality-of-implementation consideration ] This is a different order of magnitude than only allowing one function-like macro. A Pascal that does not allow !set of char! is atill quite usable. For what it's worth, I've never seen !set of char! used in a Pascal program, out of the old Berkeley pi/px compiler, UCSD, a couple of micro cross- compilers, and Turbo (which is to Pascal as Ratfor is to Fortran-77). I know that at least one of the micro systems didn't allow it (probably both, they were from the same vendor), and neither did UCSD. -- Peter da Silva, *NIX support guy @ Ferranti International Controls Corporation. Biz: peter@ficc.uu.net, +1 713 274 5180. Fun: peter@sugar.hackercorp.com. `-_-' "That particular mistake will not be repeated. There are plenty of 'U` mistakes left that have not yet been used." -- Andy Tanenbaum (ast@cs.vu.nl)
malloy@nprdc.arpa (Sean Malloy) (10/26/89)
In article <6684@ficc.uu.net> peter@ficc.uu.net (Peter da Silva) writes: >For what it's worth, I've never seen !set of char! used in a Pascal program, >out of the old Berkeley pi/px compiler, UCSD, a couple of micro cross- >compilers, and Turbo (which is to Pascal as Ratfor is to Fortran-77). I >know that at least one of the micro systems didn't allow it (probably both, >they were from the same vendor), and neither did UCSD. Here's the INTERFACE section of the MENUS unit written in UCSD Pascal that we used all through the software we developed for the Semantic Network Training System (a collection of programs running on TERAK micros that would drill users on a database of information to be memorized). Note the use of 'SET OF Char' in the definition of the MenuVarRec type. If we'd known that UCSD Pascal didn't allow 'SET OF Char', we probably would have written it some other way. Funny that our UCSD Pascal compiler didn't seem to complain about it, though. -------------------------------------------------------------------------------- {===============================================} { Unit: Menus } { Author: Steve Putz } { Filename: MENUS;L.TEXT } { Created: 13-Feb-80 } { Last Update: 13-Jul-82 [SRM] } { Description: see MENUS.DOC.TEXT } { Cleaned appearance; use new MENUS.CHARSET } {===============================================} {$S+} UNIT Menus; INTERFACE { Menus unit 17-Sep-81 [MoveChars Version] } CONST MenuLines = 100; { maximum number of items in a ListMenu } TYPE MenuStr = ^String; MenuRecord = RECORD X, Y : Integer; { char screen position of top corner } width, height: Integer; { width and height of menu frame } topLine : Integer; { index of first displayed item } curItem : Integer; { current item } len : Integer; { number of items } title : String; { displayed above menu } list : ARRAY[1..MenuLines] OF MenuStr; END; MenuVarRec = RECORD { these chars mean the following in MenuUserSel-- } SelChars, { "(de)select this item" [SELECT] } EscChars { "leave MenuUserSel" SelChars + [ESC] } : SET OF Char; { (values may be changed by user) } END; VAR MenuVars : ^MenuVarRec; PROCEDURE MenuInit; { Initializes the above sets to the default values shown in brackets. } PROCEDURE MenuNew(VAR menu: MenuRecord; atX,atY,wid,ht: Integer; titleStr: String); { Initializes the menu at the given character position coordinates and clears the menu. } PROCEDURE MenuClear(VAR menu: MenuRecord); { sets length to zero. Does not display } PROCEDURE MenuDisplay(VAR menu: MenuRecord); { Displays menu and title. } PROCEDURE MenuInsert(VAR menu: MenuRecord; text: String; before: Integer); { Inserts a line of text into the menu. } PROCEDURE MenuDelete(VAR menu: MenuRecord; item: Integer); { Deletes a line from the menu. } PROCEDURE MenuContents(VAR menu: MenuRecord; VAR text: String; item: Integer); { Returns the text contents of the given line. } FUNCTION MenuSelected(VAR menu: MenuRecord; item: Integer) : Boolean; { Returns True if the item is selected. } PROCEDURE MenuReset(VAR menu: MenuRecord); { Deselects all selections without redisplaying. } PROCEDURE MenuComp(VAR menu: MenuRecord; item: Integer); { Complements the item, and redisplays that line only, if visible. } PROCEDURE MenuTopLine(VAR menu: MenuRecord; newTop: Integer); { Scrolls the items in the list so item newTop is at the top. } PROCEDURE MenuScroll(VAR menu: MenuRecord; delta: Integer); { Scrolls the menu by delta lines. Both MenuTopLine and MenuScroll cause the menu to be redisplayed. } FUNCTION MenuUserSel(VAR menu: MenuRecord) : Char; { Allows the user to scroll the menu and select (complement) item(s). The last on which the cursor was positioned is in menu.curItem. The function returns the character which caused termination, mapped to lower case unless EscChars contains upper case. } -------------------------------------------------------------------------------- Sean Malloy | "I am here by the will of Navy Personnel Research & Development Center | the people and will not San Diego, CA 92152-6800 | leave until I get my malloy@nprdc.navy.mil | raincoat back"
peter@ficc.uu.net (Peter da Silva) (10/27/89)
Looks like I was wrong about UCSD and !set of char!. I'm sure the UCSD Pascal I used on the Apple didn't do it, but that doesn't make sense... it's all the same UCSD P-machine binary, right? Anyway, I'm *sure* I'm sure pi/px didn't allow it (aim gun at foot). -- `-_-' Peter da Silva <peter@ficc.uu.net> <peter@sugar.hackercorp.com>. 'U` -------------- +1 713 274 5180. "That particular mistake will not be repeated. There are plenty of mistakes left that have not yet been used." -- Andy Tanenbaum (ast@cs.vu.nl)
diamond@csl.sony.co.jp (Norman Diamond) (10/27/89)
In article <6684@ficc.uu.net> peter@ficc.uu.net (Peter da Silva) writes: >it's a quality-of-implementation consideration >This is a different order of magnitude than only allowing one function-like >macro. A Pascal that does not allow !set of char! is atill quite usable. >For what it's worth, I've never seen !set of char! used in a Pascal program, >out of the old Berkeley pi/px compiler, UCSD, a couple of micro cross- >compilers, and Turbo (which is to Pascal as Ratfor is to Fortran-77). I >know that at least one of the micro systems didn't allow it (probably both, >they were from the same vendor), and neither did UCSD. The days when micro Pascal compilers didn't support SET OF CHAR were before the days when micro C compilers didn't support float. Sure, a C compiler that didn't support float was still quite usable. However, as a quality of implementation issue, any compiler that does not support SET OF CHAR has as few sales as any compiler that does not support two function-like macros, and their respective standards committees are not going to come to the defense of either of them. -- Norman Diamond, Sony Corp. (diamond%ws.sony.junet@uunet.uu.net seems to work) Should the preceding opinions be caught or | James Bond asked his killed, the sender will disavow all knowledge | ATT rep for a source of their activities or whereabouts. | licence to "kill".
cnn@calmasd.Prime.COM (Can Nguyen) (07/21/90)
I'm looking for information on how to access to comp.sources.unix archives. Specifically, I'm trying to obtain the Pascal to C converter posted to comp.sources.unix in March,90 (Archive volume 21). I would appreciate if some netters can email me on info how to retrieve this program from comp.sources.unix archive or the source itself. Thanks C Nguyen cnn@calmasd.Prime.Com