⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 notes

📁 把pascal程序转成C语言程序 把pascal程序转成C语言程序
💻
📖 第 1 页 / 共 3 页
字号:
THE GRAND P2C NOTES FILE:This file contains notes to myself recording bugs, flaws, and suggestedimprovements to p2c.  They have roughly been separated into "old", "older",and "oldest" groups.  I can't guarantee I'll do any of these.  If you do,please mail me the diffs so I can incorporate them into the next release.Thanks!						-- Dave Gillespie						   daveg@synaptics.com-----------------------------------------------------------------------------   Handling of comments that trail the ELSE clause of an IF statement   could use some work.-----------------------------------------------------------------------------   Technically speaking, "for byte := min to max do" is legal even   if min > 255, i.e., the limits only need to be in range if the   body of the loop executes.  Thus, FOR loops should really use a   shadow parameter not just when max is the constant 255, but   whenever min or max are not provably in byte range.-----------------------------------------------------------------------------   Have a "-M"-like mode in which FREE is suppressed altogether, useful   in case p2c crashes because bugs have corrupted malloc's free list.-----------------------------------------------------------------------------   For expressions building small-sets whose maximum element is <= 15,   use "1 << x" instead of "1L << x".-----------------------------------------------------------------------------   Handle VAX Pascal VARYING OF CHARs used as the arguments of WITH   statements.-----------------------------------------------------------------------------   StringTruncLimit would be helped by expr.c:strmax() interpreting   sprintf control strings.  For %s, use strmax of the corresponding   argument.  For %d, use 11, etc.  For %.10s, use min(10, strmax(arg)).   For %.*s, just use strmax(arg), I guess.   Have a mode in which such assignments are automatically truncated.   Perform truncation testing for non-VAR procedure arguments, too.-----------------------------------------------------------------------------   In cref.p, the "strappend(buf,#0)" statement translates into   "strcpy(STR1,buf); strcpy(buf,STR1)" with a warning about a null   character in a sprintf control string!-----------------------------------------------------------------------------   Still having problems where the opening comment of an imported   module's interface text is copied into the program.-----------------------------------------------------------------------------   VAX Pascal features not yet handled:      [UNSAFE] attribute is only implemented in a few situations.      [UNBOUND] attribute on a procedure says it doesn't need a static link.      [TRUNCATE] attribute on a parameter allows optional params w/no default.      [LIST] attribute on a parameter is like &rest in Lisp.      Support types like, e.g., [LONG] BOOLEAN.      Can assign "structurally compatible" but different record types.      File intrinsics need serious work, especially OPEN.      If a copy param is [READONLY], don't need to copy it.      If a procedure is [ASYNCHRONOUS], make all its variables volatile.      If a procedure is [NOOPTIMIZE], make all its variables volatile.      Provide a real implementation of BIN function and :BIN read format.      BIT_OFFSET and CARD intrinsics are not supported.-----------------------------------------------------------------------------   Modula-2 features not yet handled:      Local modules are faked up in a pretty superficial way.      WORD is compatible with both pointers and CARDINALs.      WORD parameters are compatible with any word-sized object.      ARRAY OF WORD parameters are compatible with absolutely anything.      Improve treatment of character strings.      Find manuals for real implementations of Modula-2 and implement         any common language extensions.      Fix p2c to read system.m2 instead of system.imp automatically.-----------------------------------------------------------------------------   Oregon Software Pascal features not yet handled:	procedure noioerror(var f:file);		Built-in.  Sets a flag on an already-open file so that		I/O errors record an error code rather than crashing.		Each file has its own error code.	function ioerror(var f:file) : boolean;		True if an error has occurred in the file.	function iostatus(var f:file) : integer;		The error code, when ioerror was true.	reset and rewrite ignore the third parameter, and allow a fourth	param which is an integer variable that receives a status code.	Without this param, open errors are fatal.  An optional param	may be omitted as in reset(f,'foo',,v);-----------------------------------------------------------------------------   In p_search, if a file contains const/var/type/procedure/function   declarations without any module declaration, surround the entire   file with an implicit "module <generated-name>; {PERMANENT}" ... "end.".   This would help the Oregon Software dialect considerably.-----------------------------------------------------------------------------   Provide an explicit IncludeFrom syntax for "no include file".   E.g., "IncludeFrom dos 0".-----------------------------------------------------------------------------   In docast, smallsets are converted to large sets of the requested type.   Wouldn't it be better to convert to a set of 0..31 of the base type?   This would keep foo([]), where the argument is "set of char", from   allocating a full 256-bit array for the temporary.-----------------------------------------------------------------------------   When initializing a constant variant record or array of same in which   non-first variants are initialized, create a function to do the   initialization, plus, for modules w/o initializers, a note to call   this function.  Another possibility:  Initialize the array as well as   possible, but leave zeros in the variant parts.  Then the function   has only to fix up the non-first variant fields.-----------------------------------------------------------------------------   Figure out some way to initialize packed array constants, e.g., a short   macro PACK4(x,y)=(((x)<<4)+(y)) which is used inside the C initializer.   Alternatively, implement initializer functions as above and use those.-----------------------------------------------------------------------------   How about declaring Volatile any variables local to a function which   are used after the first RECOVER?  GNU also suggests writing the   statement:  "&foo;" which will have no side effect except to make   foo essentially volatile, without relying on ANSI features.-----------------------------------------------------------------------------   Test the macros for GET, PUT, etc.-----------------------------------------------------------------------------   Can the #if 0'd code for strinsert in funcs.c be changed to test   strcpyleft?-----------------------------------------------------------------------------   Even in Ansi mode, p2c seems to be casting Anyptrs into other pointer   types explicitly.  This is an automatic conversion in Ansi C.-----------------------------------------------------------------------------   A Turbo typed constant or VAX initialized variable with a VarMacro   loses its initializer!-----------------------------------------------------------------------------   Test the ability of the parser to recover from common problems such   as too many/few arguments to a procedure, missing/extra semicolon, etc.   One major problem has been with undeclared identifiers being used as   type names.-----------------------------------------------------------------------------   Line breaker still needs considerable tuning!-----------------------------------------------------------------------------   How about indenting trailing comments analogously to the code:   Try to indent to column C+(X-Y), where C=original column number,   X=output indentation, Y=original input indentation.   Even fancier would be to study all the comment indentations in the   function or struct decl to discover if most comments are at the same   absolute indentation; if so, compute the average or minimum amount of   space preceding the comments and indent the C comments to an analogous   position.-----------------------------------------------------------------------------   Warn if address is taken of an arithmetic expression like "v1+1".   Allow user to declare certain bicalls as l-values, e.g., so that   LSC's topLeft and botRight macros won't generate complaints.-----------------------------------------------------------------------------   Consider changing the "language" modes into a set of p2crc files   which can be included to support the various modes.-----------------------------------------------------------------------------   If we exchange the THEN and ELSE parts of an IF statement, be sure   to exchange their comments as well!-----------------------------------------------------------------------------   How about checking for a ".p2crc" file in the user's home directory.-----------------------------------------------------------------------------   Store comments in the following situations:      On the first line of a record decl.      On the default clause of a CASE statement        (use same trick as for ELSE clauses).      On the "end" of a CASE statement.      On null statements.      Use stealcomments for, e.g., decl_comments and others.-----------------------------------------------------------------------------   Think of other formatting options for format_gen to support.-----------------------------------------------------------------------------   Consider converting gratuitous BEGIN/END pairs into gratuitous   { } pairs.-----------------------------------------------------------------------------   The construction "s := copy(s, 1, 3)" converts to a big mess that   could be simplified to "s[3] = 0".-----------------------------------------------------------------------------   Have a mode (and make it the default!) in which declarations are mixed   if and only if the original Pascal decls were mixed.  Simply store   a flag in each meaning to mark "mixed-with-preceding-meaning".

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -