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

📄 lpgparse.c

📁 一个非常好的检索工具
💻 C
📖 第 1 页 / 共 5 页
字号:
                 (parm[i] == ' ')))            i++;    }    return;}/****************************************************************************//*                       PROCESS_OPTIONS_LINES:                             *//****************************************************************************//*    In this function, we read the first line(s) of the input text to see  *//* if they are (it is an) "options" line(s).  If so, the options are        *//* processed.  Then, we process user-supplied options if there are any.  In *//* any case, the options in effect are printed.                             *//****************************************************************************/static void process_options_lines(void){    char old_parm[MAX_LINE_SIZE + 1],         output_line[PRINT_LINE_SIZE + 1],         opt_string[60][OUTPUT_PARM_SIZE + 1],         *line_end,         temp[SYMBOL_SIZE + 1];    static char ooptions[9] = " OPTIONS";    int top = 0,        i;    strcpy(old_parm, parm); /* Save new options passed to program */    ooptions[0] = escape;   /* "ooptions" always uses default escape symbol */    while (p1 != '\0') /* Until end-of-file is reached, process */    {                 /* all comment and %options lines.       */        while(IsSpace(*p2))    /* skip all space symbols */        {            if (*p2 == '\n')            {                line_no++;                linestart = p2;                p1 = p2 + 1;            }            p2++;        }        line_end = strchr(p2, '\n'); /* find end-of-line */        /*********************************************************************/        /* First, check if line is a comment line. If so, skip it.  Next,    */        /* check if line is an options line. If so, process it. Otherwise,   */        /* break out of the loop.                                            */        /* Note that no length check is necessary before checking for "--"   */        /* or "%options" since the buffer is always extended by              */        /* MAX_LINE_SIZE elements past its required length. (see read_input) */        /*********************************************************************/        if (*p2 == '-' && *(p2 + 1) == '-')            /* skip comment line */ ;        else if (memcmp(ooptions, translate(p2, 8), 8) == 0)        {            *line_end = '\0';            PRNT(p2);    /* Print options line */            strcpy(parm, p2 + strlen(ooptions));            options();   /* Process hard-coded options */        }        else        {            p2 = p1; /* make p2 point to first character */            break;        }        /*********************************************************************/        /* If the line was a comment or an option line, check the following  */        /* line.  If we are at the end of the buffer, read in more data...   */        /*********************************************************************/        p1 = line_end + 1;        if (bufend == input_buffer + IOBUFFER_SIZE)        {            i = bufend - p1;            if (i < MAX_LINE_SIZE)            {                strcpy(input_buffer, p1);                bufend = &input_buffer[i];                read_input();                p1 = &input_buffer[0];            }        }        line_no++;        linestart = p1 - 1;        p2 = p1;    }    fprintf(syslis, "\n");    strcpy(parm, old_parm);    options();  /* Process new options passed directly to  program */    if (! error_maps_bit)  /* Deferred parsing without error maps is useless*/        deferred_bit = FALSE;#if (defined(C370) || defined(CW)) && (!defined(MVS))        strupr(file_prefix);        if (pn[0] == '\0')        {            strcpy(pn,file_prefix);            strcat(pn, "PRS");        }        if (sn[0] == '\0')        {            strcpy(sn,file_prefix);            strcat(sn, "SYM");        }        if (an[0] == '\0')        {            strcpy(an,file_prefix);            strcat(an, "ACT");        }        if (han[0] == '\0')        {            strcpy(han,file_prefix);            strcat(han, "HDR");        }        sprintf(act_file, "%s.%s.%s", an, at, am);        sprintf(hact_file, "%s.%s.%s", han, hat, ham);        sprintf(sym_file, "%s.%s.%s", sn, st, sm);        sprintf(def_file, "%sDEF.%s.%s", file_prefix, (java_bit ? "JAVA" : "H"), sm);        sprintf(prs_file, "%s.%s.%s", pn, pt, pm);        sprintf(dcl_file, "%sDCL.%s.%s", file_prefix, (java_bit ? "JAVA" : "H"), sm);#else#if defined(MVS)        if (act_file[0] == '\0')            sprintf(act_file, "%sACT.%s", file_prefix, (java_bit ? "JAVA" : "H"));        if (hact_file[0] == '\0')            sprintf(hact_file, "%sHDR.%s", file_prefix, (java_bit ? "JAVA" : "H"));        sprintf(sym_file, "%sSYM.%s", file_prefix, (java_bit ? "JAVA" : "H"));        sprintf(def_file, "%sDEF.%s", file_prefix, (java_bit ? "JAVA" : "H"));        sprintf(prs_file, "%sPRS.%s", file_prefix, (java_bit ? "JAVA" : "H"));        sprintf(dcl_file, "%sDCL.%s", file_prefix, (java_bit ? "JAVA" : "H"));#else        if (act_file[0] == '\0')            sprintf(act_file, "%sact.%s", file_prefix, (java_bit ? "java" : "h"));        if (hact_file[0] == '\0')            sprintf(hact_file, "%shdr.%s", file_prefix, (java_bit ? "java" : "h"));        sprintf(sym_file, "%ssym.%s", file_prefix, (java_bit ? "java" : "h"));        sprintf(def_file, "%sdef.%s", file_prefix, (java_bit ? "java" : "h"));        sprintf(prs_file, "%sprs.%s", file_prefix, (java_bit ? "java" : "h"));        sprintf(dcl_file, "%sdcl.%s", file_prefix, (java_bit ? "java" : "h"));#endif#endif    if (verbose_bit)   /* turn everything on */    {        first_bit = TRUE;        follow_bit = TRUE;        list_bit = TRUE;        states_bit = TRUE;        xref_bit = TRUE;        warnings_bit = TRUE;    }/*****************************************************************************//*                          PRINT OPTIONS:                                   *//*****************************************************************************//* Here we print all options set by the user.  As of now, only about 48      *//* different options and related aliases are allowed.  In case that number   *//* goes up, the bound of the array, opt_string, should be changed.           *//* BLOCKB, BLOCKE, HBLOCKB and HBLOCKE can generate the longest strings      *//* since their value can be up to MAX_PARM_SIZE characters long.             *//*****************************************************************************/    if (action_bit)        strcpy(opt_string[++top], "ACTION");    else        strcpy(opt_string[++top], "NOACTION");#if (defined(C370) || defined(CW)) && (!defined(MVS))    sprintf(opt_string[++top], "ACTFILE-NAME=%s",an);    sprintf(opt_string[++top], "ACTFILE-TYPE=%s",at);    sprintf(opt_string[++top], "ACTFILE-MODE=%s",am);#else    sprintf(opt_string[++top], "ACTFILE-NAME=%s",act_file);#endif    sprintf(opt_string[++top], "BLOCKB=%s",blockb);    sprintf(opt_string[++top], "BLOCKE=%s", blocke);    if (byte_bit)        strcpy(opt_string[++top], "BYTE");    if (conflicts_bit)        strcpy(opt_string[++top], "CONFLICTS");    else        strcpy(opt_string[++top], "NOCONFLICTS");    if (default_opt == 0)        strcpy(opt_string[++top], "NODEFAULT");    else        sprintf(opt_string[++top], "DEFAULT=%d",default_opt);    if (debug_bit)        strcpy(opt_string[++top], "DEBUG");    else        strcpy(opt_string[++top], "NODEBUG");    if (deferred_bit)        strcpy(opt_string[++top], "DEFERRED");    else        strcpy(opt_string[++top], "NODEFERRED");    if (edit_bit)        strcpy(opt_string[++top], "EDIT");    else        strcpy(opt_string[++top], "NOEDIT");    if (error_maps_bit)        strcpy(opt_string[++top], "ERROR-MAPS");    else        strcpy(opt_string[++top], "NOERROR-MAPS");    sprintf(opt_string[++top], "ESCAPE=%c", escape);    sprintf(opt_string[++top], "FILE-PREFIX=%s", file_prefix);    if (first_bit)        strcpy(opt_string[++top], "FIRST");    else        strcpy(opt_string[++top], "NOFIRST");    if (follow_bit)        strcpy(opt_string[++top], "FOLLOW");    else        strcpy(opt_string[++top], "NOFOLLOW");    if (c_bit)        sprintf(opt_string[++top], "GENERATE-PARSER=C");    else if (cpp_bit)        sprintf(opt_string[++top], "GENERATE-PARSER=C++");    else if (java_bit)        sprintf(opt_string[++top], "GENERATE-PARSER=JAVA");    else        strcpy(opt_string[++top], "NOGENERATE-PARSER");    if (goto_default_bit)        strcpy(opt_string[++top], "GOTO-DEFAULT");    else        strcpy(opt_string[++top], "NOGOTO-DEFAULT");#if defined(C370) || defined(CW)    sprintf(opt_string[++top], "HACTFILE-NAME=%s", han);    sprintf(opt_string[++top], "HACTFILE-TYPE=%s", hat);    sprintf(opt_string[++top], "HACTFILE-MODE=%s", ham);#else    sprintf(opt_string[++top], "HACTFILE-NAME=%s", hact_file);#endif    if (! byte_bit)        strcpy(opt_string[++top], "HALF-WORD");    sprintf(opt_string[++top], "HBLOCKB=%s", hblockb);    sprintf(opt_string[++top], "HBLOCKE=%s", hblocke);    if (! slr_bit)        sprintf(opt_string[++top], "LALR=%d", lalr_level);    if (list_bit)        strcpy(opt_string[++top], "LIST");    else        strcpy(opt_string[++top], "NOLIST");    sprintf(opt_string[++top], "MAX-DISTANCE=%d",maximum_distance);    sprintf(opt_string[++top], "MIN-DISTANCE=%d",minimum_distance);    if (names_opt == MAXIMUM_NAMES)        strcpy(opt_string[++top], "NAMES=MAXIMUM");    else if (names_opt == MINIMUM_NAMES)        strcpy(opt_string[++top], "NAMES=MINIMUM");    else        strcpy(opt_string[++top], "NAMES=OPTIMIZED");    if (nt_check_bit)        strcpy(opt_string[++top], "NT-CHECK");    else        strcpy(opt_string[++top], "NONT-CHECK");    sprintf(opt_string[++top], "ORMARK=%c", ormark);    sprintf(opt_string[++top], "OUTPUT-SIZE=%d", output_size);    sprintf(opt_string[++top], "PREFIX=%s",prefix);    if (read_reduce_bit)        strcpy(opt_string[++top], "READ-REDUCE");    else        strcpy(opt_string[++top], "NOREAD-REDUCE");#if defined(C370) || defined(CW)    if (record_format == 'F')        strcpy(opt_string[++top], "RECORD-FORMAT=F");    else        strcpy(opt_string[++top], "RECORD-FORMAT=V");#endif    if (scopes_bit)        strcpy(opt_string[++top], "SCOPES");    else        strcpy(opt_string[++top], "NOSCOPES");    if (shift_default_bit)        strcpy(opt_string[++top], "SHIFT-DEFAULT");    else        strcpy(opt_string[++top], "NOSHIFT-DEFAULT");    if (single_productions_bit)        strcpy(opt_string[++top], "SINGLE-PRODUCTIONS");    else        strcpy(opt_string[++top], "NOSINGLE-PRODUCTIONS");    if (slr_bit)        strcpy(opt_string[++top], "SLR");    sprintf(opt_string[++top], "STACK-SIZE=%d",stack_size);    if (states_bit)        strcpy(opt_string[++top], "STATES");    else        strcpy(opt_string[++top], "NOSTATES");    sprintf(opt_string[++top], "SUFFIX=%s",suffix);    if (table_opt == 0)        strcpy(opt_string[++top], "NOTABLE");    else if (table_opt == OPTIMIZE_SPACE)        strcpy(opt_string[++top], "TABLE=SPACE");    else        strcpy(opt_string[++top], "TABLE=TIME");    if (trace_opt == NOTRACE)        strcpy(opt_string[++top], "NOTRACE");    else if (trace_opt == TRACE_CONFLICTS)        strcpy(opt_string[++top], "TRACE=CONFLICTS");    else        strcpy(opt_string[++top], "TRACE=FULL");    if (verbose_bit)        strcpy(opt_string[++top], "VERBOSE");    else        strcpy(opt_string[++top], "NOVERBOSE");    if (warnings_bit)        strcpy(opt_string[++top], "WARNINGS");    else        strcpy(opt_string[++top], "NOWARNINGS");    if (xref_bit)        strcpy(opt_string[++top], "XREF");    else        strcpy(opt_string[++top], "NOXREF");

⌨️ 快捷键说明

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