|
|
1.1 root 1: %{
2:
3: /*
4: * COPYRIGHT 1985, 1986
5: * DIGITAL EQUIPMENT CORPORATION
6: * MAYNARD, MASSACHUSETTS
7: * ALL RIGHTS RESERVED.
8: *
9: * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
10: * SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
11: * DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITIBILITY OF THIS SOFTWARE FOR
12: * ANY PURPOSE. IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
13: *
14: * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT RIGHTS,
15: * APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN ADDITION TO THAT
16: * SET FORTH ABOVE.
17: *
18: *
19: * Permission to use, copy, modify, and distribute this software and its
20: * documentation for any purpose and without fee is hereby granted, provided
21: * that the above copyright notice appear in all copies and that both that
22: * copyright notice and this permission notice appear in supporting documentation,
23: * and that the name of Digital Equipment Corporation not be used in advertising
24: * or publicity pertaining to distribution of the software without specific,
25: * written prior permission.
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: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.