lex.l revision c2535118
1%{
2/*****************************************************************************/
3/*
4
5Copyright 1989,1998  The Open Group
6
7Permission to use, copy, modify, distribute, and sell this software and its
8documentation for any purpose is hereby granted without fee, provided that
9the above copyright notice appear in all copies and that both that
10copyright notice and this permission notice appear in supporting
11documentation.
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
19OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23Except as contained in this notice, the name of The Open Group shall not be
24used in advertising or otherwise to promote the sale, use or other dealings
25in this Software without prior written authorization from The Open Group.
26
27*/
28/**       Copyright 1988 by Evans & Sutherland Computer Corporation,        **/
29/**                          Salt Lake City, Utah                           **/
30/**                        Cambridge, Massachusetts                         **/
31/**                                                                         **/
32/**                           All Rights Reserved                           **/
33/**                                                                         **/
34/**    Permission to use, copy, modify, and distribute this software and    **/
35/**    its documentation  for  any  purpose  and  without  fee is hereby    **/
36/**    granted, provided that the above copyright notice appear  in  all    **/
37/**    copies and that both  that  copyright  notice  and  this  permis-    **/
38/**    sion  notice appear in supporting  documentation,  and  that  the    **/
39/**    name of Evans & Sutherland not be used in advertising    **/
40/**    in publicity pertaining to distribution of the  software  without    **/
41/**    specific, written prior permission.                                  **/
42/**                                                                         **/
43/**    EVANS & SUTHERLAND DISCLAIMs ALL WARRANTIES WITH REGARD    **/
44/**    TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES  OF  MERCHANT-    **/
45/**    ABILITY  AND  FITNESS,  IN  NO  EVENT SHALL EVANS & SUTHERLAND    **/
46/**    BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL  DAM-    **/
47/**    AGES OR  ANY DAMAGES WHATSOEVER  RESULTING FROM LOSS OF USE, DATA    **/
48/**    OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER    **/
49/**    TORTIOUS ACTION, ARISING OUT OF OR IN  CONNECTION  WITH  THE  USE    **/
50/**    OR PERFORMANCE OF THIS SOFTWARE.                                     **/
51/*****************************************************************************/
52
53/***********************************************************************
54 *
55 * $Xorg: lex.l,v 1.4 2001/02/09 02:05:36 xorgcvs Exp $
56 *
57 * .twmrc lex file
58 *
59 * 12-Nov-87 Thomas E. LaStrange		File created
60 *
61 ***********************************************************************/
62/* $XFree86: xc/programs/twm/lex.l,v 3.13 2001/08/27 21:11:39 dawes Exp $ */
63
64/* #include <stdio.h> */		/* lex already includes stdio.h */
65#include "twm.h"
66#include "gram.h"
67#include "list.h"
68#include "parse.h"
69
70#ifdef FLEX_SCANNER
71int yylineno;
72
73#undef YY_INPUT
74#define YY_INPUT(buf,result,size) ((result) = doinput((buf),(size)))
75static int doinput (char *buf, int size)
76{
77	int c;
78
79	if (size == 0)
80		return (0);
81
82	if ((c = (*twmInputFunc)()) <= 0)
83		return (0);
84
85	buf[0] = c;
86	return (1);
87}
88#define YY_NO_UNPUT
89#endif
90
91%}
92
93string				\"([^"]|\\.)*\"
94number				[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 ((char *)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"^"				{ yylval.num = F_CUT; return FSKEYWORD; }
120
121{string}			{ yylval.ptr = (char *)yytext; return STRING; }
122{number}			{ (void)sscanf((char *)yytext, "%d", &yylval.num);
123				  return (NUMBER);
124				}
125\#[^\n]*\n			{;}
126[\r\n\t ]			{;}
127.				{
128				  twmrc_error_prefix();
129				  fprintf (stderr,
130					   "ignoring character \"%s\"\n",
131					   yytext);
132				  ParseError = 1;
133				}
134%%
135#ifndef yywrap
136int yywrap() { return(1);}
137#endif
138
139#undef unput
140#undef input
141#undef output
142#undef feof
143#define unput(c)	twmUnput(c)
144#define input()		(*twmInputFunc)()
145#define output(c)	TwmOutput(c)
146#define feof()		(1)
147