Annotation of cci/usr/src/etc/config/config.l, revision 1.1

1.1     ! root        1: %{
        !             2: /*     config.l        1.14    83/05/18        */
        !             3: 
        !             4: #include <ctype.h>
        !             5: #include "y.tab.h"
        !             6: #include "config.h"
        !             7: 
        !             8: #define tprintf if (do_trace) printf
        !             9: 
        !            10: /*
        !            11:  * Key word table
        !            12:  */
        !            13: 
        !            14: struct kt {
        !            15:        char *kt_name;
        !            16:        int kt_val;
        !            17: } key_words[] = {
        !            18:        { "and",        AND },
        !            19:        { "args",       ARGS },
        !            20:        { "at",         AT },
        !            21:        { "config",     CONFIG },
        !            22:        { "controller", CONTROLLER },
        !            23:        { "cpu",        CPU },
        !            24:        { "csr",        CSR },
        !            25:        { "device",     DEVICE },
        !            26:        { "disk",       DISK },
        !            27:        { "drive",      DRIVE },
        !            28:        { "dst",        DST },
        !            29:        { "dumps",      DUMPS },
        !            30:        { "flags",      FLAGS },
        !            31:        { "hz",         HZ },
        !            32:        { "ident",      IDENT },
        !            33:        { "machine",    MACHINE },
        !            34:        { "major",      MAJOR },
        !            35:        { "master",     MASTER },
        !            36:        { "maxusers",   MAXUSERS },
        !            37:        { "mba",        MBA },
        !            38:        { "minor",      MINOR },
        !            39:        { "nexus",      NEXUS },
        !            40:        { "on",         ON },
        !            41:        { "options",    OPTIONS },
        !            42:        { "priority",   PRIORITY },
        !            43:        { "pseudo-device",PSEUDO_DEVICE },
        !            44:        { "root",       ROOT },
        !            45:        { "size",       SIZE },
        !            46:        { "slave",      SLAVE },
        !            47:        { "swap",       SWAP },
        !            48:        { "tape",       DEVICE },
        !            49:        { "timezone",   TIMEZONE },
        !            50:        { "trace",      TRACE },
        !            51:        { "uba",        UBA },
        !            52:        { "vba",        VBA },
        !            53:        { "vector",     VECTOR },
        !            54:        { 0, 0 },
        !            55: };
        !            56: %}
        !            57: WORD   [A-Za-z_][-A-Za-z_]*
        !            58: %%
        !            59: {WORD}         {
        !            60:                        int i;
        !            61: 
        !            62:                        if ((i = kw_lookup(yytext)) == -1)
        !            63:                        {
        !            64:                                yylval.str = yytext;
        !            65:                                tprintf("id(%s) ", yytext);
        !            66:                                return ID;
        !            67:                        }
        !            68:                        tprintf("(%s) ", yytext);
        !            69:                        return i;
        !            70:                }
        !            71: \"[^"]+\"      {
        !            72:                        yytext[strlen(yytext)-1] = '\0';
        !            73:                        yylval.str = yytext + 1;
        !            74:                        return ID;
        !            75:                }
        !            76: 0[0-7]*                {
        !            77:                        yylval.val = octal(yytext);
        !            78:                        tprintf("#O:%o ", yylval.val);
        !            79:                        return NUMBER;
        !            80:                }
        !            81: 0x[0-9a-fA-F]+ {
        !            82:                        yylval.val = hex(yytext);
        !            83:                        tprintf("#X:%x ", yylval.val);
        !            84:                        return NUMBER;
        !            85:                }
        !            86: [1-9][0-9]*    {
        !            87:                        yylval.val = atoi(yytext);
        !            88:                        tprintf("#D:%d ", yylval.val);
        !            89:                        return NUMBER;
        !            90:                }
        !            91: [0-9]"."[0-9]* {
        !            92:                        double atof();
        !            93:                        yylval.val = (int) (60 * atof(yytext) + 0.5);
        !            94:                        return FPNUMBER;
        !            95:                }
        !            96: "-"            {
        !            97:                        return MINUS;
        !            98:                }
        !            99: "?"            {
        !           100:                        yylval.val = -1;
        !           101:                        tprintf("? ");
        !           102:                        return NUMBER;
        !           103:                }
        !           104: \n/[ \t]       {
        !           105:                        yyline++;
        !           106:                        tprintf("\n... ");
        !           107:                }
        !           108: \n             {
        !           109:                        yyline++;
        !           110:                        tprintf("\n");
        !           111:                        return SEMICOLON;
        !           112:                }
        !           113: #.*            {       /* Ignored (comment) */;        }
        !           114: [ \t]*         {       /* Ignored (white space) */;    }
        !           115: ";"            {       return SEMICOLON;               }
        !           116: ","            {       return COMMA;                   }
        !           117: "="            {       return EQUALS;                  }
        !           118: "@"            {       return AT;                      }
        !           119: .              {       return yytext[0];               }
        !           120: 
        !           121: %%
        !           122: /*
        !           123:  * kw_lookup
        !           124:  *     Look up a string in the keyword table.  Returns a -1 if the
        !           125:  *     string is not a keyword otherwise it returns the keyword number
        !           126:  */
        !           127: 
        !           128: kw_lookup(word)
        !           129: register char *word;
        !           130: {
        !           131:        register struct kt *kp;
        !           132: 
        !           133:        for (kp = key_words; kp->kt_name != 0; kp++)
        !           134:                if (eq(word, kp->kt_name))
        !           135:                        return kp->kt_val;
        !           136:        return -1;
        !           137: }
        !           138: 
        !           139: /*
        !           140:  * Number conversion routines
        !           141:  */
        !           142: 
        !           143: octal(str)
        !           144: char *str;
        !           145: {
        !           146:        int num;
        !           147: 
        !           148:        (void) sscanf(str, "%o", &num);
        !           149:        return num;
        !           150: }
        !           151: 
        !           152: hex(str)
        !           153: char *str;
        !           154: {
        !           155:        int num;
        !           156: 
        !           157:        (void) sscanf(str+2, "%x", &num);
        !           158:        return num;
        !           159: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.