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