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

📄 trans.h

📁 把pascal程序转成C语言程序 把pascal程序转成C语言程序
💻 H
📖 第 1 页 / 共 5 页
字号:
/* "p2c", a Pascal to C translator, version 1.21alpha-07.Dec.93.   Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation.   Author: Dave Gillespie.   Author's address: daveg@synaptics.com.This program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation (any version).This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; see the file COPYING.  If not, write tothe Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */#ifdef __STDC__# define PP(x)  x             /* use true prototypes */# define PV()   (void)# define Anyptr void# define __CAT__(a,b)a##b#else# define PP(x)  ()            /* use old-style declarations */# define PV()   ()# define Anyptr char# define __ID__(a)a# define __CAT__(a,b)__ID__(a)b#endif#define Static                /* For debugging purposes */#include <stdio.h>/* If the following heuristic fails, compile -DBSD=0 for non-BSD systems,   or -DBSD=1 for BSD systems. */#ifdef M_XENIX# define BSD 0#endif#ifdef FILE       /* a #define in BSD, a typedef in SYSV (hp-ux, at least) */# ifndef BSD#  define BSD 1# endif#endif#ifdef BSD# if !BSD#  undef BSD# endif#endif#if defined(__STDC__) && !defined(M_XENIX)# include <stdlib.h># include <stddef.h># include <limits.h>#else# ifndef BSD#  include <malloc.h>#  include <memory.h>#  include <values.h># endif#endif#if defined(BSD) && !defined(__STDC__)# include <strings.h># define memcpy(a,b,n) bcopy(b,a,n)# define memcmp(a,b,n) bcmp(a,b,n)char *malloc(), *realloc();#else# include <string.h>#endif#include <ctype.h>#ifdef __GNUC__      /* Fast, in-line version of strcmp */# define strcmp(a,b) ({ char *_aa = (a), *_bb = (b); int _diff;  \			for (;;) {    \			    if (!*_aa && !*_bb) { _diff = 0; break; }   \                            if (*_aa++ != *_bb++)    \				{ _diff = _aa[-1] - _bb[-1]; break; }   \			} _diff; })#endif#if defined(HASDUMPS) && defined(define_globals)# define DEFDUMPS#endif/* Constants */#ifndef CHAR_BIT# define CHAR_BIT 8#endif#ifndef LONG_MAX# define LONG_MAX (((unsigned long)~0L) >> 1)#endif#ifndef LONG_MIN# define LONG_MIN (- LONG_MAX - 1)#endif#undef MININT      /* we want the Pascal definitions, not the local C definitions */#undef MAXINT#define MININT     0x80000000#define MAXINT     0x7fffffff#ifndef EXIT_SUCCESS# define EXIT_SUCCESS  0# define EXIT_FAILURE  1#endif#ifndef P2C_HOME# ifdef citPWS#  define    P2C_HOME        "/lib/p2c"# else#  define    P2C_HOME        "/usr/local/p2c"     /* sounds reasonable... */# endif#endif#ifdef define_globalschar *p2c_home = P2C_HOME;#elseextern char *p2c_home;#endif#define P2C_VERSION  "1.21alpha-07.Dec.93"/* Types */#ifdef __STDC__typedef void *anyptr;#elsetypedef char *anyptr;#endiftypedef unsigned char uchar;/* Ought to rearrange token assignments at the next full re-compile */typedef enum E_token {    TOK_NONE,    /* reserved words */    TOK_AND, TOK_ARRAY, TOK_BEGIN, TOK_CASE, TOK_CONST,    TOK_DIV, TOK_DO, TOK_DOWNTO, TOK_ELSE, TOK_END,    TOK_FILE, TOK_FOR, TOK_FUNCTION, TOK_GOTO, TOK_IF,    TOK_IN, TOK_LABEL, TOK_MOD, TOK_NIL, TOK_NOT,    TOK_OF, TOK_OR, TOK_PACKED, TOK_PROCEDURE, TOK_PROGRAM,    TOK_RECORD, TOK_REPEAT, TOK_SET, TOK_THEN, TOK_TO,    TOK_TYPE, TOK_UNTIL, TOK_VAR, TOK_WHILE, TOK_WITH,    /* symbols */    TOK_DOLLAR, TOK_STRLIT, TOK_LPAR, TOK_RPAR, TOK_STAR,    TOK_PLUS, TOK_COMMA, TOK_MINUS, TOK_DOT, TOK_DOTS,    TOK_SLASH, TOK_INTLIT, TOK_REALLIT, TOK_COLON, TOK_ASSIGN,    TOK_SEMI, TOK_NE, TOK_LT, TOK_GT, TOK_LE, TOK_GE,    TOK_EQ, TOK_LBR, TOK_RBR, TOK_HAT,    TOK_INCLUDE, TOK_ENDIF,    TOK_IDENT, TOK_MININT, TOK_EOF,    /* C symbols */    TOK_ARROW, TOK_AMP, TOK_VBAR, TOK_BANG,    TOK_TWIDDLE, TOK_PERC, TOK_QM,    TOK_LTLT, TOK_GTGT, TOK_EQEQ, TOK_BANGEQ,    TOK_PLPL, TOK_MIMI, TOK_ANDAND, TOK_OROR,    TOK_LBRACE, TOK_RBRACE, TOK_CHARLIT,    /* HP Pascal tokens */    TOK_ANYVAR, TOK_EXPORT, TOK_IMPLEMENT, TOK_IMPORT, TOK_MODULE,    TOK_OTHERWISE, TOK_RECOVER, TOK_TRY,    /* Turbo Pascal tokens */    TOK_SHL, TOK_SHR, TOK_XOR, TOK_INLINE, TOK_ABSOLUTE,    TOK_INTERRUPT, TOK_ADDR, TOK_HEXLIT, TOK_OBJECT,    TOK_CONSTRUCTOR, TOK_DESTRUCTOR, TOK_VIRTUAL, TOK_PRIVATE,    /* Oregon Software Pascal tokens */    TOK_ORIGIN, TOK_INTFONLY,    /* VAX Pascal tokens */    TOK_REM, TOK_VALUE, TOK_VARYING, TOK_OCTLIT, TOK_COLONCOLON,    TOK_STARSTAR,    /* Modula-2 tokens */    TOK_BY, TOK_DEFINITION, TOK_ELSIF, TOK_FROM, TOK_LOOP,    TOK_POINTER, TOK_QUALIFIED, TOK_RETURN,    /* UCSD Pascal tokens */    TOK_SEGMENT,    /* TIP tokens */    TOK_RANDOM, TOK_COMMON, TOK_ACCESS,    /* Object Pascal tokens */    TOK_INHERITED, TOK_OVERRIDE,    TOK_LAST} Token;#ifdef define_globalschar *toknames[(int)TOK_LAST] = { "",    "AND", "ARRAY", "BEGIN", "CASE", "CONST",    "DIV", "DO", "DOWNTO", "ELSE", "END",    "FILE", "FOR", "FUNCTION", "GOTO", "IF",    "IN", "LABEL", "MOD", "NIL", "NOT",    "OF", "OR", "PACKED", "PROCEDURE", "PROGRAM",    "RECORD", "REPEAT", "SET", "THEN", "TO",    "TYPE", "UNTIL", "VAR", "WHILE", "WITH",    "a '$'", "a string literal", "a '('", "a ')'", "a '*'",    "a '+'", "a comma", "a '-'", "a '.'", "'..'",    "a '/'", "an integer", "a real number", "a colon", "a ':='",    "a semicolon", "a '<>'", "a '<'", "a '>'", "a '<='", "a '>='",    "an '='", "a '['", "a ']'", "a '^'",    "an \"include\" file", "$end$",    "an identifier", "an integer", "end of file",    "an '->'", "an '&'", "a '|'", "a '!'",     "a '~'", "a '%'", "a '?'",    "a '<<'", "a '>>'", "a '=='", "a '!='",    "a '++'", "a '--'", "a '&&'", "a '||'",    "a '{'", "a '}'", "a character literal",    "ANYVAR", "EXPORT", "IMPLEMENT", "IMPORT", "MODULE",    "OTHERWISE", "RECOVER", "TRY",    "SHL", "SHR", "XOR", "INLINE", "ABSOLUTE",    "INTERRUPT", "an '@'", "a hex integer", "OBJECT",    "CONSTRUCTOR", "DESTRUCTOR", "VIRTUAL", "PRIVATE",    "ORIGIN", "INTF-ONLY",    "REM", "VALUE", "VARYING", "an octal integer", "a '::'",    "a '**'",    "BY", "DEFINITION", "ELSIF", "FROM", "LOOP",    "POINTER", "QUALIFIED", "RETURN",    "SEGMENT",    "RANDOM", "COMMON", "ACCESS",    "INHERITED", "OVERRIDE"} ;#elseextern char *toknames[];#endif /*define_globals*/typedef struct S_strlist {    struct S_strlist *next;    long value;    char s[1];} Strlist;typedef struct S_value {    struct S_type *type;    long i;    char *s;} Value;/* "Symbol" notes: * * The symbol table is used for several things.  Mainly it records all * identifiers in the Pascal program (normally converted to upper case). * Also used for recording certain properties about C and Pascal names. * * The symbol table is a hash table of binary trees. */#define AVOIDNAME  0x1         /* Avoid this name in C code */#define WARNNAME   0x2	       /* Warn if using this name in C code */#define AVOIDGLOB  0x4	       /* Avoid C name except private to module */#define NOSIDEEFF  0x8	       /* Function by this name has no side effects */#define STRUCTF    0x10	       /* Function by this name is a StructFunction */#define STRLAPF    0x20	       /* Function by this name is a StrlapFunction */#define LEAVEALONE 0x40	       /* Do not use custom handler for function */#define DETERMF    0x80	       /* Function by this name is Deterministic */#define FMACREC    0x100       /* Used by FieldMacro stuff */#define AVOIDFIELD 0x200       /* Avoid this name as a struct field name */#define NEEDSTATIC 0x400       /* This name must be declared static */#define KWPOSS     0x800       /* This word may be a keyword */#define FUNCBREAK  0x7000      /* Line breaking flags (see sys.p2crc) */# define FALLBREAK  0x1000     /*  Break at all commas if at any */# define FSPCARG1   0x2000     /*  First argument is special */# define FSPCARG2   0x3000     /*  First two arguments are special */

⌨️ 快捷键说明

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