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

📄 lpgparse.c

📁 一个非常好的检索工具
💻 C
📖 第 1 页 / 共 5 页
字号:
    }    return TRUE;}/*****************************************************************************//*                              OPTIONS:                                     *//*****************************************************************************//*   OPTION handles the decoding of options passed by the user and resets    *//* them appropriately. "options" may be called twice: when a parameter line  *//* is passed to the main program and when the user codes an %OPTIONS line in *//* his grammar.                                                              *//*    Basically, there are two kinds of options: switches which indicate a   *//* certain setting just by their appearance, and valued options which are    *//* followed by an equal sign and the value to be assigned to them.           *//*****************************************************************************/static void options(void){    char *c,         token[MAX_PARM_SIZE+1],         temp [MAX_PARM_SIZE+1],         delim;    register int i,                 j,                 len;    BOOLEAN flag;/*******************************************************************//* If we scan the comment sign, we stop processing the rest of the *//* parameter string.                                               *//*******************************************************************/    for (c = parm; *c != '\0'; c++)    {        if (*c == '-' && *(c+1) == '-')            break;    }    *c = '\0';    i = 0;    while ((parm[i] != '\0') &&    /* Clean front of string */           ((parm[i] == ',') ||            (parm[i] == '/') ||            (parm[i] == ' ')))         i++;    while (parm[i] != '\0')     /* Repeat until parm line is exhausted */    {        strcpy(parm, parm + i);       /* Remove garbage in front */        i = 0;        while ((parm[i] != '\0')&&    /* Search for delimiter */               ((parm[i] != ',') &&                (parm[i] != '/') &&                (parm[i] != '=') &&                (parm[i] != ' ')))            i++;        for (j = 0; j < i; j++)   /* Fold actual parameter */        {            token[j] = TOUPPER(parm[j]);            temp[j] = parm[j];        }        token[i] = '\0';        temp[i] = '\0';        /***********************************/        /* find first non-blank after parm */        /***********************************/        while (parm[i] != '\0' && parm[i] == ' ')            i++;        if (parm[i] != '\0')  /* not end of parameter line */            delim = parm[i];        else            delim = ' ';        len = strlen(token);        if (len > MAX_PARM_SIZE)            token[MAX_PARM_SIZE] = '\0';/*****************************************************************************//*  We check whether we have a switch or a value parameter.                  *//* Each category is checked separately.  A match is made whenever            *//* a minimum unambiguous prefix of the token in question matches an          *//* option...                                                                 *//*                                                                           *//* At this stage, TEMP contains the value of the switch as specified         *//* and TOKEN contains the upper-case folded value of TEMP.                   *//*****************************************************************************/        if (delim != '=')  /* if switch parameter then process */        {            if ((len > 2) &&                (memcmp(token, "NO", 2) == 0)) /* option has "NO" */            {                                  /* prefix?         */                flag = FALSE;                len = len-2;                strcpy(token, token + 2);  /* get rid of "NO" prefix */            }            else                flag = TRUE;            if (memcmp(oaction, token, len) == 0)                action_bit = flag;            else if (memcmp(obyte, token, len) == 0)                byte_bit = flag;            else if (memcmp(oconflicts, token, len) == 0)                conflicts_bit = flag;            else if (len >=4 && memcmp(odefault, token, len) == 0)            {                if (flag)                    default_opt = 5;                else                    default_opt = 0;            }            else if (len >= 3 && memcmp(odebug, token, len) == 0)                debug_bit = flag;            else if (len >= 4 && memcmp(odeferred, token, len) == 0)                deferred_bit = flag;            else if (len >= 2 && memcmp(oedit, token, len) == 0)                edit_bit = flag;            else if ((len >= 2) &&                      ((memcmp(oerrormaps,token, len) == 0) ||                       (strcmp("EM", token) == 0) ||                       (memcmp(oerrormaps2, token, len) == 0) ||                       (memcmp(oerrormaps3, token, len) == 0)))                error_maps_bit = flag;            else if ((len >= 2) && (memcmp(ofirst, token, len) == 0))                first_bit = flag;            else if ((len >= 2) && (memcmp(ofollow, token, len) == 0))                follow_bit = flag;            else if (len >= 2 &&                     ((strcmp(token, "GP") == 0) ||                      (memcmp(ogenprsr, token, len) == 0) ||                      (memcmp(ogenprsr2, token, len) == 0) ||                      (memcmp(ogenprsr3, token, len) == 0)))            {                c_bit = flag;                cpp_bit = FALSE;                java_bit = FALSE;            }            else if (len >= 2 &&                     ((strcmp(token, "GD") == 0) ||                      (memcmp(ogotodefault, token, len) == 0) ||                      (memcmp(ogotodefault2, token, len) == 0) ||                      (memcmp(ogotodefault3, token, len) == 0)))                goto_default_bit = flag;            else if  ((strcmp(token, "HW") == 0) ||                      (memcmp(ohalfword, token, len) == 0) ||                      (memcmp(ohalfword2, token, len) == 0) ||                      (memcmp(ohalfword3, token, len) == 0))                byte_bit = NOT(flag);	    else if ((strcmp(token, "JI") == 0) ||		     (memcmp(ojikes, token, len) == 0))		jikes_bit = 1;            else if (len >= 2 && memcmp(olalr, token, len) == 0)            {                slr_bit = NOT(flag);                lalr_level = 1;            }            else if (len >= 2 && memcmp(olist, token, len) == 0)                list_bit = flag;            else if  ((strcmp(token, "NC") == 0) ||                      (memcmp(ontcheck, token, len) == 0) ||                      (memcmp(ontcheck2, token, len) == 0) ||                      (memcmp(ontcheck3, token, len) == 0))                nt_check_bit = flag;            else if ((strcmp(token, "RR") == 0) ||                     (memcmp(oreadreduce, token, len) == 0) ||                     (memcmp(oreadreduce2, token, len) == 0) ||                     (memcmp(oreadreduce3, token, len) == 0))                read_reduce_bit = flag;            else if (len >=2 && memcmp(oscopes, token, len) == 0)                scopes_bit = flag;            else if ((len >= 2) &&                     ((strcmp(token, "SD") == 0) ||                      (memcmp(oshiftdefault, token, len) == 0)  ||                      (memcmp(oshiftdefault2, token, len) == 0) ||                      (memcmp(oshiftdefault3, token, len) == 0)))                shift_default_bit = flag;            else if ((len >= 2) &&                     ((strcmp(token, "SP") == 0) ||                      (memcmp(osingleproductions, token, len) == 0) ||                      (memcmp(osingleproductions2, token, len) == 0) ||                      (memcmp(osingleproductions3, token, len) == 0)))                single_productions_bit = flag;            else if (len >= 2 && memcmp(oslr, token, len) == 0)            {                slr_bit = flag;                lalr_level = 1;            }            else if (len >= 2 && memcmp(ostates, token, len) == 0)                states_bit = flag;            else if (len >= 2 && memcmp(otable, token, len) == 0)            {                if (flag)                    table_opt = OPTIMIZE_SPACE;                else                    table_opt = 0;            }            else if (len >= 2 && memcmp(otrace, token, len) == 0)            {                if (flag)                    trace_opt = TRACE_CONFLICTS;                else                    trace_opt = NOTRACE;            }            else if (memcmp(overbose, token, len) == 0)                verbose_bit = flag;            else if (memcmp(owarnings, token, len) == 0)                warnings_bit = flag;            else if (memcmp(oxref, token, len) == 0)                xref_bit = flag;            else if ((strcmp(token, "D") == 0) ||                     (strcmp(token, "DE") == 0))            {                sprintf(msg_line,                        "\"%s\" is an ambiguous option: "                        "DEBUG, DEFAULT, DEFERRED ?", temp);                PRNTERR(msg_line);            }            else if (strcmp(token, "DEF") == 0)            {                PRNTERR("\"DEF\" is an ambiguous option: "                        "DEFAULT, DEFERRED ?");            }            else if (strcmp(token, "E") == 0)            {                PRNTERR("\"E\" is an ambiguous option: "                        "EDIT, ERROR-MAPS ?");            }            else if (strcmp(token, "F") == 0)            {                PRNTERR("\"F\" is an ambiguous option: FOLLOW, FIRST ?");            }            else if (strcmp(token, "G") == 0)            {                PRNTERR("\"G\" is an ambiguous option: "                        "GENERATE-PARSER, GOTO-DEFAULT ?");            }            else if (strcmp(token, "L") == 0)            {                PRNTERR("\"L\" is an ambiguous option: LALR, LIST ?");            }            else if (strcmp(token, "S") == 0)            {                PRNTERR("\"S\" is an ambiguous option:\n "                        "SCOPES, SEARCH, STATES, SLR, "                        "SHIFT-DEFAULT, SINGLE-PRODUCTIONS  ?");            }            else if (strcmp(token, "T") == 0)            {                PRNTERR("\"T\" is an ambiguous option:  TABLE, TRACE ?");            }            else            {                sprintf(msg_line, "\"%s\" is an invalid option", temp);                PRNTERR(msg_line);            }        }        /****************************************/        /* We now process the valued-parameter. */        /****************************************/        else /* value parameter. pick value after "=" and process */        {            i++;            if (IsSpace(parm[i]) || parm[i] == '\0')/* no value specified */            {                sprintf(msg_line,                        "Null string or blank is invalid for parameter %s",                        token);                PRNTERR(msg_line);                continue;            }            j = i;            while ((parm[i] != '\0')&&   /* find next delimeter */                   ((parm[i] !=  ',') &&                    (parm[i] !=  '/') &&                    (parm[i] !=  ' ')))                i++;            memcpy(temp, parm+j, i - j);  /* copy into TEMP */            temp[i - j] = '\0';#if (defined(C370) || defined(CW)) && (!defined(MVS))            if ((strcmp(token, "AN") == 0) ||                 ((len >= 9) &&                  ((memcmp(token, oactfile_name, len) == 0) ||                   (memcmp(token, oactfile_name2, len) == 0) ||                   (memcmp(token, oactfile_name3, len) == 0))))            {                memcpy(an, temp, 8);                pn[MIN(strlen(temp), 8)] = '\0';                strupr(an);            }            else if ((strcmp(token, "AT") == 0) ||                      ((len >= 9) &&                       ((memcmp(token, oactfile_type, len) == 0) ||                        (memcmp(token, oactfile_type2, len) == 0) ||                        (memcmp(token, oactfile_type3, len) == 0))))            {                memcpy(at, temp, 8);                at[MIN(strlen(temp), 8)] = '\0';                strupr(at);            }            else if ((strcmp(token, "AM") == 0) ||                     ((len >= 9) &&                      ((memcmp(token, oactfile_mode, len) == 0) ||                       (memcmp(token, oactfile_mode2, len) == 0) ||                       (memcmp(token, oactfile_mode3, len) == 0))))            {                memcpy(am, temp, 2);                am[MIN(strlen(temp), 2)] = '\0';                strupr(am);            }#else            if ((strcmp(token, "AN") == 0) ||                (memcmp(token, oactfile_name, len) == 0) ||                (memcmp(token, oactfile_name2, len) == 0) ||                (memcmp(token, oactfile_name3, len) == 0))               strcpy(act_file, temp);#endif            else if (strcmp(token, oblockb) == 0)                strcpy(blockb, temp);            else if (strcmp(token, oblocke) == 0)                strcpy(blocke, temp);            else if (memcmp(odefault, token, len) == 0)            {                if (verify(temp))                    default_opt = MIN(atoi(temp), 5);                else                {                    sprintf(msg_line,                            "\"%s\" is an invalid value for %s",                            temp, token);                    PRNTERR(msg_line);                }            }            else if (len >= 2 && memcmp(token, oescape, len) == 0)                escape = temp[0];            else if (((strcmp(token, "FP") == 0) ||                      (memcmp(token, ofile_prefix, len) == 0) ||                      (memcmp(token, ofile_prefix2, len) == 0) ||                      (memcmp(token, ofile_prefix3, len) == 0)))            {                memcpy(file_prefix, temp, 5);

⌨️ 快捷键说明

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