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 /*****************************************************************************/
28 
29 /***********************************************************************
30  *
31  * $XConsortium: lex.l,v 1.62 89/12/10 17:46:33 jim Exp $
32  *
33  * .twmrc lex file
34  *
35  * 12-Nov-87 Thomas E. LaStrange		File created
36  *
37  ***********************************************************************/
38 
39 /* #include <stdio.h> */		/* lex already includes stdio.h */
40 #include "gram.h"
41 #include "parse.h"
42 extern char *ProgramName;
43 
44 extern int ParseError;
45 
46 #undef YY_INPUT
47 #define YY_INPUT(buf,result,max_size) \
48 	{ \
49 		int res = (*twmInputFunc)(); \
50 		if (res == NULL) \
51 			result = YY_NULL; \
52 		else \
53 		{ \
54 			buf[0] = res; \
55 			result = 1; \
56 		} \
57 	}
58 
59 %}
60 
61 string				\"([^"]|\\.)*\"
62 regexp				\/([^/]|\\.)*\/
63 number				[0-9]+
64 %%
65 "{"				{ return (LB); }
66 "}"				{ return (RB); }
67 "("				{ return (LP); }
68 ")"				{ return (RP); }
69 "="				{ return (EQUALS); }
70 "~"				{ return (TILDE); }
71 ":"				{ return (COLON); }
72 "+"				{ return PLUS; }
73 "-"				{ return MINUS; }
74 "|"				{ return OR; }
75 "*"				{ return ASTERISK; }
76 ">"				{ return GREATER; }
77 
78 [a-zA-Z\.]+			{ int token = parse_keyword (yytext,
79 							     &yylval.num);
80 				  if (token == ERRORTOKEN) {
81 				      twmrc_error_prefix();
82 				      fprintf (stderr,
83 				       "ignoring unknown keyword:  %s\n",
84 					       yytext);
85 				      ParseError = 1;
86 				  } else
87 				    return token;
88 				}
89 
90 "!"				{ yylval.num = F_EXEC; return FSKEYWORD; }
91 "!!"				{ yylval.num = F_WINEXEC; return FSKEYWORD; }
92 "^"				{ yylval.num = F_CUT; return FSKEYWORD; }
93 
94 {string}			{ yylval.ptr = (char *)yytext; return STRING; }
95 {regexp}			{ yylval.ptr = (char *)yytext; return REGEXP; }
96 {number}			{ (void)sscanf(yytext, "%d", &yylval.num);
97 				  return (NUMBER);
98 				}
99 \#[^\n]*\n			{;}
100 [\n\t ]				{;}
101 .				{
102 				  twmrc_error_prefix();
103 				  fprintf (stderr,
104 					   "ignoring character \"%s\"\n",
105 					   yytext);
106 				  ParseError = 1;
107 				}
108 %%
109 #ifndef yywrap
110 yywrap() { return(1);}
111 #endif
112 
113 #undef unput
114 /*#undef input*/
115 #undef output
116 #undef feof
117 #define unput(c)	twmUnput(c)
118 /*#define input()		(*twmInputFunc)()*/
119 #define output(c)	TwmOutput(c)
120 #define feof()		(1)
121