~ctwm/ctwm/trunk

1 by Claude Lecommandeur
CTWM version 1.1
1
%{
554.1.10 by Matthew Fuller
Pull out the simple cases of long-form twm+Claude copyright/license
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
 * Copyright 1992 Claude Lecommandeur.
11 by Claude Lecommandeur
CTWM version 3.2p1
9
 */
1 by Claude Lecommandeur
CTWM version 1.1
10
11
/***********************************************************************
12
 *
13
 * $XConsortium: lex.l,v 1.62 89/12/10 17:46:33 jim Exp $
14
 *
15
 * .twmrc lex file
16
 *
17
 * 12-Nov-87 Thomas E. LaStrange		File created
18
 *
19
 ***********************************************************************/
20
395.1.4 by Matthew Fuller
Move ctwm.h to the top of gram.y, and add it to lex.l.
21
#include "ctwm.h"
528.1.63 by Matthew Fuller
#if 0 out the old function #define's in parse.h, and add
22
#include "functions_defs.h"
1 by Claude Lecommandeur
CTWM version 1.1
23
#include "parse.h"
431.1.27 by Matthew Fuller
Break out a parse_be.h for the stuff that should only be
24
#include "parse_be.h"
1 by Claude Lecommandeur
CTWM version 1.1
25
492.2.33 by Matthew Fuller
Do some more cleanup of headers including headers.
26
#include "gram.tab.h"
27
384.1.1 by Matthew Fuller
Little documentation of what's going on here.
28
/*
29
 * flex uses a YY_INPUT macro internally rather than input.  It doesn't
30
 * need unput since it maintains state internally.
31
 */
9 by Claude Lecommandeur
CTWM version 3.1
32
#ifdef FLEX_SCANNER
33
#  undef YY_INPUT
17 by Claude Lecommandeur
CTWM version 3.5
34
#  define YY_INPUT(buf,result,max_size) {buf[0]=twmInputFunc();result=(buf[0] != 0);}
9 by Claude Lecommandeur
CTWM version 3.1
35
#endif
384.1.6 by Matthew Fuller
Leave a comment about how we can figure versions of flex if we need
36
37
/*
38
 * YY_FLEX_{MAJOR,MINOR}_VERSION was added in 2.5.1 (28Mar95); just in
39
 * case we need to do version checks of stuff.
40
 */
384.1.7 by Matthew Fuller
flex provides some macros to avoid declaring input/unput functions.
41
42
/*
43
 * flex listens to these to avoid declaring these functions, which we
44
 * don't use, so suppress the warning.
45
 */
46
#define YY_NO_UNPUT
47
#define YY_NO_INPUT
48
1 by Claude Lecommandeur
CTWM version 1.1
49
%}
50
51
string				\"([^"]|\\.)*\"
52
number				[0-9]+
580 by Matthew Fuller
Add options to tell flex to disable bothering with yywrap and yyunput.
53
54
 /* Requires flex 2.5.1 (28Mar95) */
55
%option noyywrap
56
 /* Requires flex 2.5.2 (25Apr95) */
57
%option nounput
58
1 by Claude Lecommandeur
CTWM version 1.1
59
%%
60
"{"				{ return (LB); }
61
"}"				{ return (RB); }
62
"("				{ return (LP); }
63
")"				{ return (RP); }
64
"="				{ return (EQUALS); }
65
":"				{ return (COLON); }
66
"+"				{ return PLUS; }
67
"-"				{ return MINUS; }
68
"|"				{ return OR; }
69
70
[a-zA-Z\.]+			{ int token = parse_keyword (yytext, 
71
							     &yylval.num);
72
				  if (token == ERRORTOKEN) {
73
				      twmrc_error_prefix();
74
				      fprintf (stderr,
75
				       "ignoring unknown keyword:  %s\n", 
76
					       yytext);
492.2.97 by Matthew Fuller
bool-ify flags and return values related to config file parsing.
77
				      ParseError = true;
1 by Claude Lecommandeur
CTWM version 1.1
78
				  } else 
79
				    return token;
80
				}
81
82
"!"				{ yylval.num = F_EXEC; return FSKEYWORD; }
83
134 by Richard Levitte
Resolve a lot of unsigned vs. signed conflicts, and a few other
84
{string}			{ yylval.ptr = yytext; return STRING; }
544.1.2 by Matthew Fuller
GCC some remaining (void) return casts.
85
{number}			{ sscanf(yytext, "%d", &yylval.num);
513.1.12 by Matthew Fuller
Actually, it looks like I can just pull in yytext to gram.y, so revert
86
				  return NUMBER; }
1 by Claude Lecommandeur
CTWM version 1.1
87
\#[^\n]*\n			{;}
88
[\n\t ]				{;}
89
.				{
90
				  twmrc_error_prefix();
91
				  fprintf (stderr, 
92
					   "ignoring character \"%s\"\n",
93
					   yytext);
492.2.97 by Matthew Fuller
bool-ify flags and return values related to config file parsing.
94
				  ParseError = true;
1 by Claude Lecommandeur
CTWM version 1.1
95
				}
96
%%
384.1.3 by Matthew Fuller
Add a comment explaining why we have the #ifndef guard.
97
98
/*
99
 * In flex versions before 2.4.1 (30Nov93), yywrap was a macro, not a
100
 * function.  There's no way we really support versions that old, but
101
 * what the heck...
580 by Matthew Fuller
Add options to tell flex to disable bothering with yywrap and yyunput.
102
 *
103
 * This function should actually be unused due to the noyywrap %option
104
 * specified above, but is left around in case of weird edge cases.
384.1.3 by Matthew Fuller
Add a comment explaining why we have the #ifndef guard.
105
 */
11 by Claude Lecommandeur
CTWM version 3.2p1
106
#ifndef yywrap
93 by Richard Levitte
- Convert all functions to use proper prototypes.
107
int yywrap(void) { return(1);}
11 by Claude Lecommandeur
CTWM version 3.2p1
108
#endif
109
384.1.1 by Matthew Fuller
Little documentation of what's going on here.
110
/* AT&T lex uses the input/unput macros */
9 by Claude Lecommandeur
CTWM version 3.1
111
#ifndef FLEX_SCANNER
384.1.2 by Matthew Fuller
Just #error out on non-flex lex. The cmake build chain probably won't
112
/*
113
 * I believe Solaris at least recently recently (and maybe currently)
114
 * ships with an AT&T lex, but also with flex beside it.  Plan
115
 * 9 might ship only A&T lex?
116
 *
117
 * However, our current build toolchain doesn't look for any lex other
118
 * than flex.  So #error out if we get here; adventurous users might take
119
 * this out, and it might work; let us know!
120
 */
121
#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
122
#ifdef NON_FLEX_LEX
1 by Claude Lecommandeur
CTWM version 1.1
123
#undef unput
124
#undef input
125
#undef output
126
#undef feof
127
#define unput(c)	twmUnput(c)
128
#define input()		(*twmInputFunc)()
129
#define output(c)	TwmOutput(c)
130
#define feof()		(1)
386.1.1 by Matthew Fuller
Create a NON_FLEX_LEX define to hide non-flex-only bits behind, and
131
#endif /* NON_FLEX_LEX */
132
#endif /* !FLEX_SCANNER */
17 by Claude Lecommandeur
CTWM version 3.5
133