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

📄 common.h

📁 一个非常好的检索工具
💻 H
📖 第 1 页 / 共 3 页
字号:
    (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);/*******************************************************************//* The following macros are analogous to the ones above, except    *//* that they deal with sets of states instead of sets of terminals *//* or non-terminals.                                               *//*******************************************************************/#define SET_COLLECTION_BIT(i, b) \    collection[(i) * state_set_size + (((b) - 1) / SIZEOF_BC)] |= \         (((b) + BC_OFFSET) % SIZEOF_BC ? \          (BOOLEAN_CELL) 1 << (((b) + BC_OFFSET) % SIZEOF_BC) : \          (BOOLEAN_CELL) 1);#define EMPTY_COLLECTION_SET(i) \    { \        register int kji; \        for (kji = 0; kji < state_set_size; kji++) \             collection[(i) * state_set_size + kji] = 0; \    }/*******************************************************************//* The following macros can be used to check, set, or reset a bit  *//* in a bit-string of any length.                                  *//*******************************************************************/#define SET_BIT(set, b) \    (set)[((b) - 1) / SIZEOF_BC] |= \         (((b) + BC_OFFSET) % SIZEOF_BC ? \          (BOOLEAN_CELL) 1 << (((b) + BC_OFFSET) % SIZEOF_BC) : \          (BOOLEAN_CELL) 1);#define RESET_BIT(set, b) \    (set)[((b) - 1) / SIZEOF_BC] &= \         ~(((b) + BC_OFFSET) % SIZEOF_BC ? \           (BOOLEAN_CELL) 1 << (((b) + BC_OFFSET) % SIZEOF_BC): \           (BOOLEAN_CELL) 1);#define IS_ELEMENT(set, b)    /* is b in set ? */ \    ((set)[((b) - 1) / SIZEOF_BC] & \          (((b) + BC_OFFSET) % SIZEOF_BC ? \           (BOOLEAN_CELL) 1 << (((b) + BC_OFFSET) % SIZEOF_BC) : \           (BOOLEAN_CELL) 1))/*******************************************************************//*******************************************************************//**                                                               **//**                         ITERATION MACROS                      **//**                                                               **//*******************************************************************//*******************************************************************//* The following macros (ALL_) are used to iterate over a sequence.*//*******************************************************************/#define ALL_LA_STATES(indx) \        (indx = num_states + 1; indx <= (int) max_la_state; indx++)#define ALL_TERMINALS(indx) \        (indx = 1; indx <= num_terminals; indx++)#define ALL_TERMINALS_BACKWARDS(indx) \        (indx = num_terminals; indx >= 1; indx--)#define ALL_NON_TERMINALS(indx) \        (indx = num_terminals + 1; indx <= num_symbols; indx++)#define ALL_NON_TERMINALS_BACKWARDS(indx) \        (indx = num_symbols; indx >= num_terminals + 1; indx--)#define ALL_SYMBOLS(indx) (indx = 1; indx <= num_symbols; indx++)#define ALL_ITEMS(indx) (indx = 1; indx <= (int) num_items; indx++)#define ALL_STATES(indx) (indx = 1; indx <= (int) num_states; indx++)#define ALL_RULES(indx) (indx = 0; indx <= num_rules; indx++)#define ALL_RULES_BACKWARDS(indx) \        (indx = num_rules; indx >= 0; indx--)#define ENTIRE_RHS(indx, rule_no) (indx = rules[rule_no].rhs;\                                   indx < rules[(rule_no) + 1].rhs;\                                   indx++)#define RHS_SIZE(rule_no) (rules[(rule_no) + 1].rhs - rules[rule_no].rhs)#define RETRIEVE_STRING(indx) (&string_table[symno[indx].ptr])#define RETRIEVE_NAME(indx) (&string_table[name[indx]])/*******************************************************************//*******************************************************************//**                                                               **//**                      MISCELLANEOUS MACROS                     **//**                                                               **//*******************************************************************//*******************************************************************/#define TOUPPER(c) (islower(c) ? toupper(c) : c)#define MAX(a,b)   (((a) > (b)) ? (a) : (b))#define MIN(a,b)   (((a) < (b)) ? (a) : (b))#define ABS(x) (((x) < 0) ? -(x) : (x))#define NOT(item) (! item)/**********************************************************************//* The following two macros check whether or not the value of an      *//* integer variable exceeds the maximum limit for a short or a long   *//* integer, respectively. Note that the user should declare the       *//* variable in question as a long integer. In the case of INT_CHECK,  *//* this check is meaningful only if INT and SHORT are the same size.  *//* Otherwise, if INT and LONG are of the same size, as is usually the *//* case on large systems, this check is meaningless - too late !!!    *//**********************************************************************/#define SHORT_CHECK(var) \    if (var > SHRT_MAX) \    { \        PRNTERR("The limit of a short int value" \                " has been exceeded by " #var); \        exit(12); \    }#define INT_CHECK(var) \    if (var > INT_MAX) \    { \        PRNTERR("The limit of an int value" \                " has been exceeded by " #var); \        exit(12); \    }#define ENDPAGE_CHECK if (++output_line_no >= PAGE_SIZE) \                          PR_HEADING#define PRNT(msg) \    { \        printf("%s\n",msg); \        fprintf(syslis,"%s\n",msg); \        ENDPAGE_CHECK; \    }#define PRNTWNG(msg) \    { \        printf("***WARNING: %s\n",msg);\        fprintf(syslis,"***WARNING: %s\n",msg);\        ENDPAGE_CHECK; \    }#define PRNTERR(msg) \    { \        printf("***ERROR: %s\n",msg);\        fprintf(syslis,"***ERROR: %s\n",msg);\        ENDPAGE_CHECK; \    }/*******************************************************************//*******************************************************************//**                                                               **//**     MACROS FOR DEREFERENCING AUTOMATON HEADER STRUCTURES      **//**                                                               **//*******************************************************************//*******************************************************************/#define SHIFT_SYMBOL(hdr, indx)   (((hdr).map)[indx].symbol)#define SHIFT_ACTION(hdr, indx)   (((hdr).map)[indx].action)#define GOTO_SYMBOL(hdr, indx)    (((hdr).map)[indx].symbol)#define GOTO_ACTION(hdr, indx)    (((hdr).map)[indx].action)#define GOTO_LAPTR(hdr, indx)     (((hdr).map)[indx].laptr)#define REDUCE_SYMBOL(hdr, indx)  (((hdr).map)[indx].symbol)#define REDUCE_RULE_NO(hdr, indx) (((hdr).map)[indx].rule_number)/*******************************************************************//*******************************************************************//**                                                               **//**                         OUTPUT MACROS                         **//**                                                               **//*******************************************************************//*******************************************************************//* The following macro definitions are used only in processing the *//* output.                                                         *//*******************************************************************/#define BUFFER_CHECK(file) \    if ((IOBUFFER_SIZE - (output_ptr - &output_buffer[0])) < 73) \    { \        fwrite(output_buffer, sizeof(char), \               output_ptr - &output_buffer[0], file); \        output_ptr = &output_buffer[0]; \    }/*******************************************************************//*******************************************************************//**                                                               **//**                      GLOBAL DECLARATIONS                      **//**                                                               **//*******************************************************************//*******************************************************************/typedef unsigned int BOOLEAN_CELL; /* Basic unit used to represent */                                   /* Bit sets                     */typedef BOOLEAN_CELL *SET_PTR;typedef char BOOLEAN;extern const char HEADER_INFO[];extern const char VERSION[];extern const char BLANK[];extern const long MAX_TABLE_SIZE;struct node{    struct node *next;    int          value;};/*******************************************************************//* RULES is the structure that contain the rules of the grammar.   *//* Every rule of the grammar is mapped into an integer, and given  *//* rule, and we have access to a value RHS which is the index      *//* location in the vector RHS where the right-hand-side of the rule*//* begins.  The right hand side of a certain rule represented by an*//* integer I starts at index location RULES[I].RHS in RHS, and     *//* ends at index location RULES[I + 1].RHS - 1.  An extra          *//* NUM_RULES + 1 element is used as a "fence" for the last rule.   *//* The RHS vector as mentioned above is used to hold a complete    *//* list of allthe right-hand-side symbols specified in the grammar.*//*******************************************************************/struct ruletab_type{    short   lhs,            rhs;    BOOLEAN sp;};struct shift_type{    short symbol,          action;};struct shift_header_type{    struct shift_type *map;    short              size;};struct reduce_type{    short symbol,          rule_number;};struct reduce_header_type{    struct reduce_type *map;    short              size;};struct goto_type{    int   laptr;    short symbol,          action;};struct goto_header_type{    struct goto_type *map;    short             size;};struct lastats_type{    struct reduce_header_type reduce;    short                     shift_number,                              in_state;};struct statset_type{    struct node             *kernel_items,                            *complete_items;    struct goto_header_type  go_to;    short                    shift_number;};extern char *timeptr;extern long output_line_no;

⌨️ 快捷键说明

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