Annotation of researchv9/X11/src/X.V11R1/clients/uwm/lex.l, revision 1.1

1.1     ! root        1: %{
        !             2: 
        !             3: #include <X11/copyright.h>
        !             4: 
        !             5: /*
        !             6:  * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
        !             7:  *
        !             8:  *                         All Rights Reserved
        !             9:  *
        !            10:  * Permission to use, copy, modify, and distribute this software and its
        !            11:  * documentation for any purpose and without fee is hereby granted,
        !            12:  * provided that the above copyright notice appear in all copies and that
        !            13:  * both that copyright notice and this permission notice appear in
        !            14:  * supporting documentation, and that the name of Digital Equipment
        !            15:  * Corporation not be used in advertising or publicity pertaining to
        !            16:  * distribution of the software without specific, written prior permission.
        !            17:  *
        !            18:  *
        !            19:  * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
        !            20:  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
        !            21:  * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
        !            22:  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
        !            23:  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
        !            24:  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
        !            25:  * SOFTWARE.
        !            26:  */
        !            27: 
        !            28:  
        !            29: 
        !            30: 
        !            31: /*
        !            32:  * MODIFICATION HISTORY
        !            33:  *
        !            34:  * 000 -- M. Gancarz, DEC Ultrix Engineering Group
        !            35:  */
        !            36: 
        !            37: #ifndef lint
        !            38: static char *sccsid = "@(#)lex.l       3.8     1/24/86";
        !            39: #endif
        !            40: 
        !            41: #include "y.tab.h"
        !            42: #include "uwm.h"
        !            43: 
        !            44: char *dequote();
        !            45: char *stash();
        !            46: 
        !            47: %}
        !            48: W      [ \t]+
        !            49: %%
        !            50: 
        !            51: #.*\n                          { return(COMMENT); }    /* Comments. */
        !            52: {W}                            { ; }   /* Whitespace. */
        !            53: [^ \"\t\n#=\^\!\|\(\)\{\}:;]+  { yylval.sval=stash(yytext);return(STRING); }
        !            54: \"[^\"\n]*\"                   { yylval.sval=stash(dequote(yytext));
        !            55:                                  return(STRING); }
        !            56: \n                             { return(NL); }
        !            57: .                              { return(*yytext); }
        !            58: 
        !            59: %%
        !            60: 
        !            61: /*
        !            62:  * Remove the quotes enclosing a quoted string.
        !            63:  */
        !            64: char *
        !            65: dequote(s)
        !            66: char *s;
        !            67: {
        !            68:     char *p;
        !            69: 
        !            70:     ++s;
        !            71:     p = rindex(s, '"');
        !            72:     *p = '\0';
        !            73:     return(s);
        !            74: }
        !            75: 
        !            76: /*
        !            77:  * Save string away in memory and return a pointer to it.  If
        !            78:  * no space could be found, quit with a fatal error.
        !            79:  */
        !            80: char *stash(s)
        !            81: char *s;
        !            82: {
        !            83:     char *ptr;
        !            84:     char *malloc();
        !            85: 
        !            86:     ptr = malloc(strlen(s) + 1);
        !            87:     if (ptr == NULL) {
        !            88:         Error("out of space");
        !            89:     }
        !            90:     return(strcpy(ptr, s));
        !            91: }

unix.superglobalmegacorp.com

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