[BACK]Return to ct.y CVS log [TXT][DIR] Up to [local] / src / usr.bin / mk_cmds

Annotation of src/usr.bin/mk_cmds/ct.y, Revision 1.1

1.1     ! downsj      1: %{
        !             2: /*     $OpenBSD: ct.y,v 1.1.1.1 1995/12/14 06:52:48 tholo Exp $        */
        !             3:
        !             4: /*-
        !             5:  * Copyright 1987, 1988 by the Student Information Processing Board
        !             6:  *     of the Massachusetts Institute of Technology
        !             7:  *
        !             8:  * Permission to use, copy, modify, and distribute this software
        !             9:  * and its documentation for any purpose and without fee is
        !            10:  * hereby granted, provided that the above copyright notice
        !            11:  * appear in all copies and that both that copyright notice and
        !            12:  * this permission notice appear in supporting documentation,
        !            13:  * and that the names of M.I.T. and the M.I.T. S.I.P.B. not be
        !            14:  * used in advertising or publicity pertaining to distribution
        !            15:  * of the software without specific, written prior permission.
        !            16:  * M.I.T. and the M.I.T. S.I.P.B. make no representations about
        !            17:  * the suitability of this software for any purpose.  It is
        !            18:  * provided "as is" without express or implied warranty.
        !            19:  */
        !            20:
        !            21: #include <stdio.h>
        !            22: #include <stdlib.h>
        !            23:
        !            24: char *str_concat3(), *ds(), *generate_rqte(), *quote();
        !            25: long flag_value();
        !            26: char *last_token = (char *)NULL;
        !            27: FILE *output_file;
        !            28: long gensym_n = 0;
        !            29: %}
        !            30:
        !            31: %union {
        !            32:        char *dynstr;
        !            33:        long flags;
        !            34: }
        !            35:
        !            36: %token COMMAND_TABLE REQUEST UNKNOWN UNIMPLEMENTED END
        !            37: %token <dynstr> STRING
        !            38: %token <dynstr> FLAGNAME
        !            39: %type <dynstr> namelist header request_list
        !            40: %type <dynstr> request_entry
        !            41: %type <flags> flag_list options
        !            42: %left OPTIONS
        !            43: %{
        !            44: #define NO_SS_ERR_H
        !            45: #include <ss/ss.h>
        !            46: %}
        !            47: %start command_table
        !            48: %%
        !            49: command_table :        header request_list END ';'
        !            50:                { write_ct($1, $2); }
        !            51:        ;
        !            52:
        !            53: header :       COMMAND_TABLE STRING ';'
        !            54:                { $$ = $2; }
        !            55:        ;
        !            56:
        !            57: request_list : request_list request_entry
        !            58:                { $$ = str_concat3($1, $2, ""); }
        !            59:        |
        !            60:                { $$ = ""; }
        !            61:        ;
        !            62:
        !            63: request_entry :        REQUEST STRING ',' STRING ',' namelist ',' options ';'
        !            64:                { $$ = generate_rqte($2, quote($4), $6, $8); }
        !            65:        |       REQUEST STRING ',' STRING ',' namelist ';'
        !            66:                { $$ = generate_rqte($2, quote($4), $6, 0); }
        !            67:        |       UNKNOWN namelist ';'
        !            68:                { $$ = generate_rqte("ss_unknown_request",
        !            69:                                        (char *)NULL, $2, 0); }
        !            70:        |       UNIMPLEMENTED STRING ',' STRING ',' namelist ';'
        !            71:                { $$ = generate_rqte("ss_unimplemented", quote($4), $6, 3); }
        !            72:        ;
        !            73:
        !            74: options        :       '(' flag_list ')'
        !            75:                { $$ = $2; }
        !            76:        |       '(' ')'
        !            77:                { $$ = 0; }
        !            78:        ;
        !            79:
        !            80: flag_list :    flag_list ',' STRING
        !            81:                { $$ = $1 | flag_val($3); }
        !            82:        |       STRING
        !            83:                { $$ = flag_val($1); }
        !            84:        ;
        !            85:
        !            86: namelist:      STRING
        !            87:                { $$ = quote(ds($1)); }
        !            88:        |       namelist ',' STRING
        !            89:                { $$ = str_concat3($1, quote($3), ",\n    "); }
        !            90:        ;
        !            91:
        !            92: %%