Annotation of 43BSDReno/usr.sbin/htable/parse.y, revision 1.1

1.1     ! root        1: %{
        !             2: 
        !             3: /*
        !             4:  * Copyright (c) 1983 Regents of the University of California.
        !             5:  * All rights reserved.
        !             6:  *
        !             7:  * Redistribution and use in source and binary forms are permitted provided
        !             8:  * that: (1) source distributions retain this entire copyright notice and
        !             9:  * comment, and (2) distributions including binaries display the following
        !            10:  * acknowledgement:  ``This product includes software developed by the
        !            11:  * University of California, Berkeley and its contributors'' in the
        !            12:  * documentation or other materials provided with the distribution and in
        !            13:  * all advertising materials mentioning features or use of this software.
        !            14:  * Neither the name of the University nor the names of its contributors may
        !            15:  * be used to endorse or promote products derived from this software without
        !            16:  * specific prior written permission.
        !            17:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
        !            18:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
        !            19:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            20:  */
        !            21: 
        !            22: #ifndef lint
        !            23: static char sccsid[] = "@(#)parse.y    5.5 (Berkeley) 6/1/90";
        !            24: #endif /* not lint */
        !            25: 
        !            26: #include "htable.h"
        !            27: %}
        !            28: 
        !            29: %union {
        !            30:        int     number;
        !            31:        struct  addr *addrlist;
        !            32:        struct  name *namelist;
        !            33: }
        !            34: %start Table
        !            35: 
        !            36: %token                 END
        !            37: %token <number>                NUMBER KEYWORD
        !            38: %token <namelist>      NAME
        !            39: 
        !            40: %type <namelist>       Names Cputype Opsys Protos Proto
        !            41: %type <addrlist>       Addresses Address
        !            42: %%
        !            43: Table  :       Entry
        !            44:        |       Table Entry
        !            45:        ;
        !            46: 
        !            47: Entry  :       KEYWORD ':' Addresses ':' Names ':' END
        !            48:        = {
        !            49:                do_entry($1, $3, $5, NONAME, NONAME, NONAME);
        !            50:        }
        !            51:        |       KEYWORD ':' Addresses ':' Names ':' Cputype ':' END
        !            52:        = {
        !            53:                do_entry($1, $3, $5, $7, NONAME, NONAME);
        !            54:        }
        !            55:        |       KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' END
        !            56:        = {
        !            57:                do_entry($1, $3, $5, $7, $9, NONAME);
        !            58:        }
        !            59:        |       KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' ':' END
        !            60:        = {
        !            61:                do_entry($1, $3, $5, $7, $9, NONAME);
        !            62:        }
        !            63:        |       KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' Protos ':' END
        !            64:        = {
        !            65:                do_entry($1, $3, $5, $7, $9, $11);
        !            66:        }
        !            67:        |       error END
        !            68:        |       END             /* blank line */
        !            69:        ;
        !            70: 
        !            71: Addresses:     Address
        !            72:        = {
        !            73:                $$ = $1;
        !            74:        }
        !            75:        |       Address ',' Addresses
        !            76:        = {
        !            77:                $1->addr_link = $3;
        !            78:                $$ = $1;
        !            79:        }
        !            80:        ;
        !            81: 
        !            82: Address        :       NUMBER '.' NUMBER '.' NUMBER '.' NUMBER
        !            83:        = {
        !            84:                char *a;
        !            85: 
        !            86:                $$ = (struct addr *)malloc(sizeof (struct addr));
        !            87:                a = (char *)&($$->addr_val);
        !            88:                a[0] = $1; a[1] = $3; a[2] = $5; a[3] = $7;
        !            89:                $$->addr_link = NOADDR;
        !            90:        }
        !            91:        ;
        !            92: 
        !            93: Names  :       NAME
        !            94:        = {
        !            95:                $$ = $1;
        !            96:        }
        !            97:        |       NAME ',' Names
        !            98:        = {
        !            99:                $1->name_link = $3;
        !           100:                $$ = $1;
        !           101:        }
        !           102:        ;
        !           103: 
        !           104: Cputype :      /* empty */
        !           105:        = {
        !           106:                $$ = NONAME;
        !           107:        }
        !           108:        |       NAME
        !           109:        = {
        !           110:                $$ = $1;
        !           111:        }
        !           112:        ;
        !           113: 
        !           114: Opsys  :       /* empty */
        !           115:        = {
        !           116:                $$ = NONAME;
        !           117:        }
        !           118:        |       NAME
        !           119:        = {
        !           120:                $$ = $1;
        !           121:        }
        !           122:        ;
        !           123: 
        !           124: Protos :       Proto
        !           125:        = {
        !           126:                $$ = $1;
        !           127:        }
        !           128:        |       Proto ',' Protos
        !           129:        = {
        !           130:                $1->name_link = $3;
        !           131:                $$ = $1;
        !           132:        }
        !           133:        ;
        !           134: 
        !           135: Proto  :       NAME
        !           136:        = {
        !           137:                $$ = $1;
        !           138:        }
        !           139:        ;
        !           140: %%
        !           141: 
        !           142: #include <stdio.h>
        !           143: 
        !           144: extern int yylineno;
        !           145: 
        !           146: yyerror(msg)
        !           147:        char *msg;
        !           148: {
        !           149:        fprintf(stderr, "\"%s\", line %d: %s\n", infile, yylineno, msg);
        !           150: }

unix.superglobalmegacorp.com

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