Annotation of 43BSD/contrib/X/uwm/lex.l, revision 1.1

1.1     ! root        1: %{
        !             2: 
        !             3: /************************************************************************
        !             4:  *                                                                     *
        !             5:  *                     Copyright (c) 1986 by                           *
        !             6:  *             Digital Equipment Corporation, Maynard, MA              *
        !             7:  *                      All Rights Reserved.                           *
        !             8:  *                                                                     *
        !             9:  *     Permission to use, copy, modify, and distribute this software   *
        !            10:  *     and its documentation is hereby granted only to licensees of    *
        !            11:  *     The Regents of the University of California pursuant to their   *
        !            12:  *     license agreement for the Berkeley Software Distribution        *
        !            13:  *     provided that the following appears on all copies.              *
        !            14:  *                                                                     *
        !            15:  *            "LICENSED FROM DIGITAL EQUIPMENT CORPORATION             *
        !            16:  *                      COPYRIGHT (C) 1986                             *       
        !            17:  *                 DIGITAL EQUIPMENT CORPORATION                       *
        !            18:  *                         MAYNARD, MA                                 *
        !            19:  *                     ALL RIGHTS RESERVED.                            *
        !            20:  *                                                                     *
        !            21:  *      THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT  * 
        !            22:  *     NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL   *
        !            23:  *     EQUIPMENT CORPORATION.  DIGITAL MAKES NO REPRESENTATIONS        *
        !            24:  *     ABOUT SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. IT IS       *
        !            25:  *     SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.           *
        !            26:  *                                                                     *       
        !            27:  *     IF THE UNIVERSITY OF CALIFORNIA OR ITS LICENSEES MODIFY         *       
        !            28:  *     THE SOFTWARE IN A MANNER CREATING DERIVATIVE COPYRIGHT          *       
        !            29:  *     RIGHTS APPROPRIATE COPYRIGHT LEGENDS MAY BE PLACED ON THE       *
        !            30:  *     DERIVATIVE WORK IN ADDITION TO THAT SET FORTH ABOVE."           *       
        !            31:  *                                                                     *
        !            32:  ************************************************************************/
        !            33:  
        !            34: 
        !            35: 
        !            36: /*
        !            37:  * MODIFICATION HISTORY
        !            38:  *
        !            39:  * 000 -- M. Gancarz, DEC Ultrix Engineering Group
        !            40:  */
        !            41: 
        !            42: #ifndef lint
        !            43: static char *sccsid = "@(#)lex.l       3.8     1/24/86";
        !            44: #endif
        !            45: 
        !            46: #include "y.tab.h"
        !            47: #include "uwm.h"
        !            48: 
        !            49: char *dequote();
        !            50: char *stash();
        !            51: 
        !            52: %}
        !            53: W      [ \t]+
        !            54: %%
        !            55: 
        !            56: #.*\n                          { return(COMMENT); }    /* Comments. */
        !            57: {W}                            { ; }   /* Whitespace. */
        !            58: [^ \"\t\n#=\^\!\|\(\)\{\}:;]+  { yylval.sval=stash(yytext);return(STRING); }
        !            59: \"[^\"\n]*\"                   { yylval.sval=stash(dequote(yytext));
        !            60:                                  return(STRING); }
        !            61: \n                             { return(NL); }
        !            62: .                              { return(*yytext); }
        !            63: 
        !            64: %%
        !            65: 
        !            66: /*
        !            67:  * Remove the quotes enclosing a quoted string.
        !            68:  */
        !            69: char *
        !            70: dequote(s)
        !            71: char *s;
        !            72: {
        !            73:     char *p;
        !            74: 
        !            75:     ++s;
        !            76:     p = rindex(s, '"');
        !            77:     *p = '\0';
        !            78:     return(s);
        !            79: }
        !            80: 
        !            81: /*
        !            82:  * Save string away in memory and return a pointer to it.  If
        !            83:  * no space could be found, quit with a fatal error.
        !            84:  */
        !            85: char *stash(s)
        !            86: char *s;
        !            87: {
        !            88:     char *ptr;
        !            89:     char *malloc();
        !            90: 
        !            91:     ptr = malloc(strlen(s) + 1);
        !            92:     if (ptr == NULL) {
        !            93:         Error("out of space");
        !            94:     }
        !            95:     return(strcpy(ptr, s));
        !            96: }

unix.superglobalmegacorp.com

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