~ctwm/ctwm/trunk

1 by Claude Lecommandeur
CTWM version 1.1
1
%{
2
/*****************************************************************************/
3
/**       Copyright 1988 by Evans & Sutherland Computer Corporation,        **/
4
/**                          Salt Lake City, Utah                           **/
5
/**  Portions Copyright 1989 by the Massachusetts Institute of Technology   **/
6
/**                        Cambridge, Massachusetts                         **/
7
/**                                                                         **/
8
/**                           All Rights Reserved                           **/
9
/**                                                                         **/
10
/**    Permission to use, copy, modify, and distribute this software and    **/
11
/**    its documentation  for  any  purpose  and  without  fee is hereby    **/
12
/**    granted, provided that the above copyright notice appear  in  all    **/
13
/**    copies and that both  that  copyright  notice  and  this  permis-    **/
14
/**    sion  notice appear in supporting  documentation,  and  that  the    **/
15
/**    names of Evans & Sutherland and M.I.T. not be used in advertising    **/
16
/**    in publicity pertaining to distribution of the  software  without    **/
17
/**    specific, written prior permission.                                  **/
18
/**                                                                         **/
19
/**    EVANS & SUTHERLAND AND M.I.T. DISCLAIM ALL WARRANTIES WITH REGARD    **/
20
/**    TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES  OF  MERCHANT-    **/
21
/**    ABILITY  AND  FITNESS,  IN  NO  EVENT SHALL EVANS & SUTHERLAND OR    **/
22
/**    M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL  DAM-    **/
23
/**    AGES OR  ANY DAMAGES WHATSOEVER  RESULTING FROM LOSS OF USE, DATA    **/
24
/**    OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER    **/
25
/**    TORTIOUS ACTION, ARISING OUT OF OR IN  CONNECTION  WITH  THE  USE    **/
26
/**    OR PERFORMANCE OF THIS SOFTWARE.                                     **/
27
/*****************************************************************************/
11 by Claude Lecommandeur
CTWM version 3.2p1
28
/* 
29
 *  [ ctwm ]
30
 *
31
 *  Copyright 1992 Claude Lecommandeur.
32
 *            
33
 * Permission to use, copy, modify  and distribute this software  [ctwm] and
34
 * its documentation for any purpose is hereby granted without fee, provided
35
 * that the above  copyright notice appear  in all copies and that both that
36
 * copyright notice and this permission notice appear in supporting documen-
37
 * tation, and that the name of  Claude Lecommandeur not be used in adverti-
38
 * sing or  publicity  pertaining to  distribution of  the software  without
39
 * specific, written prior permission. Claude Lecommandeur make no represen-
40
 * tations  about the suitability  of this software  for any purpose.  It is
41
 * provided "as is" without express or implied warranty.
42
 *
43
 * Claude Lecommandeur DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
44
 * INCLUDING ALL  IMPLIED WARRANTIES OF  MERCHANTABILITY AND FITNESS.  IN NO
45
 * EVENT SHALL  Claude Lecommandeur  BE LIABLE FOR ANY SPECIAL,  INDIRECT OR
46
 * CONSEQUENTIAL  DAMAGES OR ANY  DAMAGES WHATSOEVER  RESULTING FROM LOSS OF
47
 * USE, DATA  OR PROFITS,  WHETHER IN AN ACTION  OF CONTRACT,  NEGLIGENCE OR
48
 * OTHER  TORTIOUS ACTION,  ARISING OUT OF OR IN  CONNECTION WITH THE USE OR
49
 * PERFORMANCE OF THIS SOFTWARE.
50
 *
51
 * Author:  Claude Lecommandeur [ lecom@sic.epfl.ch ][ April 1992 ]
52
 */
1 by Claude Lecommandeur
CTWM version 1.1
53
54
/***********************************************************************
55
 *
56
 * $XConsortium: lex.l,v 1.62 89/12/10 17:46:33 jim Exp $
57
 *
58
 * .twmrc lex file
59
 *
60
 * 12-Nov-87 Thomas E. LaStrange		File created
61
 *
62
 ***********************************************************************/
63
395.1.4 by Matthew Fuller
Move ctwm.h to the top of gram.y, and add it to lex.l.
64
#include "ctwm.h"
1 by Claude Lecommandeur
CTWM version 1.1
65
#include "parse.h"
431.1.27 by Matthew Fuller
Break out a parse_be.h for the stuff that should only be
66
#include "parse_be.h"
1 by Claude Lecommandeur
CTWM version 1.1
67
492.2.33 by Matthew Fuller
Do some more cleanup of headers including headers.
68
#include "gram.tab.h"
69
384.1.1 by Matthew Fuller
Little documentation of what's going on here.
70
/*
71
 * flex uses a YY_INPUT macro internally rather than input.  It doesn't
72
 * need unput since it maintains state internally.
73
 */
9 by Claude Lecommandeur
CTWM version 3.1
74
#ifdef FLEX_SCANNER
75
#  undef YY_INPUT
17 by Claude Lecommandeur
CTWM version 3.5
76
#  define YY_INPUT(buf,result,max_size) {buf[0]=twmInputFunc();result=(buf[0] != 0);}
9 by Claude Lecommandeur
CTWM version 3.1
77
#endif
384.1.6 by Matthew Fuller
Leave a comment about how we can figure versions of flex if we need
78
79
/*
80
 * YY_FLEX_{MAJOR,MINOR}_VERSION was added in 2.5.1 (28Mar95); just in
81
 * case we need to do version checks of stuff.
82
 */
384.1.7 by Matthew Fuller
flex provides some macros to avoid declaring input/unput functions.
83
84
/*
85
 * flex listens to these to avoid declaring these functions, which we
86
 * don't use, so suppress the warning.
87
 */
88
#define YY_NO_UNPUT
89
#define YY_NO_INPUT
90
1 by Claude Lecommandeur
CTWM version 1.1
91
%}
92
93
string				\"([^"]|\\.)*\"
94
number				[0-9]+
95
%%
96
"{"				{ return (LB); }
97
"}"				{ return (RB); }
98
"("				{ return (LP); }
99
")"				{ return (RP); }
100
"="				{ return (EQUALS); }
101
":"				{ return (COLON); }
102
"+"				{ return PLUS; }
103
"-"				{ return MINUS; }
104
"|"				{ return OR; }
105
106
[a-zA-Z\.]+			{ int token = parse_keyword (yytext, 
107
							     &yylval.num);
108
				  if (token == ERRORTOKEN) {
109
				      twmrc_error_prefix();
110
				      fprintf (stderr,
111
				       "ignoring unknown keyword:  %s\n", 
112
					       yytext);
113
				      ParseError = 1;
114
				  } else 
115
				    return token;
116
				}
