OpenCOBOL 1.1pre-rel
reserved.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2001-2009 Keisuke Nishida
00003  * Copyright (C) 2007-2009 Roger While
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2, or (at your option)
00008  * any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this software; see the file COPYING.  If not, write to
00017  * the Free Software Foundation, 51 Franklin Street, Fifth Floor
00018  * Boston, MA 02110-1301 USA
00019  */
00020 
00021 #include "config.h"
00022 
00023 #include <stdlib.h>
00024 #include <string.h>
00025 #include <ctype.h>
00026 
00027 #include "cobc.h"
00028 #include "tree.h"
00029 #include "parser.h"
00030 
00031 static struct {
00032         const char                              *name;
00033         const enum cb_system_name_category      category;
00034         const int                               token;
00035         cb_tree                                 node;
00036 } system_table[] = {
00037   {"SYSIN",             CB_DEVICE_NAME,  CB_DEVICE_SYSIN, NULL},
00038   {"SYSIPT",            CB_DEVICE_NAME,  CB_DEVICE_SYSIN, NULL},
00039   {"SYSOUT",            CB_DEVICE_NAME,  CB_DEVICE_SYSOUT, NULL},
00040   {"SYSLIST",           CB_DEVICE_NAME,  CB_DEVICE_SYSOUT, NULL},
00041   {"SYSLST",            CB_DEVICE_NAME,  CB_DEVICE_SYSOUT, NULL},
00042   {"PRINTER",           CB_DEVICE_NAME,  CB_DEVICE_SYSOUT, NULL},
00043   {"SYSERR",            CB_DEVICE_NAME,  CB_DEVICE_SYSERR, NULL},
00044   {"CONSOLE",           CB_DEVICE_NAME,  CB_DEVICE_CONSOLE, NULL},
00045   {"C01",               CB_FEATURE_NAME, CB_FEATURE_C01, NULL},
00046   {"C02",               CB_FEATURE_NAME, CB_FEATURE_C02, NULL},
00047   {"C03",               CB_FEATURE_NAME, CB_FEATURE_C03, NULL},
00048   {"C04",               CB_FEATURE_NAME, CB_FEATURE_C04, NULL},
00049   {"C05",               CB_FEATURE_NAME, CB_FEATURE_C05, NULL},
00050   {"C06",               CB_FEATURE_NAME, CB_FEATURE_C06, NULL},
00051   {"C07",               CB_FEATURE_NAME, CB_FEATURE_C07, NULL},
00052   {"C08",               CB_FEATURE_NAME, CB_FEATURE_C08, NULL},
00053   {"C09",               CB_FEATURE_NAME, CB_FEATURE_C09, NULL},
00054   {"C10",               CB_FEATURE_NAME, CB_FEATURE_C10, NULL},
00055   {"C11",               CB_FEATURE_NAME, CB_FEATURE_C11, NULL},
00056   {"C12",               CB_FEATURE_NAME, CB_FEATURE_C12, NULL},
00057   {"FORMFEED",          CB_FEATURE_NAME, CB_FEATURE_FORMFEED, NULL},
00058   {"SWITCH-1",          CB_SWITCH_NAME,  CB_SWITCH_1, NULL},
00059   {"SWITCH-2",          CB_SWITCH_NAME,  CB_SWITCH_2, NULL},
00060   {"SWITCH-3",          CB_SWITCH_NAME,  CB_SWITCH_3, NULL},
00061   {"SWITCH-4",          CB_SWITCH_NAME,  CB_SWITCH_4, NULL},
00062   {"SWITCH-5",          CB_SWITCH_NAME,  CB_SWITCH_5, NULL},
00063   {"SWITCH-6",          CB_SWITCH_NAME,  CB_SWITCH_6, NULL},
00064   {"SWITCH-7",          CB_SWITCH_NAME,  CB_SWITCH_7, NULL},
00065   {"SWITCH-8",          CB_SWITCH_NAME,  CB_SWITCH_8, NULL},
00066   {NULL, 0, 0, NULL}
00067 };
00068 
00069 struct reserved {
00070         const char      *name;
00071         const int       token;
00072 };
00073 
00074 static const struct reserved reserved_words[] = {
00075   {"ACCEPT",                    ACCEPT},                /* 2002 */
00076   {"ACCESS",                    ACCESS},                /* 2002 */
00077   {"ACTIVE-CLASS",              -1},                    /* 2002 */
00078   {"ADD",                       ADD},                   /* 2002 */
00079   {"ADDRESS",                   ADDRESS},               /* 2002 */
00080   {"ADVANCING",                 ADVANCING},             /* 2002 */
00081   {"AFTER",                     AFTER},                 /* 2002 */
00082   {"ALIGNED",                   -1},                    /* 2002 */
00083   {"ALL",                       ALL},                   /* 2002 */
00084   {"ALLOCATE",                  ALLOCATE},              /* 2002 */
00085   {"ALPHABET",                  ALPHABET},              /* 2002 */
00086   {"ALPHABETIC",                ALPHABETIC},            /* 2002 */
00087   {"ALPHABETIC-LOWER",          ALPHABETIC_LOWER},      /* 2002 */
00088   {"ALPHABETIC-UPPER",          ALPHABETIC_UPPER},      /* 2002 */
00089   {"ALPHANUMERIC",              ALPHANUMERIC},          /* 2002 */
00090   {"ALPHANUMERIC-EDITED",       ALPHANUMERIC_EDITED},   /* 2002 */
00091   {"ALSO",                      ALSO},                  /* 2002 */
00092   {"ALTER",                     ALTER},                 /* 85 */
00093   {"ALTERNATE",                 ALTERNATE},             /* 2002 */
00094   {"AND",                       AND},                   /* 2002 */
00095   {"ANY",                       ANY},                   /* 2002 */
00096   {"ANYCASE",                   -1},                    /* 2002 */
00097   {"ARE",                       ARE},                   /* 2002 */
00098   {"AREA",                      AREA},                  /* 2002 */
00099   {"AREAS",                     AREA},                  /* 2002 */
00100   {"ARGUMENT-NUMBER",           ARGUMENT_NUMBER},       /* extension */
00101   {"ARGUMENT-VALUE",            ARGUMENT_VALUE},        /* extension */
00102   {"ARITHMETIC",                -1},                    /* 2002 (C/S) */
00103   {"AS",                        AS},                    /* 2002 */
00104   {"ASCENDING",                 ASCENDING},             /* 2002 */
00105   {"ASSIGN",                    ASSIGN},                /* 2002 */
00106   {"AT",                        AT},                    /* 2002 */
00107   {"ATTRIBUTE",                 -1},                    /* 2002 (C/S) */
00108   {"AUTO",                      AUTO},                  /* 2002 (C/S) */
00109   {"AUTO-SKIP",                 AUTO},                  /* extension */
00110   {"AUTOMATIC",                 AUTOMATIC},             /* extension */
00111   {"AUTOTERMINATE",             AUTO},                  /* extension */
00112   {"B-AND",                     -1},                    /* 2002 */
00113   {"B-NOT",                     -1},                    /* 2002 */
00114   {"B-OR",                      -1},                    /* 2002 */
00115   {"B-XOR",                     -1},                    /* 2002 */
00116   {"BACKGROUND-COLOR",          BACKGROUND_COLOR},      /* 2002 (C/S) */
00117   {"BASED",                     BASED},                 /* 2002 */
00118   {"BEEP",                      BELL},                  /* extension */
00119   {"BEFORE",                    BEFORE},                /* 2002 */
00120   {"BELL",                      BELL},                  /* 2002 (C/S) */
00121   {"BINARY",                    BINARY},                /* 2002 */
00122   {"BINARY-C-LONG",             BINARY_C_LONG},         /* Extension */
00123   {"BINARY-CHAR",               BINARY_CHAR},           /* 2002 */
00124   {"BINARY-DOUBLE",             BINARY_DOUBLE},         /* 2002 */
00125   {"BINARY-LONG",               BINARY_LONG},           /* 2002 */
00126   {"BINARY-SHORT",              BINARY_SHORT},          /* 2002 */
00127   {"BIT",                       -1},                    /* 2002 */
00128   {"BLANK",                     BLANK},                 /* 2002 */
00129   {"BLINK",                     BLINK},                 /* 2002 (C/S) */
00130   {"BLOCK",                     BLOCK},                 /* 2002 */
00131   {"BOOLEAN",                   -1},                    /* 2002 */
00132   {"BOTTOM",                    BOTTOM},                /* 2002 */
00133   {"BY",                        BY},                    /* 2002 */
00134   {"BYTE-LENGTH",               BYTE_LENGTH},           /* 2002 (C/S) */
00135   {"CALL",                      CALL},                  /* 2002 */
00136   {"CANCEL",                    CANCEL},                /* 2002 */
00137   {"CD",                        -1},                    /* 2002 */
00138   {"CENTER",                    -1},                    /* 2002 (C/S) */
00139   {"CF",                        CONTROL_FOOTING},       /* 2002 */
00140   {"CH",                        CONTROL_HEADING},       /* 2002 */
00141   {"CHAIN",                     -1},                    /* extension */
00142   {"CHAINING",                  CHAINING},              /* extension */
00143   {"CHARACTER",                 CHARACTER},             /* 2002 */
00144   {"CHARACTERS",                CHARACTERS},            /* 2002 */
00145   {"CLASS",                     CLASS},                 /* 2002 */
00146   {"CLASS-ID",                  -1},                    /* 2002 */
00147   {"CLASSIFICATION",            -1},                    /* 2002 (C/S) */
00148   {"CLOSE",                     CLOSE},                 /* 2002 */
00149   {"CODE",                      CODE},                  /* 2002 */
00150   {"CODE-SET",                  CODE_SET},              /* 2002 */
00151   {"COL",                       COLUMN},                /* 2002 */
00152   {"COLLATING",                 COLLATING},             /* 2002 */
00153   {"COLS",                      COLUMNS},               /* 2002 */
00154   {"COLUMN",                    COLUMN},                /* 2002 */
00155   {"COLUMNS",                   COLUMNS},               /* 2002 */
00156   {"COMMA",                     COMMA},                 /* 2002 */
00157   {"COMMAND-LINE",              COMMAND_LINE},          /* extension */
00158   {"COMMIT",                    COMMIT},                /* extension */
00159   {"COMMON",                    COMMON},                /* 2002 */
00160   {"COMMUNICATION",             -1},                    /* 2002 */
00161   {"COMP",                      COMP},                  /* 2002 */
00162 #ifdef  __MVS__ /* EBCDIC! */
00163   {"COMP-X",                    COMP_X},                /* extension */
00164 #endif
00165   {"COMP-1",                    COMP_1},                /* extension */
00166   {"COMP-2",                    COMP_2},                /* extension */
00167   {"COMP-3",                    COMP_3},                /* extension */
00168   {"COMP-4",                    COMP_4},                /* extension */
00169   {"COMP-5",                    COMP_5},                /* extension */
00170 #ifndef __MVS__
00171   {"COMP-X",                    COMP_X},                /* extension */
00172 #endif
00173   {"COMPUTATIONAL",             COMP},                  /* 2002 */
00174 #ifdef  __MVS__ /* EBCDIC! */
00175   {"COMPUTATIONAL-X",           COMP_X},                /* extension */
00176 #endif
00177   {"COMPUTATIONAL-1",           COMP_1},                /* extension */
00178   {"COMPUTATIONAL-2",           COMP_2},                /* extension */
00179   {"COMPUTATIONAL-3",           COMP_3},                /* extension */
00180   {"COMPUTATIONAL-4",           COMP_4},                /* extension */
00181   {"COMPUTATIONAL-5",           COMP_5},                /* extension */
00182 #ifndef __MVS__
00183   {"COMPUTATIONAL-X",           COMP_X},                /* extension */
00184 #endif
00185   {"COMPUTE",                   COMPUTE},               /* 2002 */
00186   {"CONDITION",                 -1},                    /* 2002 */
00187   {"CONFIGURATION",             CONFIGURATION},         /* 2002 */
00188   {"CONSTANT",                  CONSTANT},              /* 2002 */
00189   {"CONTAINS",                  CONTAINS},              /* 2002 */
00190   {"CONTENT",                   CONTENT},               /* 2002 */
00191   {"CONTINUE",                  CONTINUE},              /* 2002 */
00192   {"CONTROL",                   CONTROL},               /* 2002 */
00193   {"CONTROLS",                  CONTROL},               /* 2002 */
00194   {"CONVERTING",                CONVERTING},            /* 2002 */
00195   {"COPY",                      0},                     /* 2002 */
00196   {"CORR",                      CORRESPONDING},         /* 2002 */
00197   {"CORRESPONDING",             CORRESPONDING},         /* 2002 */
00198   {"COUNT",                     COUNT},                 /* 2002 */
00199   {"CRT",                       CRT},                   /* 2002 */
00200   {"CURRENCY",                  CURRENCY},              /* 2002 */
00201   {"CURSOR",                    CURSOR},                /* 2002 */
00202   {"CYCLE",                     CYCLE},                 /* 2002 (C/S) */
00203   {"DATA",                      DATA},                  /* 2002 */
00204   {"DATA-POINTER",              -1},                    /* 2002 */
00205   {"DATE",                      DATE},                  /* 2002 */
00206   {"DAY",                       DAY},                   /* 2002 */
00207   {"DAY-OF-WEEK",               DAY_OF_WEEK},           /* 2002 */
00208   {"DE",                        DETAIL},                /* 2002 */
00209   {"DEBUGGING",                 DEBUGGING},             /* 2002 */
00210   {"DECIMAL-POINT",             DECIMAL_POINT},         /* 2002 */
00211   {"DECLARATIVES",              DECLARATIVES},          /* 2002 */
00212   {"DEFAULT",                   DEFAULT},               /* 2002 */
00213   {"DELETE",                    DELETE},                /* 2002 */
00214   {"DELIMITED",                 DELIMITED},             /* 2002 */
00215   {"DELIMITER",                 DELIMITER},             /* 2002 */
00216   {"DEPENDING",                 DEPENDING},             /* 2002 */
00217   {"DESCENDING",                DESCENDING},            /* 2002 */
00218   {"DESTINATION",               -1},                    /* 2002 */
00219   {"DETAIL",                    DETAIL},                /* 2002 */
00220   {"DISABLE",                   -1},                    /* 2002 */
00221   {"DISK",                      DISK},                  /* extension */
00222   {"DISPLAY",                   DISPLAY},               /* 2002 */
00223   {"DIVIDE",                    DIVIDE},                /* 2002 */
00224   {"DIVISION",                  DIVISION},              /* 2002 */
00225   {"DOWN",                      DOWN},                  /* 2002 */
00226   {"DUPLICATES",                DUPLICATES},            /* 2002 */
00227   {"DYNAMIC",                   DYNAMIC},               /* 2002 */
00228   {"EBCDIC",                    EBCDIC},                /* extension */
00229   {"EC",                        -1},                    /* 2002 */
00230   {"EGI",                       -1},                    /* 2002 */
00231   {"ELSE",                      ELSE},                  /* 2002 */
00232   {"EMI",                       -1},                    /* 2002 */
00233   {"ENABLE",                    -1},                    /* 2002 */
00234   {"END",                       END},                   /* 2002 */
00235   {"END-ACCEPT",                END_ACCEPT},            /* 2002 */
00236   {"END-ADD",                   END_ADD},               /* 2002 */
00237   {"END-CALL",                  END_CALL},              /* 2002 */
00238   {"END-COMPUTE",               END_COMPUTE},           /* 2002 */
00239   {"END-DELETE",                END_DELETE},            /* 2002 */
00240   {"END-DISPLAY",               END_DISPLAY},           /* 2002 */
00241   {"END-DIVIDE",                END_DIVIDE},            /* 2002 */
00242   {"END-EVALUATE",              END_EVALUATE},          /* 2002 */
00243   {"END-IF",                    END_IF},                /* 2002 */
00244   {"END-MULTIPLY",              END_MULTIPLY},          /* 2002 */
00245   {"END-OF-PAGE",               EOP},                   /* 2002 */
00246   {"END-PERFORM",               END_PERFORM},           /* 2002 */
00247   {"END-READ",                  END_READ},              /* 2002 */
00248   {"END-RECEIVE",               -1},                    /* 2002 */
00249   {"END-RETURN",                END_RETURN},            /* 2002 */
00250   {"END-REWRITE",               END_REWRITE},           /* 2002 */
00251   {"END-SEARCH",                END_SEARCH},            /* 2002 */
00252   {"END-START",                 END_START},             /* 2002 */
00253   {"END-STRING",                END_STRING},            /* 2002 */
00254   {"END-SUBTRACT",              END_SUBTRACT},          /* 2002 */
00255   {"END-UNSTRING",              END_UNSTRING},          /* 2002 */
00256   {"END-WRITE",                 END_WRITE},             /* 2002 */
00257   {"ENTRY",                     ENTRY},                 /* extension */
00258   {"ENTRY-CONVENTION",          -1},                    /* 2002 (C/S) */
00259   {"ENVIRONMENT",               ENVIRONMENT},           /* 2002 */
00260   {"ENVIRONMENT-NAME",          ENVIRONMENT_NAME},      /* extension */
00261   {"ENVIRONMENT-VALUE",         ENVIRONMENT_VALUE},     /* extension */
00262   {"EO",                        -1},                    /* 2002 */
00263   {"EOL",                       EOL},                   /* 2002 (C/S) */
00264   {"EOP",                       EOP},                   /* 2002 */
00265   {"EOS",                       EOS},                   /* 2002 (C/S) */
00266   {"EQUAL",                     EQUAL},                 /* 2002 */
00267   {"EQUALS",                    EQUALS},                /* extension */
00268   {"ERASE",                     ERASE},                 /* 2002 (C/S) */
00269   {"ERROR",                     ERROR},                 /* 2002 */
00270   {"ESCAPE",                    ESCAPE},                /* extension */
00271   {"ESI",                       -1},                    /* 2002 */
00272   {"EVALUATE",                  EVALUATE},              /* 2002 */
00273   {"EXCEPTION",                 EXCEPTION},             /* 2002 */
00274   {"EXCEPTION-OBJECT",          -1},                    /* 2002 */
00275   {"EXCLUSIVE",                 EXCLUSIVE},             /* extension */
00276   {"EXIT",                      EXIT},                  /* 2002 */
00277   {"EXPANDS",                   -1},                    /* 2002 (C/S) */
00278   {"EXTEND",                    EXTEND},                /* 2002 */
00279   {"EXTERNAL",                  EXTERNAL},              /* 2002 */
00280   {"FACTORY",                   -1},                    /* 2002 */
00281   {"FALSE",                     TOK_FALSE},             /* 2002 */
00282   {"FD",                        FD},                    /* 2002 */
00283   {"FILE",                      TOK_FILE},              /* 2002 */
00284   {"FILE-CONTROL",              FILE_CONTROL},          /* 2002 */
00285   {"FILE-ID",                   FILE_ID},               /* extension */
00286   {"FILLER",                    FILLER},                /* 2002 */
00287   {"FINAL",                     FINAL},                 /* 2002 */
00288   {"FIRST",                     FIRST},                 /* 2002 */
00289   {"FLOAT-BINARY-16",           -1},                    /* 2008 */
00290   {"FLOAT-BINARY-34",           -1},                    /* 2008 */
00291   {"FLOAT-BINARY-7",            -1},                    /* 2008 */
00292   {"FLOAT-DECIMAL-16",          -1},                    /* 2008 */
00293   {"FLOAT-DECIMAL-34",          -1},                    /* 2008 */
00294   {"FLOAT-EXTENDED",            -1},                    /* 2002 */
00295   {"FLOAT-LONG",                COMP_2},                /* 2002 */
00296   {"FLOAT-SHORT",               COMP_1},                /* 2002 */
00297   {"FOOTING",                   FOOTING},               /* 2002 */
00298   {"FOR",                       FOR},                   /* 2002 */
00299   {"FOREGROUND-COLOR",          FOREGROUND_COLOR},      /* 2002 (C/S) */
00300   {"FOREVER",                   FOREVER},               /* 2002 (C/S) */
00301   {"FORMAT",                    -1},                    /* 2002 */
00302   {"FREE",                      FREE},                  /* 2002 */
00303   {"FROM",                      FROM},                  /* 2002 */
00304   {"FULL",                      FULL},                  /* 2002 (C/S) */
00305   {"FUNCTION",                  FUNCTION},              /* 2002 */
00306   {"FUNCTION-ID",               FUNCTION_ID},           /* 2002 */
00307   {"FUNCTION-POINTER",          -1},                    /* 2008 */
00308   {"GENERATE",                  GENERATE},              /* 2002 */
00309   {"GET",                       -1},                    /* 2002 */
00310   {"GIVING",                    GIVING},                /* 2002 */
00311   {"GLOBAL",                    GLOBAL},                /* 2002 */
00312   {"GO",                        GO},                    /* 2002 */
00313   {"GOBACK",                    GOBACK},                /* 2002 */
00314   {"GREATER",                   GREATER},               /* 2002 */
00315   {"GROUP",                     GROUP},                 /* 2002 */
00316   {"GROUP-USAGE",               -1},                    /* 2002 */
00317   {"HEADING",                   HEADING},               /* 2002 */
00318   {"HIGH-VALUE",                HIGH_VALUE},            /* 2002 */
00319   {"HIGH-VALUES",               HIGH_VALUE},            /* 2002 */
00320   {"HIGHLIGHT",                 HIGHLIGHT},             /* 2002 (C/S) */
00321   {"I-O",                       I_O},                   /* 2002 */
00322   {"I-O-CONTROL",               I_O_CONTROL},           /* 2002 */
00323   {"ID",                        IDENTIFICATION},        /* extension */
00324   {"IDENTIFICATION",            IDENTIFICATION},        /* 2002 */
00325   {"IF",                        IF},                    /* 2002 */
00326   {"IGNORE",                    IGNORE},                /* extension */
00327   {"IGNORING",                  IGNORING},              /* 2002 (C/S) */
00328   {"IMPLEMENTS",                -1},                    /* 2002 (C/S) */
00329   {"IN",                        IN},                    /* 2002 */
00330   {"INDEX",                     INDEX},                 /* 2002 */
00331   {"INDEXED",                   INDEXED},               /* 2002 */
00332   {"INDICATE",                  INDICATE},              /* 2002 */
00333   {"INFINITY",                  -1},                    /* 2002 */
00334   {"INHERITS",                  -1},                    /* 2002 */
00335   {"INITIAL",                   TOK_INITIAL},           /* 2002 */
00336   {"INITIALIZE",                INITIALIZE},            /* 2002 */
00337   {"INITIALIZED",               INITIALIZED},           /* 2002 */
00338   {"INITIATE",                  INITIATE},              /* 2002 */
00339   {"INPUT",                     INPUT},                 /* 2002 */
00340   {"INPUT-OUTPUT",              INPUT_OUTPUT},          /* 2002 */
00341   {"INSPECT",                   INSPECT},               /* 2002 */
00342   {"INTERFACE",                 -1},                    /* 2002 */
00343   {"INTERFACE-ID",              -1},                    /* 2002 */
00344   {"INTO",                      INTO},                  /* 2002 */
00345   {"INTRINSIC",                 INTRINSIC},             /* 2002 (C/S) */
00346   {"INVALID",                   INVALID},               /* 2002 */
00347   {"INVOKE",                    -1},                    /* 2002 */
00348   {"IS",                        IS},                    /* 2002 */
00349   {"JUST",                      JUSTIFIED},             /* 2002 */
00350   {"JUSTIFIED",                 JUSTIFIED},             /* 2002 */
00351   {"KEY",                       KEY},                   /* 2002 */
00352   {"LABEL",                     LABEL},                 /* 85 */
00353   {"LAST",                      LAST},                  /* 2002 */
00354   {"LC_ALL",                    -1},                    /* 2002 (C/S) */
00355   {"LC_COLLATE",                -1},                    /* 2002 (C/S) */
00356   {"LC_CTYPE",                  -1},                    /* 2002 (C/S) */
00357   {"LC_MESSAGES",               -1},                    /* 2002 (C/S) */
00358   {"LC_MONETARY",               -1},                    /* 2002 (C/S) */
00359   {"LC_NUMERIC",                -1},                    /* 2002 (C/S) */
00360   {"LC_TIME",                   -1},                    /* 2002 (C/S) */
00361   {"LEADING",                   LEADING},               /* 2002 */
00362   {"LEFT",                      LEFT},                  /* 2002 */
00363   {"LENGTH",                    LENGTH},                /* 2002 */
00364   {"LESS",                      LESS},                  /* 2002 */
00365   {"LIMIT",                     LIMIT},                 /* 2002 */
00366   {"LIMITS",                    LIMITS},                /* 2002 */
00367   {"LINAGE",                    LINAGE},                /* 2002 */
00368   {"LINAGE-COUNTER",            LINAGE_COUNTER},        /* 2002 */
00369   {"LINE",                      LINE},                  /* 2002 */
00370   {"LINE-COUNTER",              -1},                    /* 2002 */
00371   {"LINES",                     LINES},                 /* 2002 */
00372   {"LINKAGE",                   LINKAGE},               /* 2002 */
00373   {"LOCAL-STORAGE",             LOCAL_STORAGE},         /* 2002 */
00374   {"LOCALE",                    LOCALE},                /* 2002 */
00375   {"LOCK",                      LOCK},                  /* 2002 */
00376   {"LOW-VALUE",                 LOW_VALUE},             /* 2002 */
00377   {"LOW-VALUES",                LOW_VALUE},             /* 2002 */
00378   {"LOWLIGHT",                  LOWLIGHT},              /* 2002 (C/S) */
00379   {"MANUAL",                    MANUAL},                /* 2002 (C/S) */
00380   {"MEMORY",                    MEMORY},                /* 85 */
00381   {"MERGE",                     MERGE},                 /* 2002 */
00382   {"MESSAGE",                   -1},                    /* 2002 */
00383   {"METHOD",                    -1},                    /* 2002 */
00384   {"METHOD-ID",                 -1},                    /* 2002 */
00385   {"MINUS",                     MINUS},                 /* 2002 */
00386   {"MODE",                      MODE},                  /* 2002 */
00387   {"MOVE",                      MOVE},                  /* 2002 */
00388   {"MULTIPLE",                  MULTIPLE},              /* 2002 (C/S) */
00389   {"MULTIPLY",                  MULTIPLY},              /* 2002 */
00390   {"NATIONAL",                  NATIONAL},              /* 2002 */
00391   {"NATIONAL-EDITED",           NATIONAL_EDITED},       /* 2002 */
00392   {"NATIVE",                    NATIVE},                /* 2002 */
00393   {"NEGATIVE",                  NEGATIVE},              /* 2002 */
00394   {"NESTED",                    -1},                    /* 2002 */
00395   {"NEXT",                      NEXT},                  /* 2002 */
00396   {"NO",                        NO},                    /* 2002 */
00397   {"NONE",                      -1},                    /* 2002 (C/S) */
00398   {"NORMAL",                    -1},                    /* 2002 (C/S) */
00399   {"NOT",                       NOT},                   /* 2002 */
00400   {"NULL",                      TOK_NULL},              /* 2002 */
00401   {"NULLS",                     TOK_NULL},              /* extension */
00402   {"NUMBER",                    NUMBER},                /* 2002 */
00403   {"NUMBERS",                   NUMBER},                /* 2002 (C/S) */
00404   {"NUMERIC",                   NUMERIC},               /* 2002 */
00405   {"NUMERIC-EDITED",            NUMERIC_EDITED},        /* 2002 */
00406   {"OBJECT",                    -1},                    /* 2002 */
00407   {"OBJECT-COMPUTER",           OBJECT_COMPUTER},       /* 2002 */
00408   {"OBJECT-REFERENCE",          -1},                    /* 2002 */
00409   {"OCCURS",                    OCCURS},                /* 2002 */
00410   {"OF",                        OF},                    /* 2002 */
00411   {"OFF",                       OFF},                   /* 2002 */
00412   {"OMITTED",                   OMITTED},               /* 2002 */
00413   {"ON",                        ON},                    /* 2002 */
00414   {"ONLY",                      ONLY},                  /* 2002 (C/S) */
00415   {"OPEN",                      OPEN},                  /* 2002 */
00416   {"OPTIONAL",                  OPTIONAL},              /* 2002 */
00417   {"OPTIONS",                   -1},                    /* 2002 */
00418   {"OR",                        OR},                    /* 2002 */
00419   {"ORDER",                     ORDER},                 /* 2002 */
00420   {"ORGANIZATION",              ORGANIZATION},          /* 2002 */
00421   {"OTHER",                     OTHER},                 /* 2002 */
00422   {"OUTPUT",                    OUTPUT},                /* 2002 */
00423   {"OVERFLOW",                  OVERFLOW},              /* 2002 */
00424   {"OVERLINE",                  OVERLINE},              /* extension */
00425   {"OVERRIDE",                  -1},                    /* 2002 */
00426   {"PACKED-DECIMAL",            PACKED_DECIMAL},        /* 2002 */
00427   {"PADDING",                   PADDING},               /* 2002 */
00428   {"PAGE",                      PAGE},                  /* 2002 */
00429   {"PAGE-COUNTER",              -1},                    /* 2002 */
00430   {"PARAGRAPH",                 PARAGRAPH},             /* 2002 (C/S) */
00431   {"PERFORM",                   PERFORM},               /* 2002 */
00432   {"PF",                        PAGE_FOOTING},          /* 2002 */
00433   {"PH",                        PAGE_HEADING},          /* 2002 */
00434   {"PIC",                       0},                     /* 2002 */
00435   {"PICTURE",                   0},                     /* 2002 */
00436   {"PLUS",                      PLUS},                  /* 2002 */
00437   {"POINTER",                   POINTER},               /* 2002 */
00438   {"POSITION",                  POSITION},              /* 85 */
00439   {"POSITIVE",                  POSITIVE},              /* 2002 */
00440   {"PRESENT",                   PRESENT},               /* 2002 */
00441   {"PREVIOUS",                  PREVIOUS},              /* 2002 (C/S) */
00442   {"PRINTER",                   PRINTER},               /* extension */
00443   {"PRINTING",                  PRINTING},              /* 2002 */
00444   {"PROCEDURE",                 PROCEDURE},             /* 2002 */
00445   {"PROCEDURE-POINTER",         PROGRAM_POINTER},       /* extension */
00446   {"PROCEDURES",                PROCEDURES},            /* extension */
00447   {"PROCEED",                   PROCEED},               /* 85 */
00448   {"PROGRAM",                   PROGRAM},               /* 2002 */
00449   {"PROGRAM-ID",                PROGRAM_ID},            /* 2002 */
00450   {"PROGRAM-POINTER",           PROGRAM_POINTER},       /* 2002 */
00451   {"PROMPT",                    PROMPT},                /* extension */
00452   {"PROPERTY",                  -1},                    /* 2002 */
00453   {"PROTOTYPE",                 -1},                    /* 2002 */
00454   {"PURGE",                     -1},                    /* 2002 */
00455   {"QUEUE",                     -1},                    /* 2002 */
00456   {"QUOTE",                     QUOTE},                 /* 2002 */
00457   {"QUOTES",                    QUOTE},                 /* 2002 */
00458   {"RAISE",                     -1},                    /* 2002 */
00459   {"RAISING",                   -1},                    /* 2002 */
00460   {"RANDOM",                    RANDOM},                /* 2002 */
00461   {"RD",                        RD},                    /* 2002 */
00462   {"READ",                      READ},                  /* 2002 */
00463   {"RECEIVE",                   -1},                    /* 2002 */
00464   {"RECORD",                    RECORD},                /* 2002 */
00465   {"RECORDING",                 RECORDING},             /* extension */
00466   {"RECORDS",                   RECORDS},               /* 2002 */
00467   {"RECURSIVE",                 RECURSIVE},             /* 2002 (C/S) */
00468   {"REDEFINES",                 REDEFINES},             /* 2002 */
00469   {"REEL",                      REEL},                  /* 2002 */
00470   {"REFERENCE",                 REFERENCE},             /* 2002 */
00471   {"RELATION",                  -1},                    /* 2002 (C/S) */
00472   {"RELATIVE",                  RELATIVE},              /* 2002 */
00473   {"RELEASE",                   RELEASE},               /* 2002 */
00474   {"REMAINDER",                 REMAINDER},             /* 2002 */
00475   {"REMOVAL",                   REMOVAL},               /* 2002 */
00476   {"RENAMES",                   RENAMES},               /* 2002 */
00477   {"REPLACE",                   -1},                    /* 2002 */
00478   {"REPLACING",                 REPLACING},             /* 2002 */
00479   {"REPORT",                    REPORT},                /* 2002 */
00480   {"REPORTING",                 REPORTING},             /* 2002 */
00481   {"REPORTS",                   REPORTS},               /* 2002 */
00482   {"REPOSITORY",                REPOSITORY},            /* 2002 */
00483   {"REPRESENTS-NOT-A-NUMBER",   -1},                    /* 2008 */
00484   {"REQUIRED",                  REQUIRED},              /* 2002 (C/S) */
00485   {"RESERVE",                   RESERVE},               /* 2002 */
00486   {"RESET",                     -1},                    /* 2002 */
00487   {"RESUME",                    -1},                    /* 2002 */
00488   {"RETRY",                     -1},                    /* 2002 */
00489   {"RETURN",                    RETURN},                /* 2002 */
00490   {"RETURNING",                 RETURNING},             /* 2002 */
00491   {"REVERSE-VIDEO",             REVERSE_VIDEO},         /* 2002 (C/S) */
00492   {"REWIND",                    REWIND},                /* 2002 */
00493   {"REWRITE",                   REWRITE},               /* 2002 */
00494   {"RF",                        REPORT_FOOTING},        /* 2002 */
00495   {"RH",                        REPORT_HEADING},        /* 2002 */
00496   {"RIGHT",                     RIGHT},                 /* 2002 */
00497   {"ROLLBACK",                  ROLLBACK},              /* extension */
00498   {"ROUNDED",                   ROUNDED},               /* 2002 */
00499   {"RUN",                       RUN},                   /* 2002 */
00500   {"SAME",                      SAME},                  /* 2002 */
00501   {"SCREEN",                    SCREEN},                /* 2002 */
00502   {"SCROLL",                    SCROLL},                /* extension */
00503   {"SD",                        SD},                    /* 2002 */
00504   {"SEARCH",                    SEARCH},                /* 2002 */
00505   {"SECONDS",                   -1},                    /* 2002 (C/S) */
00506   {"SECTION",                   SECTION},               /* 2002 */
00507   {"SECURE",                    SECURE},                /* 2002 (C/S) */
00508   {"SEGMENT",                   -1},                    /* 2002 */
00509   {"SEGMENT-LIMIT",             SEGMENT_LIMIT},         /* 85 */
00510   {"SELECT",                    SELECT},                /* 2002 */
00511   {"SELF",                      -1},                    /* 2002 */
00512   {"SEND",                      -1},                    /* 2002 */
00513   {"SENTENCE",                  SENTENCE},              /* 2002 */
00514   {"SEPARATE",                  SEPARATE},              /* 2002 */
00515   {"SEQUENCE",                  SEQUENCE},              /* 2002 */
00516   {"SEQUENTIAL",                SEQUENTIAL},            /* 2002 */
00517   {"SET",                       SET},                   /* 2002 */
00518   {"SHARING",                   SHARING},               /* 2002 */
00519   {"SIGN",                      SIGN},                  /* 2002 */
00520   {"SIGNED",                    SIGNED},                /* 2002 (C/S) */
00521   {"SIGNED-INT",                SIGNED_INT},            /* extension */
00522   {"SIGNED-LONG",               SIGNED_LONG},           /* extension */
00523   {"SIGNED-SHORT",              SIGNED_SHORT},          /* extension */
00524   {"SIZE",                      SIZE},                  /* 2002 */
00525   {"SORT",                      SORT},                  /* 2002 */
00526   {"SORT-MERGE",                SORT_MERGE},            /* 2002 */
00527   {"SOURCE",                    SOURCE},                /* 2002 */
00528   {"SOURCE-COMPUTER",           SOURCE_COMPUTER},       /* 2002 */
00529   {"SOURCES",                   -1},                    /* 2002 */
00530   {"SPACE",                     SPACE},                 /* 2002 */
00531   {"SPACES",                    SPACE},                 /* 2002 */
00532   {"SPECIAL-NAMES",             SPECIAL_NAMES},         /* 2002 */
00533   {"STANDARD",                  STANDARD},              /* 2002 */
00534   {"STANDARD-1",                STANDARD_1},            /* 2002 */
00535   {"STANDARD-2",                STANDARD_2},            /* 2002 */
00536   {"START",                     START},                 /* 2002 */
00537   {"STATEMENT",                 -1},                    /* 2002 (C/S) */
00538   {"STATUS",                    STATUS},                /* 2002 */
00539   {"STEP",                      -1},                    /* 2002 (C/S) */
00540   {"STOP",                      STOP},                  /* 2002 */
00541   {"STRING",                    STRING},                /* 2002 */
00542   {"STRONG",                    -1},                    /* 2002 (C/S) */
00543   {"SUB-QUEUE-1",               -1},                    /* 2002 */
00544   {"SUB-QUEUE-2",               -1},                    /* 2002 */
00545   {"SUB-QUEUE-3",               -1},                    /* 2002 */
00546   {"SUBTRACT",                  SUBTRACT},              /* 2002 */
00547   {"SUM",                       SUM},                   /* 2002 */
00548   {"SUPER",                     -1},                    /* 2002 */
00549   {"SUPPRESS",                  SUPPRESS},              /* 2002 */
00550   {"SYMBOL",                    -1},                    /* 2002 (C/S) */
00551   {"SYMBOLIC",                  SYMBOLIC},              /* 2002 */
00552   {"SYNC",                      SYNCHRONIZED},          /* 2002 */
00553   {"SYNCHRONIZED",              SYNCHRONIZED},          /* 2002 */
00554   {"SYSTEM-DEFAULT",            -1},                    /* 2002 */
00555   {"TABLE",                     -1},                    /* 2002 */
00556   {"TALLYING",                  TALLYING},              /* 2002 */
00557   {"TAPE",                      TAPE},                  /* 85 */
00558   {"TERMINAL",                  -1},                    /* 2002 */
00559   {"TERMINATE",                 TERMINATE},             /* 2002 */
00560   {"TEST",                      TEST},                  /* 2002 */
00561   {"TEXT",                      -1},                    /* 2002 */
00562   {"THAN",                      THAN},                  /* 2002 */
00563   {"THEN",                      THEN},                  /* 2002 */
00564   {"THROUGH",                   THRU},                  /* 2002 */
00565   {"THRU",                      THRU},                  /* 2002 */
00566   {"TIME",                      TIME},                  /* 2002 */
00567   {"TIMES",                     TIMES},                 /* 2002 */
00568   {"TO",                        TO},                    /* 2002 */
00569   {"TOP",                       TOP},                   /* 2002 */
00570   {"TRAILING",                  TRAILING},              /* 2002 */
00571   {"TRANSFORM",                 TRANSFORM},             /* OSVS */
00572   {"TRUE",                      TOK_TRUE},              /* 2002 */
00573   {"TYPE",                      TYPE},                  /* 2002 */
00574   {"TYPEDEF",                   -1},                    /* 2002 */
00575   {"UCS-4",                     -1},                    /* 2002 (C/S) */
00576   {"UNDERLINE",                 UNDERLINE},             /* 2002 (C/S) */
00577   {"UNIT",                      UNIT},                  /* 2002 */
00578   {"UNIVERSAL",                 -1},                    /* 2002 */
00579   {"UNLOCK",                    UNLOCK},                /* 2002 */
00580   {"UNSIGNED",                  UNSIGNED},              /* 2002 (C/S) */
00581   {"UNSIGNED-INT",              UNSIGNED_INT},          /* extension */
00582   {"UNSIGNED-LONG",             UNSIGNED_LONG},         /* extension */
00583   {"UNSIGNED-SHORT",            UNSIGNED_SHORT},        /* extension */
00584   {"UNSTRING",                  UNSTRING},              /* 2002 */
00585   {"UNTIL",                     UNTIL},                 /* 2002 */
00586   {"UP",                        UP},                    /* 2002 */
00587   {"UPDATE",                    UPDATE},                /* extension */
00588   {"UPON",                      UPON},                  /* 2002 */
00589   {"USAGE",                     USAGE},                 /* 2002 */
00590   {"USE",                       USE},                   /* 2002 */
00591   {"USER-DEFAULT",              -1},                    /* 2002 */
00592   {"USING",                     USING},                 /* 2002 */
00593   {"UTF-16",                    -1},                    /* 2002 (C/S) */
00594   {"UTF-8",                     -1},                    /* 2002 (C/S) */
00595   {"VAL-STATUS",                -1},                    /* 2002 */
00596   {"VALID",                     -1},                    /* 2002 */
00597   {"VALIDATE",                  -1},                    /* 2002 */
00598   {"VALIDATE-STATUS",           -1},                    /* 2002 */
00599   {"VALUE",                     VALUE},                 /* 2002 */
00600   {"VALUES",                    VALUE},                 /* 2002 */
00601   {"VARYING",                   VARYING},               /* 2002 */
00602   {"WAIT",                      WAIT},                  /* extension */
00603   {"WHEN",                      WHEN},                  /* 2002 */
00604   {"WITH",                      WITH},                  /* 2002 */
00605   {"WORDS",                     WORDS},                 /* 85 */
00606   {"WORKING-STORAGE",           WORKING_STORAGE},       /* 2002 */
00607   {"WRITE",                     WRITE},                 /* 2002 */
00608   {"YYYYDDD",                   YYYYDDD},               /* 2002 (C/S) */
00609   {"YYYYMMDD",                  YYYYMMDD},              /* 2002 (C/S) */
00610   {"ZERO",                      ZERO},                  /* 2002 */
00611   {"ZEROES",                    ZERO},                  /* 2002 */
00612   {"ZEROS",                     ZERO},                  /* 2002 */
00613 };
00614 
00615 #define NUM_RESERVED_WORDS      sizeof (reserved_words) / sizeof (struct reserved)
00616 
00617 /* FUNCTION List */
00618 /* Name, Arguments, Implemented, Enum intrinsic, Routine, Category, Can refmod */
00619 
00620 static const struct cb_intrinsic_table function_list[] = {
00621   { "ABS",                              1, 1, CB_INTR_ABS,
00622                                         "cob_intr_abs",
00623                                         CB_CATEGORY_NUMERIC, 0 },
00624   { "ACOS",                             1, 1, CB_INTR_ACOS,
00625                                         "cob_intr_acos",
00626                                         CB_CATEGORY_NUMERIC, 0 },
00627   { "ANNUITY",                          2, 1, CB_INTR_ANNUITY,
00628                                         "cob_intr_annuity",
00629                                         CB_CATEGORY_NUMERIC, 0 },
00630   { "ASIN",                             1, 1, CB_INTR_ASIN,
00631                                         "cob_intr_asin",
00632                                         CB_CATEGORY_NUMERIC, 0 },
00633   { "ATAN",                             1, 1, CB_INTR_ATAN,
00634                                         "cob_intr_atan",
00635                                         CB_CATEGORY_NUMERIC, 0 },
00636   { "BOOLEAN-OF-INTEGER",               2, 0, CB_INTR_BOOLEAN_OF_INTEGER,
00637                                         NULL,
00638                                         CB_CATEGORY_NUMERIC, 0 },
00639   { "BYTE-LENGTH",                      1, 1, CB_INTR_BYTE_LENGTH,
00640                                         "cob_intr_length",
00641                                         CB_CATEGORY_NUMERIC, 0 },
00642   { "CHAR",                             1, 1, CB_INTR_CHAR,
00643                                         "cob_intr_char",
00644                                         CB_CATEGORY_ALPHANUMERIC, 0 },
00645   { "CHAR-NATIONAL",                    1, 0, CB_INTR_CHAR_NATIONAL,
00646                                         NULL,
00647                                         CB_CATEGORY_ALPHANUMERIC, 0 },
00648   { "COMBINED-DATETIME",                2, 1, CB_INTR_COMBINED_DATETIME,
00649                                         "cob_intr_combined_datetime",
00650                                         CB_CATEGORY_NUMERIC, 0 },
00651   { "CONCATENATE",                      -1, 1, CB_INTR_CONCATENATE,
00652                                         "cob_intr_concatenate",
00653                                         CB_CATEGORY_ALPHANUMERIC, 1 },
00654   { "COS",                              1, 1, CB_INTR_COS,
00655                                         "cob_intr_cos",
00656                                         CB_CATEGORY_NUMERIC, 0 },
00657   { "CURRENT-DATE",                     0, 1, CB_INTR_CURRENT_DATE,
00658                                         "cob_intr_current_date",
00659                                         CB_CATEGORY_ALPHANUMERIC, 1 },
00660   { "DATE-OF-INTEGER",                  1, 1, CB_INTR_DATE_OF_INTEGER,
00661                                         "cob_intr_date_of_integer",
00662                                         CB_CATEGORY_NUMERIC, 0 },
00663   { "DATE-TO-YYYYMMDD",                 -1, 1, CB_INTR_DATE_TO_YYYYMMDD,
00664                                         "cob_intr_date_to_yyyymmdd",
00665                                         CB_CATEGORY_NUMERIC, 0 },
00666   { "DAY-OF-INTEGER",                   1, 1, CB_INTR_DAY_OF_INTEGER,
00667                                         "cob_intr_day_of_integer",
00668                                         CB_CATEGORY_NUMERIC, 0 },
00669   { "DAY-TO-YYYYDDD",                   -1, 1, CB_INTR_DAY_TO_YYYYDDD,
00670                                         "cob_intr_day_to_yyyyddd",
00671                                         CB_CATEGORY_NUMERIC, 0 },
00672   { "DISPLAY-OF",                       -1, 0, CB_INTR_DISPLAY_OF,
00673                                         NULL,
00674                                         CB_CATEGORY_ALPHANUMERIC, 0 },
00675   { "E",                                0, 1, CB_INTR_E,
00676                                         NULL,
00677                                         CB_CATEGORY_NUMERIC, 0 },
00678   { "EXCEPTION-FILE",                   0, 1, CB_INTR_EXCEPTION_FILE,
00679                                         "cob_intr_exception_file",
00680                                         CB_CATEGORY_ALPHANUMERIC, 0 },
00681   { "EXCEPTION-FILE-N",                 0, 0, CB_INTR_EXCEPTION_FILE_N,
00682                                         NULL,
00683                                         CB_CATEGORY_ALPHANUMERIC, 0 },
00684   { "EXCEPTION-LOCATION",               0, 1, CB_INTR_EXCEPTION_LOCATION,
00685                                         "cob_intr_exception_location",
00686                                         CB_CATEGORY_ALPHANUMERIC, 0 },
00687   { "EXCEPTION-LOCATION-N",             0, 0, CB_INTR_EXCEPTION_LOCATION_N,
00688                                         NULL,
00689                                         CB_CATEGORY_ALPHANUMERIC, 0 },
00690   { "EXCEPTION-STATEMENT",              0, 1, CB_INTR_EXCEPTION_STATEMENT,
00691                                         "cob_intr_exception_statement",
00692                                         CB_CATEGORY_ALPHANUMERIC, 0 },
00693   { "EXCEPTION-STATUS",                 0, 1, CB_INTR_EXCEPTION_STATUS,
00694                                         "cob_intr_exception_status",
00695                                         CB_CATEGORY_ALPHANUMERIC, 0 },
00696   { "EXP",                              1, 1, CB_INTR_EXP,
00697                                         "cob_intr_exp",
00698                                         CB_CATEGORY_NUMERIC, 0 },
00699   { "EXP10",                            1, 1, CB_INTR_EXP10,
00700                                         "cob_intr_exp10",
00701                                         CB_CATEGORY_NUMERIC, 0 },
00702   { "FACTORIAL",                        1, 1, CB_INTR_FACTORIAL,
00703                                         "cob_intr_factorial",
00704                                         CB_CATEGORY_NUMERIC, 0 },
00705   { "FRACTION-PART",                    1, 1, CB_INTR_FRACTION_PART,
00706                                         "cob_intr_fraction_part",
00707                                         CB_CATEGORY_NUMERIC, 0 },
00708   { "HIGHEST-ALGEBRAIC",                1, 0, CB_INTR_HIGHEST_ALGEBRAIC,
00709                                         NULL,
00710                                         CB_CATEGORY_NUMERIC, 0 },
00711   { "INTEGER",                          1, 1, CB_INTR_INTEGER,
00712                                         "cob_intr_integer",
00713                                         CB_CATEGORY_NUMERIC, 0 },
00714   { "INTEGER-OF-BOOLEAN",               1, 0, CB_INTR_INTEGER_OF_BOOLEAN,
00715                                         NULL,
00716                                         CB_CATEGORY_NUMERIC, 0 },
00717   { "INTEGER-OF-DATE",                  1, 1, CB_INTR_INTEGER_OF_DATE,
00718                                         "cob_intr_integer_of_date",
00719                                         CB_CATEGORY_NUMERIC, 0 },
00720   { "INTEGER-OF-DAY",                   1, 1, CB_INTR_INTEGER_OF_DAY,
00721                                         "cob_intr_integer_of_day",
00722                                         CB_CATEGORY_NUMERIC, 0 },
00723   { "INTEGER-PART",                     1, 1, CB_INTR_INTEGER_PART,
00724                                         "cob_intr_integer_part",
00725                                         CB_CATEGORY_NUMERIC, 0 },
00726   { "LENGTH",                           1, 1, CB_INTR_LENGTH,
00727                                         "cob_intr_length",
00728                                         CB_CATEGORY_NUMERIC, 0 },
00729   { "LOCALE-COMPARE",                   -1, 0, CB_INTR_LOCALE_COMPARE,
00730                                         NULL,
00731                                         CB_CATEGORY_ALPHANUMERIC, 0 },
00732   { "LOCALE-DATE",                      2, 1, CB_INTR_LOCALE_DATE,
00733                                         "cob_intr_locale_date",
00734                                         CB_CATEGORY_ALPHANUMERIC, 1 },
00735   { "LOCALE-TIME",                      2, 1, CB_INTR_LOCALE_TIME,
00736                                         "cob_intr_locale_time",
00737                                         CB_CATEGORY_ALPHANUMERIC, 1 },
00738   { "LOCALE-TIME-FROM-SECONDS",         2, 1, CB_INTR_LOCALE_TIME_FROM_SECS,
00739                                         "cob_intr_lcl_time_from_secs",
00740                                         CB_CATEGORY_ALPHANUMERIC, 1 },
00741   { "LOG",                              1, 1, CB_INTR_LOG,
00742                                         "cob_intr_log",
00743                                         CB_CATEGORY_NUMERIC, 0 },
00744   { "LOG10",                            1, 1, CB_INTR_LOG10,
00745                                         "cob_intr_log10",
00746                                         CB_CATEGORY_NUMERIC, 0 },
00747   { "LOWER-CASE",                       1, 1, CB_INTR_LOWER_CASE,
00748                                         "cob_intr_lower_case",
00749                                         CB_CATEGORY_ALPHANUMERIC, 1 },
00750   { "LOWEST-ALGEBRAIC",                 1, 0, CB_INTR_LOWEST_ALGEBRAIC,
00751                                         NULL,
00752                                         CB_CATEGORY_NUMERIC, 0 },
00753   { "MAX",                              -1, 1, CB_INTR_MAX,
00754                                         "cob_intr_max",
00755                                         CB_CATEGORY_NUMERIC, 0 },
00756   { "MEAN",                             -1, 1, CB_INTR_MEAN,
00757                                         "cob_intr_mean",
00758                                         CB_CATEGORY_NUMERIC, 0 },
00759   { "MEDIAN",                           -1, 1, CB_INTR_MEDIAN,
00760                                         "cob_intr_median",
00761                                         CB_CATEGORY_NUMERIC, 0 },
00762   { "MIDRANGE",                         -1, 1, CB_INTR_MIDRANGE,
00763                                         "cob_intr_midrange",
00764                                         CB_CATEGORY_NUMERIC, 0 },
00765   { "MIN",                              -1, 1, CB_INTR_MIN,
00766                                         "cob_intr_min",
00767                                         CB_CATEGORY_NUMERIC, 0 },
00768   { "MOD",                              2, 1, CB_INTR_MOD,
00769                                         "cob_intr_mod",
00770                                         CB_CATEGORY_NUMERIC, 0 },
00771   { "NATIONAL-OF",                      -1, 0, CB_INTR_NATIONAL_OF,
00772                                         NULL,
00773                                         CB_CATEGORY_ALPHANUMERIC, 0 },
00774   { "NUMVAL",                           1, 1, CB_INTR_NUMVAL,
00775                                         "cob_intr_numval",
00776                                         CB_CATEGORY_NUMERIC, 0 },
00777   { "NUMVAL-C",                         2, 1, CB_INTR_NUMVAL_C,
00778                                         "cob_intr_numval_c",
00779                                         CB_CATEGORY_NUMERIC, 0 },
00780   { "NUMVAL-F",                         1, 0, CB_INTR_NUMVAL_F,
00781                                         NULL,
00782                                         CB_CATEGORY_NUMERIC, 0 },
00783   { "ORD",                              1, 1, CB_INTR_ORD,
00784                                         "cob_intr_ord",
00785                                         CB_CATEGORY_NUMERIC, 0 },
00786   { "ORD-MAX",                          -1, 1, CB_INTR_ORD_MAX,
00787                                         "cob_intr_ord_max",
00788                                         CB_CATEGORY_NUMERIC, 0 },
00789   { "ORD-MIN",                          -1, 1, CB_INTR_ORD_MIN,
00790                                         "cob_intr_ord_min",
00791                                         CB_CATEGORY_NUMERIC, 0 },
00792   { "PI",                               0, 1, CB_INTR_PI,
00793                                         NULL,
00794                                         CB_CATEGORY_NUMERIC, 0 },
00795   { "PRESENT-VALUE",                    -1, 1, CB_INTR_PRESENT_VALUE,
00796                                         "cob_intr_present_value",
00797                                         CB_CATEGORY_NUMERIC, 0 },
00798   { "RANDOM",                           -1, 1, CB_INTR_RANDOM,
00799                                         "cob_intr_random",
00800                                         CB_CATEGORY_NUMERIC, 0 },
00801   { "RANGE",                            -1, 1, CB_INTR_RANGE,
00802                                         "cob_intr_range",
00803                                         CB_CATEGORY_NUMERIC, 0 },
00804   { "REM",                              2, 1, CB_INTR_REM,
00805                                         "cob_intr_rem",
00806                                         CB_CATEGORY_NUMERIC, 0 },
00807   { "REVERSE",                          1, 1, CB_INTR_REVERSE,
00808                                         "cob_intr_reverse",
00809                                         CB_CATEGORY_ALPHANUMERIC, 1 },
00810   { "SECONDS-FROM-FORMATTED-TIME",      2, 1, CB_INTR_SECONDS_PAST_MIDNIGHT,
00811                                         "cob_intr_seconds_from_formatted_time",
00812                                         CB_CATEGORY_NUMERIC, 0 },
00813   { "SECONDS-PAST-MIDNIGHT",            0, 1, CB_INTR_SECONDS_PAST_MIDNIGHT,
00814                                         "cob_intr_seconds_past_midnight",
00815                                         CB_CATEGORY_NUMERIC, 0 },
00816   { "SIGN",                             1, 1, CB_INTR_SIGN,
00817                                         "cob_intr_sign",
00818                                         CB_CATEGORY_NUMERIC, 0 },
00819   { "SIN",                              1, 1, CB_INTR_SIN,
00820                                         "cob_intr_sin",
00821                                         CB_CATEGORY_NUMERIC, 0 },
00822   { "SQRT",                             1, 1, CB_INTR_SQRT,
00823                                         "cob_intr_sqrt",
00824                                         CB_CATEGORY_NUMERIC, 0 },
00825   { "STANDARD-COMPARE",                 -1, 0, CB_INTR_STANDARD_COMPARE,
00826                                         NULL,
00827                                         CB_CATEGORY_ALPHANUMERIC, 0 },
00828   { "STANDARD-DEVIATION",               -1, 1, CB_INTR_STANDARD_DEVIATION,
00829                                         "cob_intr_standard_deviation",
00830                                         CB_CATEGORY_NUMERIC, 0 },
00831   { "STORED-CHAR-LENGTH",               1, 1, CB_INTR_STORED_CHAR_LENGTH,
00832                                         "cob_intr_stored_char_length",
00833                                         CB_CATEGORY_NUMERIC, 0 },
00834   { "SUBSTITUTE",                       -1, 1, CB_INTR_SUBSTITUTE,
00835                                         "cob_intr_substitute",
00836                                         CB_CATEGORY_ALPHANUMERIC, 1 },
00837   { "SUBSTITUTE-CASE",                  -1, 1, CB_INTR_SUBSTITUTE_CASE,
00838                                         "cob_intr_substitute_case",
00839                                         CB_CATEGORY_ALPHANUMERIC, 1 },
00840   { "SUM",                              -1, 1, CB_INTR_SUM,
00841                                         "cob_intr_sum",
00842                                         CB_CATEGORY_NUMERIC, 0 },
00843   { "TAN",                              1, 1, CB_INTR_TAN,
00844                                         "cob_intr_tan",
00845                                         CB_CATEGORY_NUMERIC, 0 },
00846   { "TEST-DATE-YYYYMMDD",               1, 1, CB_INTR_TEST_DATE_YYYYMMDD,
00847                                         "cob_intr_test_date_yyyymmdd",
00848                                         CB_CATEGORY_NUMERIC, 0 },
00849   { "TEST-DAY-YYYYDDD",                 1, 1, CB_INTR_TEST_DAY_YYYYDDD,
00850                                         "cob_intr_test_day_yyyyddd",
00851                                         CB_CATEGORY_NUMERIC, 0 },
00852   { "TEST-NUMVAL",                      1, 0, CB_INTR_TEST_NUMVAL,
00853                                         NULL,
00854                                         CB_CATEGORY_NUMERIC, 0 },
00855   { "TEST-NUMVAL-C",                    -1, 0, CB_INTR_TEST_NUMVAL_C,
00856                                         NULL,
00857                                         CB_CATEGORY_NUMERIC, 0 },
00858   { "TEST-NUMVAL-F",                    1, 0, CB_INTR_TEST_NUMVAL_F,
00859                                         NULL,
00860                                         CB_CATEGORY_NUMERIC, 0 },
00861   { "TRIM",                             2, 1, CB_INTR_TRIM,
00862                                         "cob_intr_trim",
00863                                         CB_CATEGORY_ALPHANUMERIC, 1 },
00864   { "UPPER-CASE",                       1, 1, CB_INTR_UPPER_CASE,
00865                                         "cob_intr_upper_case",
00866                                         CB_CATEGORY_ALPHANUMERIC, 1 },
00867   { "VARIANCE",                         -1, 1, CB_INTR_VARIANCE, 
00868                                         "cob_intr_variance",
00869                                         CB_CATEGORY_NUMERIC, 0 },
00870   { "WHEN-COMPILED",                    0, 1, CB_INTR_WHEN_COMPILED,
00871                                         "cob_intr_when_compiled",
00872                                         CB_CATEGORY_ALPHANUMERIC, 1 },
00873   { "YEAR-TO-YYYY",                     -1, 1, CB_INTR_YEAR_TO_YYYY,
00874                                         "cob_intr_year_to_yyyy",
00875                                         CB_CATEGORY_NUMERIC, 0 }
00876 };
00877 
00878 #define NUM_INTRINSICS  sizeof(function_list) / sizeof(struct cb_intrinsic_table)
00879 
00880 static int
00881 reserve_comp (const void *p1, const void *p2)
00882 {
00883         return strcasecmp (p1, ((struct reserved *)p2)->name);
00884 }
00885 
00886 static int
00887 intrinsic_comp (const void *p1, const void *p2)
00888 {
00889         return strcasecmp (p1, ((struct cb_intrinsic_table *)p2)->name);
00890 }
00891 
00892 cb_tree
00893 lookup_system_name (const char *name)
00894 {
00895         int     i;
00896 
00897         for (i = 0; system_table[i].name != NULL; ++i) {
00898                 if (strcasecmp (name, system_table[i].name) == 0) {
00899                         return system_table[i].node;
00900                 }
00901         }
00902         return cb_error_node;
00903 }
00904 
00905 int
00906 lookup_reserved_word (const char *name)
00907 {
00908         struct reserved *p;
00909         struct noreserve        *noresptr;
00910 
00911         p = bsearch (name, reserved_words, NUM_RESERVED_WORDS,
00912                         sizeof (struct reserved), reserve_comp);
00913         if (!p) {
00914                 return 0;
00915         }
00916         for (noresptr = norestab; noresptr; noresptr = noresptr->next) {
00917                 if (strcasecmp (name, noresptr->noresword) == 0) {
00918                         return 0;
00919                 }
00920         }
00921         if (p->token != -1) {
00922                 return p->token;
00923         }
00924         cb_error (_("'%s' reserved word, but not supported yet"), name);
00925         return 0;
00926 }
00927 
00928 struct cb_intrinsic_table *
00929 lookup_intrinsic (const char *name, const int checkres)
00930 {
00931         struct cb_intrinsic_table       *cbp;
00932         struct noreserve                *noresptr;
00933 
00934         if (checkres) {
00935                 for (noresptr = norestab; noresptr; noresptr = noresptr->next) {
00936                         if (strcasecmp (name, noresptr->noresword) == 0) {
00937                                 return NULL;
00938                         }
00939                 }
00940         }
00941         cbp = bsearch (name, function_list, NUM_INTRINSICS,
00942                         sizeof (struct cb_intrinsic_table), intrinsic_comp);
00943         if (cbp && cbp->implemented) {
00944                 return cbp;
00945         }
00946         return NULL;
00947 }
00948 
00949 void
00950 cb_list_reserved (void)
00951 {
00952         const char      *s;
00953         size_t  i;
00954         size_t  n;
00955 
00956         printf ("Reserved Words (Parsed Y/N)\n\n");
00957         for (i = 0; i < NUM_RESERVED_WORDS; ++i) {
00958                 n = strlen (reserved_words[i].name);
00959                 switch (n / 8) {
00960                 case 0:
00961                         s = "\t\t\t\t";
00962                         break;
00963                 case 1:
00964                         s = "\t\t\t";
00965                         break;
00966                 case 2:
00967                         s = "\t\t";
00968                         break;
00969                 default:
00970                         s = "\t";
00971                         break;
00972                 }
00973                 printf ("%s%s(%s)\n", reserved_words[i].name, s,
00974                         reserved_words[i].token != -1 ? "Y" : "N");
00975         }
00976 }
00977 
00978 void
00979 cb_list_intrinsics (void)
00980 {
00981         const char      *s;
00982         size_t          i;
00983         size_t          n;
00984 
00985         printf ("Intrinsic Function (Implemented Y/N)\n\n");
00986         for (i = 0; i < NUM_INTRINSICS; ++i) {
00987                 n = strlen (function_list[i].name);
00988                 switch (n / 8) {
00989                 case 0:
00990                         s = "\t\t\t\t";
00991                         break;
00992                 case 1:
00993                         s = "\t\t\t";
00994                         break;
00995                 case 2:
00996                         s = "\t\t";
00997                         break;
00998                 default:
00999                         s = "\t";
01000                         break;
01001                 }
01002                 printf ("%s%s(%s)\n", function_list[i].name, s,
01003                         function_list[i].implemented ? "Y" : "N");
01004         }
01005 }
01006 
01007 void
01008 cb_list_mnemonics (void)
01009 {
01010         size_t          i;
01011 
01012         printf ("Mnemonic names\n\n");
01013         for (i = 0; system_table[i].name != NULL; ++i) {
01014                 printf ("%s\n", system_table[i].name);
01015         }
01016 }
01017 
01018 void
01019 cb_init_reserved (void)
01020 {
01021         int     i;
01022 
01023         /* build system-name table */
01024         for (i = 0; system_table[i].name != NULL; ++i) {
01025                 system_table[i].node =
01026                   cb_build_system_name (system_table[i].category, system_table[i].token);
01027         }
01028 }
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines