chiark / gitweb /
debian/changelog: start -4~
[vtwm.git] / lex.l
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
43 extern int parse_keyword();
44 extern void twmrc_error_prefix();
45
46 extern char *ProgramName;
47 extern int ParseError;
48
49 #ifdef FLEX_SCANNER
50 #undef  YY_INPUT
51 #define YY_INPUT(b,r,s)         r = ((b[0] = (*twmInputFunc)()) != 0)
52 #endif
53 %}
54
55 string                          \"([^"]|\\.)*\"
56 regexp                          \/([^/]|\\.)*\/
57 number                          [0-9]+
58 %%
59 "{"                             { return (LB); }
60 "}"                             { return (RB); }
61 "("                             { return (LP); }
62 ")"                             { return (RP); }
63 "="                             { return (EQUALS); }
64 "~"                             { return (TILDE); }
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);
77                                       ParseError = 1;
78                                   } else 
79                                     return token;
80                                 }
81
82 "!"                             { yylval.num = F_EXEC; return FSKEYWORD; }
83 "^"                             { yylval.num = F_CUT; return FSKEYWORD; }
84
85 {string}                        { yylval.ptr = (char *)yytext; return STRING; }
86 {regexp}                        { yylval.ptr = (char *)yytext; return REGEXP; }
87 {number}                        { (void)sscanf((char *)&yytext[0], "%d", &yylval.num);
88                                   return (NUMBER);
89                                 }
90 \#[^\n]*\n                      {;}
91 [\n\t ]                         {;}
92 .                               {
93                                   twmrc_error_prefix();
94                                   fprintf (stderr, 
95                                            "ignoring character \"%s\"\n",
96                                            yytext);
97                                   ParseError = 1;
98                                 }
99 %%
100 #ifndef FLEX_SCANNER
101 yywrap() { return(1);}
102
103 #undef input
104 #undef feof
105 #define feof()          (1)
106 #define input()         (*twmInputFunc)()
107 #endif
108 #undef output
109 #define output(c)       TwmOutput(c)
110 #undef unput
111 #define unput(c)        twmUnput(c)