117
118
"!"				{ yylval.num = F_EXEC; return FSKEYWORD; }
119
134 by Richard Levitte
Resolve a lot of unsigned vs. signed conflicts, and a few other
120
{string}			{ yylval.ptr = yytext; return STRING; }
121
{number}			{ (void)sscanf(yytext, "%d", &yylval.num);
122
				  return NUMBER; }
1 by Claude Lecommandeur
CTWM version 1.1
123
\#[^\n]*\n			{;}
124
[\n\t ]				{;}
125
.				{
126
				  twmrc_error_prefix();
127
				  fprintf (stderr, 
128
					   "ignoring character \"%s\"\n",
129
					   yytext);
130
				  ParseError = 1;
131
				}
132
%%
384.1.3 by Matthew Fuller
Add a comment explaining why we have the #ifndef guard.
133
134
/*
135
 * In flex versions before 2.4.1 (30Nov93), yywrap was a macro, not a
136
 * function.  There's no way we really support versions that old, but
137
 * what the heck...
138
 */
11 by Claude Lecommandeur
CTWM version 3.2p1
139
#ifndef yywrap
93 by Richard Levitte
- Convert all functions to use proper prototypes.
140
int yywrap(void) { return(1);}
11 by Claude Lecommandeur
CTWM version 3.2p1
141
#endif
142
384.1.1 by Matthew Fuller
Little documentation of what's going on here.
143
/* AT&T lex uses the input/unput macros */
9 by Claude Lecommandeur
CTWM version 3.1
144
#ifndef FLEX_SCANNER
384.1.2 by Matthew Fuller
Just #error out on non-flex lex. The cmake build chain probably won't
145
/*
146
 * I believe Solaris at least recently recently (and maybe currently)
147
 * ships with an AT&T lex, but also with flex beside it.  Plan
148
 * 9 might ship only A&T lex?
149
 *
150
 * However, our current build toolchain doesn't look for any lex other
151
 * than flex.  So #error out if we get here; adventurous users might take
152
 * this out, and it might work; let us know!
153
 */
154
#error Not supported on non-flex; remove this line at your own risk
386.1.1 by Matthew Fuller
Create a NON_FLEX_LEX define to hide non-flex-only bits behind, and
155
#ifdef NON_FLEX_LEX
1 by Claude Lecommandeur
CTWM version 1.1
156
#undef unput
157
#undef input
158
#undef output
159
#undef feof
160
#define unput(c)	twmUnput(c)
161
#define input()		(*twmInputFunc)()
162
#define output(c)	TwmOutput(c)
163
#define feof()		(1)
386.1.1 by Matthew Fuller
Create a NON_FLEX_LEX define to hide non-flex-only bits behind, and
164
#endif /* NON_FLEX_LEX */
165
#endif /* !FLEX_SCANNER */
17 by Claude Lecommandeur
CTWM version 3.5
166