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

📄 common.h

📁 一个非常好的检索工具
💻 H
📖 第 1 页 / 共 3 页
字号:
/* $Id: common.h,v 1.4 2001/10/10 14:53:10 ericb Exp $ *//* This software is subject to the terms of the IBM Jikes Compiler License Agreement available at the following URL: http://ibm.com/developerworks/opensource/jikes. Copyright (C) 1983, 1999, 2001 International Business Machines Corporation and others.  All Rights Reserved. You must accept the terms of that agreement to use this software.*/#ifndef COMMON_INCLUDED#define COMMON_INCLUDED/*******************************************************************//* One of the switches below may have to be set prior to building  *//* JIKES PG. OS2 is for all C compilers running under OS2. DOS is  *//* for all C compilers running under DOS. Note that to run under   *//* DOS, the compiler used must support the Huge model (32-bit ptr  *//* simulation). C370 is for the IBM C compiler running under CMS   *//* or MVS. CW is for the Waterloo C compiler running under VM/CMS. *//*                                                                 *//* This system was built to run on a vanilla Unix or AIX system.   *//* No switch need to be set for such an environment.  Set other    *//* switch(es) as needed. Note that the switch C370 should always   *//* be accompanied by either the switch VM or the switch MVS.       *//*                                                                 *//*******************************************************************//*#define DOS#define OS2#define MVS#define CW#define C370#define VM*/#include <assert.h>#include <stddef.h>#include <stdio.h>#include <stdlib.h>#include <limits.h>#include "c370.h"/*******************************************************************//*******************************************************************//**                                                               **//**                         GLOBAL CONSTANTS                      **//**                                                               **//*******************************************************************//*******************************************************************/#define PR_HEADING  \    { \        fprintf(syslis, "\f\n\n %-39s%s %-30.24s Page %d\n\n",\                        HEADER_INFO, VERSION, timeptr, ++page_no);\                        output_line_no = 4;\    }#define MAX_PARM_SIZE      22#define SYMBOL_SIZE        256#define MAX_MSG_SIZE       (256 + SYMBOL_SIZE)#define PRINT_LINE_SIZE    80#define PARSER_LINE_SIZE   80#define MAX_LINE_SIZE      256#undef  PAGE_SIZE#define PAGE_SIZE          55#define OPTIMIZE_TIME      1#define OPTIMIZE_SPACE     2#define MINIMUM_NAMES      1#define MAXIMUM_NAMES      2#define OPTIMIZE_PHRASES   3#define NOTRACE            0#define TRACE_CONFLICTS    1#define TRACE_FULL         2#define STATE_TABLE_UBOUND 1020#define STATE_TABLE_SIZE   (STATE_TABLE_UBOUND + 1) /* 1021 is a prime */#define SHIFT_TABLE_UBOUND 400#define SHIFT_TABLE_SIZE   (SHIFT_TABLE_UBOUND + 1) /* 401 is a prime */#define SCOPE_UBOUND       100#define SCOPE_SIZE         (SCOPE_UBOUND + 1)   /* 101 is prime */#undef  FALSE#undef  TRUE#define FALSE              0#define TRUE               1#define IS_A_TERMINAL      <= num_terminals#define IS_A_NON_TERMINAL  > num_terminals#define SPACE          ' '#define COMMA          ','#define INFINITY       ((short) SHRT_MAX)#define OMEGA          ((short) SHRT_MIN)#define NIL            ((short) SHRT_MIN + 1)#define DEFAULT_SYMBOL 0/*******************************************************************//*******************************************************************//**                                                               **//**                       ALLOCATE/FREE MACROS                    **//**                                                               **//*******************************************************************//*******************************************************************//* The following macro definitions are used to preprocess calls to *//* allocate routines that require locations. The FFREE macro is    *//* normally an invocation to the FREE routine. It is encoded as    *//* a macro here in case we need to do some debugging on dynamic    *//* storage.                                                        *//*******************************************************************/#define Allocate_node()           allocate_node(hostfile, __LINE__)#define Allocate_int_array(n)     allocate_int_array(n, hostfile, __LINE__)#define Allocate_short_array(n)   allocate_short_array(n, hostfile, __LINE__)#define Allocate_boolean_array(n) allocate_boolean_array(n, hostfile, __LINE__)#define Allocate_goto_map(n)      allocate_goto_map(n, hostfile, __LINE__)#define Allocate_shift_map(n)     allocate_shift_map(n, hostfile, __LINE__)#define Allocate_reduce_map(n)    allocate_reduce_map(n, hostfile, __LINE__)#define ffree(x) free(x) /* { free(x); x = (void *) ULONG_MAX; } *//*******************************************************************//*******************************************************************//**                                                               **//**                          PARSING MACROS                       **//**                                                               **//*******************************************************************//*******************************************************************//* The following macro definitions are used only in processing the *//* input source.                                                   *//*******************************************************************/#define EQUAL_STRING(symb, p) \        (strcmp((symb), string_table + (p) -> st_ptr) == 0)#define EXTRACT_STRING(indx) (&string_table[indx])#define HT_SIZE           701     /* 701 is a prime */#define RULEHDR_INCREMENT 1024#define ACTELMT_INCREMENT 1024#define DEFELMT_INCREMENT 16#ifdef DOS#define IOBUFFER_SIZE 8192#else#define IOBUFFER_SIZE 65536#endif/*******************************************************************//*******************************************************************//**                                                               **//**                         BIT SET MACROS                        **//**                                                               **//*******************************************************************//*******************************************************************//* The following macros are used to define operations on sets that *//* are represented as bit-strings.  BOOLEAN_CELL is a type that is *//* used as the elemental unit used to construct the sets.  For     *//* example, if BOOLEAN_CELL consists of four bytes and assumming   *//* that each byte contains 8 bits then the constant SIZEOF_BC      *//* represents the total number of bits that is contained in each   *//* elemental unit.                                                 *//*                                                                 *//* In general, a parameter called "set" or "set"i, where i is an   *//* integer, is a pointer to a set or array of sets; a parameter    *//* called "i" or "j" represents an index in an array of sets; a    *//* parameter called "b" represents a particular element (or bit)   *//* within a set.                                                   *//*                                                                 *//*******************************************************************/#define SIZEOF_BC (sizeof(BOOLEAN_CELL) * CHAR_BIT)#define BC_OFFSET (SIZEOF_BC - 1)/*******************************************************************//* This macro takes as argument an array of bit sets called "set", *//* an integer "nt" indicating the index of a particular set in the *//* array and an integer "t" indicating a particular element within *//* the set. IS_IN_SET check whether ot not the element "t" is in   *//* the set "set(nt)".                                              *//*                                                                 *//* The value (nt*term_set_size) is used to determine the starting  *//* address of the set element in question.  The value              *//* (??? / SIZEOF_BC) is used to determine the actual BOOLEAN_CELL  *//* containing the bit in question.  Finally, the value             *//* (SIZEOF_BC - (t % SIZEOF_BC)) identifies the actual bit in the  *//* unit. The bit in question is pushed to the first position and   *//* and-ed with the value 01. This operation yields the value TRUE  *//* if the bit is on. Otherwise, the value FALSE is obtained.       *//* Recall that in C, one cannot shift (left or right) by 0. This   *//* is why the ? is used here.                                      *//*******************************************************************/#define IS_IN_SET(set, i, b)    /* is b in set[i] ? */ \    ((set)[(i) * term_set_size + (((b) - 1) / SIZEOF_BC)] & \          (((b) + BC_OFFSET) % SIZEOF_BC ? \           (BOOLEAN_CELL) 1 << (((b) + BC_OFFSET) % SIZEOF_BC) : \           (BOOLEAN_CELL) 1))/*******************************************************************//* The macro SET_UNION takes as argument two arrays of sets:       *//* "set1" and "set2", and two integers "i" and "j" which are       *//* indices to be used to access particular sets in "set1" and      *//* "set2", respectively.  SET_UNION computes the union of the two  *//* sets in question and places the result in the relevant set in   *//* "set1".                                                         *//*                                                                 *//* The remaining macros are either analoguous to IS_IN_SET or      *//* SET_UNION.                                                      *//*                                                                 *//* Note that a macro with the variable "kji" declared in its body  *//* should not be invoked with a parameter of the same name.        *//*                                                                 *//*******************************************************************/#define SET_UNION(set1, i, set2, j)    /* set[i] union set2[j] */ \    { \        register int kji; \        for (kji = 0; kji < term_set_size; kji++) \             (set1)[(i) * term_set_size + kji] |= \                   (set2)[(j) * term_set_size + kji]; \    }#define INIT_SET(set)    /* set = {} */ \    { \        register int kji; \        for (kji = 0; kji < term_set_size; kji++) \             (set)[kji] = 0; \    }#define ASSIGN_SET(set1, i, set2, j)    /* set1[i] = set2[j] */ \    { \        register int kji; \        for (kji = 0; kji < term_set_size; kji++) \             (set1)[(i) * term_set_size + kji] = \                   (set2)[(j) * term_set_size + kji]; \    }#define SET_BIT_IN(set, i, b)    /* set[i] = set[i] with b; */ \    (set)[(i) * term_set_size + (((b) - 1) / SIZEOF_BC)] |= \         (((b) + BC_OFFSET) % SIZEOF_BC ? \          (BOOLEAN_CELL) 1 << (((b) + BC_OFFSET) % SIZEOF_BC) : \          (BOOLEAN_CELL) 1);#define RESET_BIT_IN(set, i, b)    /* set[i] = set[i] less b; */ \    (set)[(i) * term_set_size + (((b) - 1) / SIZEOF_BC)] &= \         ~(((b) + BC_OFFSET) % SIZEOF_BC ? \           (BOOLEAN_CELL) 1 << (((b) + BC_OFFSET) % SIZEOF_BC): \           (BOOLEAN_CELL) 1);/*******************************************************************//* The following macros are analogous to the ones above, except    *//* that they deal with sets of non-terminals instead of sets of    *//* terminals.                                                      *//*******************************************************************/#define IS_IN_NTSET(set, i, b)    /* is b in set[i] ? */ \    ((set)[(i) * non_term_set_size + (((b) - 1) / SIZEOF_BC)] & \          (((b) + BC_OFFSET) % SIZEOF_BC ? \           (BOOLEAN_CELL) 1 << (((b) + BC_OFFSET) % SIZEOF_BC) : \           (BOOLEAN_CELL) 1))#define NTSET_UNION(set1, i, set2, j)    /* set1[i] union set2[j] */ \    { \        register int kji; \        for (kji = 0; kji < non_term_set_size; kji++) \             (set1)[(i) * non_term_set_size + kji] |= \                   (set2)[(j) * non_term_set_size + kji]; \    }#define INIT_NTSET(set)    /* set = {} */ \    { \        register int kji; \        for (kji = 0; kji < non_term_set_size; kji++) \             (set)[kji] = 0; \    }#define ASSIGN_NTSET(set1, i, set2, j)    /* set1[i] = set2[j] */ \    { \        register int kji; \        for (kji = 0; kji < non_term_set_size; kji++) \             (set1)[(i) * non_term_set_size + kji] = \                   (set2)[(j) * non_term_set_size + kji]; \    }#define NTSET_BIT_IN(set, i, b)    /* set[i] = set[i] with b; */ \    (set)[(i) * non_term_set_size + (((b) - 1) / SIZEOF_BC)] |= \         (((b) + BC_OFFSET) % SIZEOF_BC ? \          (BOOLEAN_CELL) 1 << (((b) + BC_OFFSET) % SIZEOF_BC) : \          (BOOLEAN_CELL) 1);#define NTRESET_BIT_IN(set, i, b)    /* set[i] = set[i] less b; */ \

⌨️ 快捷键说明

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